LibreOffice Module sc (master) 1
op_array.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#include "op_array.hxx"
11
13#include <sstream>
14
15using namespace formula;
16
17namespace sc::opencl {
18
20 const std::string &sSymName, SubArguments &vSubArguments)
21{
25 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
26 ss << "{\n";
27 ss << " int gid0=get_global_id(0);\n";
28 ss << " double tmp =0;\n";
29 GenerateRangeArgPair( 0, 1, vSubArguments, ss, EmptyIsZero,
30 " tmp +=pow(arg1,2) - pow(arg2,2);\n"
31 );
32 ss << " return tmp;\n";
33 ss << "}\n";
34}
35
37 const std::string &sSymName, SubArguments &vSubArguments)
38{
42 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
43 ss << "{\n";
44 ss << " int gid0=get_global_id(0);\n";
45 ss << " double tmp =0;\n";
46 GenerateRangeArgPair( 0, 1, vSubArguments, ss, EmptyIsZero,
47 " tmp +=pow(arg1,2) + pow(arg2,2);\n"
48 );
49 ss << " return tmp;\n";
50 ss << "}\n";
51}
52
54 const std::string &sSymName, SubArguments &vSubArguments)
55{
59 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
60 ss << "{\n";
61 ss << " int gid0=get_global_id(0);\n";
62 ss << " double tmp =0;\n";
63 GenerateRangeArgPair( 0, 1, vSubArguments, ss, EmptyIsZero,
64 " tmp +=pow((arg1-arg2),2);\n"
65 );
66 ss << " return tmp;\n";
67 ss << "}\n";
68}
69
70}
71
72/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_array.cxx:19
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_array.cxx:36
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_array.cxx:53
void GenerateFunctionDeclaration(const std::string &sSymName, SubArguments &vSubArguments, outputstream &ss)
Definition: opbase.cxx:566
static void GenerateRangeArgPair(int arg1, int arg2, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code, const char *firstElementDiff=nullptr)
Definition: opbase.cxx:423
std::vector< DynamicKernelArgumentRef > SubArguments
Definition: opbase.hxx:347
#define CHECK_PARAMETER_DOUBLEVECTORREF(arg)
Definition: opbase.hxx:97
#define CHECK_PARAMETER_COUNT(min, max)
Definition: opbase.hxx:85