LibreOffice Module sc (master) 1
op_logical.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_logical.hxx"
11
13#include <sstream>
14
15using namespace formula;
16
17namespace sc::opencl {
18
20 const std::string &sSymName, SubArguments &vSubArguments)
21{
22 CHECK_PARAMETER_COUNT( 1, 30 );
23 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
24 ss << "{\n";
25 ss << " int gid0 = get_global_id(0);\n";
26 ss << " bool t = false;\n";
27 for(size_t j = 0; j< vSubArguments.size(); j++)
28 {
29 GenerateArg( j, vSubArguments, ss );
30 ss << " t = t " << openclOperator() << " (arg" << j << " != 0);\n";
31 }
32 ss << " return t;\n";
33 ss << "}\n";
34}
35
37 const std::string &sSymName, SubArguments &vSubArguments)
38{
39 CHECK_PARAMETER_COUNT( 1, 30 );
40 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
41 ss << "{\n";
42 ss << " int gid0 = get_global_id(0);\n";
43 ss << " bool t = true;\n";
44 for(size_t j = 0; j< vSubArguments.size(); j++)
45 {
46 GenerateArg( j, vSubArguments, ss, EmptyIsNan );
47 // AND() with a svSingleVectorRef pointing to an empty cell skips that cell.
48 // See ScInterpreter::ScAnd().
49 ss << " if( !isnan( arg" << j << " ))\n";
50 ss << " t = t " << openclOperator() << " (arg" << j << " != 0);\n";
51 }
52 ss << " return t;\n";
53 ss << "}\n";
54}
55
57 const std::string &sSymName, SubArguments &vSubArguments)
58{
60 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
61 ss << "{\n";
62 ss << " int gid0 = get_global_id(0);\n";
63 GenerateArg( 0, vSubArguments, ss );
64 ss << " return arg0 == 0;\n";
65 ss << "}\n";
66}
67
69 const std::string &sSymName, SubArguments &vSubArguments)
70{
72 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
73 ss << "{\n";
74 ss << " int gid0 = get_global_id(0);\n";
75 GenerateArg( 0, vSubArguments, ss );
76 if(vSubArguments.size()>1)
77 GenerateArg( 1, vSubArguments, ss );
78 else
79 ss << " double arg1 = 1;\n";
80 if(vSubArguments.size()>2)
81 GenerateArg( 2, vSubArguments, ss );
82 else
83 ss << " double arg2 = 0;\n";
84
85 ss << " if(arg0 != 0)\n";
86 ss << " return arg1;\n";
87 ss << " else\n";
88 ss << " return arg2;\n";
89 ss << "}\n";
90}
91
92}
93/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_logical.cxx:36
virtual const char * openclOperator() const override
The C operator implementing the function.
Definition: op_logical.hxx:33
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_logical.cxx:68
virtual const char * openclOperator() const =0
The C operator implementing the function.
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_logical.cxx:19
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_logical.cxx:56
void GenerateArg(const char *name, int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero, GenerateArgTypeType generateType=DoNotGenerateArgType)
Definition: opbase.cxx:226
void GenerateFunctionDeclaration(const std::string &sSymName, SubArguments &vSubArguments, outputstream &ss)
Definition: opbase.cxx:563
std::vector< DynamicKernelArgumentRef > SubArguments
Definition: opbase.hxx:347
#define CHECK_PARAMETER_COUNT(min, max)
Definition: opbase.hxx:85