Update git submodules
[LibreOffice.git] / sc / source / core / opencl / op_logical.cxx
blob16a66698dcd748bb795c9c15f28278fe0c5d3499
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include "op_logical.hxx"
12 #include <sstream>
14 namespace sc::opencl {
16 void OpLogicalBinaryOperator::GenSlidingWindowFunction(outputstream &ss,
17 const std::string &sSymName, SubArguments &vSubArguments)
19 CHECK_PARAMETER_COUNT( 1, 30 );
20 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
21 ss << "{\n";
22 ss << " int gid0 = get_global_id(0);\n";
23 ss << " bool t = false;\n";
24 for(size_t j = 0; j< vSubArguments.size(); j++)
26 GenerateArg( j, vSubArguments, ss );
27 ss << " t = t " << openclOperator() << " (arg" << j << " != 0);\n";
29 ss << " return t;\n";
30 ss << "}\n";
33 void OpAnd::GenSlidingWindowFunction(outputstream &ss,
34 const std::string &sSymName, SubArguments &vSubArguments)
36 CHECK_PARAMETER_COUNT( 1, 30 );
37 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
38 ss << "{\n";
39 ss << " int gid0 = get_global_id(0);\n";
40 ss << " bool t = true;\n";
41 for(size_t j = 0; j< vSubArguments.size(); j++)
43 GenerateArg( j, vSubArguments, ss, EmptyIsNan );
44 // AND() with a svSingleVectorRef pointing to an empty cell skips that cell.
45 // See ScInterpreter::ScAnd().
46 ss << " if( !isnan( arg" << j << " ))\n";
47 ss << " t = t " << openclOperator() << " (arg" << j << " != 0);\n";
49 ss << " return t;\n";
50 ss << "}\n";
53 void OpNot::GenSlidingWindowFunction(outputstream &ss,
54 const std::string &sSymName, SubArguments &vSubArguments)
56 CHECK_PARAMETER_COUNT( 1, 1 );
57 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
58 ss << "{\n";
59 ss << " int gid0 = get_global_id(0);\n";
60 GenerateArg( 0, vSubArguments, ss );
61 ss << " return arg0 == 0;\n";
62 ss << "}\n";
65 void OpIf::GenSlidingWindowFunction(outputstream &ss,
66 const std::string &sSymName, SubArguments &vSubArguments)
68 CHECK_PARAMETER_COUNT( 1, 3 );
69 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
70 ss << "{\n";
71 ss << " int gid0 = get_global_id(0);\n";
72 GenerateArg( 0, vSubArguments, ss );
73 if(vSubArguments.size()>1)
74 GenerateArg( 1, vSubArguments, ss );
75 else
76 ss << " double arg1 = 1;\n";
77 if(vSubArguments.size()>2)
78 GenerateArg( 2, vSubArguments, ss );
79 else
80 ss << " double arg2 = 0;\n";
82 ss << " if(arg0 != 0)\n";
83 ss << " return arg1;\n";
84 ss << " else\n";
85 ss << " return arg2;\n";
86 ss << "}\n";
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */