1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include "op_logical.hxx"
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
);
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";
33 void OpAnd::GenSlidingWindowFunction(outputstream
&ss
,
34 const std::string
&sSymName
, SubArguments
&vSubArguments
)
36 CHECK_PARAMETER_COUNT( 1, 30 );
37 GenerateFunctionDeclaration( sSymName
, vSubArguments
, ss
);
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";
53 void OpNot::GenSlidingWindowFunction(outputstream
&ss
,
54 const std::string
&sSymName
, SubArguments
&vSubArguments
)
56 CHECK_PARAMETER_COUNT( 1, 1 );
57 GenerateFunctionDeclaration( sSymName
, vSubArguments
, ss
);
59 ss
<< " int gid0 = get_global_id(0);\n";
60 GenerateArg( 0, vSubArguments
, ss
);
61 ss
<< " return arg0 == 0;\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
);
71 ss
<< " int gid0 = get_global_id(0);\n";
72 GenerateArg( 0, vSubArguments
, ss
);
73 if(vSubArguments
.size()>1)
74 GenerateArg( 1, vSubArguments
, ss
);
76 ss
<< " double arg1 = 1;\n";
77 if(vSubArguments
.size()>2)
78 GenerateArg( 2, vSubArguments
, ss
);
80 ss
<< " double arg2 = 0;\n";
82 ss
<< " if(arg0 != 0)\n";
83 ss
<< " return arg1;\n";
85 ss
<< " return arg2;\n";
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */