fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / opencl / op_array.cxx
blobb642c3b187ea4a625dcabef5028e3eb41ae76ee1
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_array.hxx"
12 #include "formulagroup.hxx"
13 #include "document.hxx"
14 #include "formulacell.hxx"
15 #include "tokenarray.hxx"
16 #include "compiler.hxx"
17 #include "interpre.hxx"
18 #include <formula/vectortoken.hxx>
19 #include <sstream>
21 using namespace formula;
23 namespace sc { namespace opencl {
25 void OpSumX2MY2::GenSlidingWindowFunction(std::stringstream &ss,
26 const std::string &sSymName, SubArguments &vSubArguments)
28 ss << "\ndouble " << sSymName;
29 ss << "_"<< BinFuncName() <<"(";
30 for (unsigned i = 0; i < vSubArguments.size(); i++)
32 if (i)
33 ss << ",";
34 vSubArguments[i]->GenSlidingWindowDecl(ss);
36 ss << ")\n {\n";
37 ss <<" int gid0=get_global_id(0);\n";
38 ss << " double tmp =0;\n";
39 GenTmpVariables(ss,vSubArguments);
40 if(vSubArguments[0]->GetFormulaToken()->GetType() ==
41 formula::svDoubleVectorRef)
43 FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
44 const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
45 formula::DoubleVectorRefToken *>(tmpCur);
46 size_t nCurWindowSize = pCurDVR->GetArrayLength() <
47 pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
48 pCurDVR->GetRefRowSize() ;
49 ss << " int i ;\n";
50 ss << " for (i = ";
51 if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
52 ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
53 } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
54 ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
55 } else {
56 ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
58 ss << " {\n";
59 if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
61 ss << " int doubleIndex =i+gid0;\n";
62 }else
64 ss << " int doubleIndex =i;\n";
67 CheckSubArgumentIsNan(ss,vSubArguments,0);
68 CheckSubArgumentIsNan(ss,vSubArguments,1);
69 ss << " tmp +=pow(tmp0,2) - pow(tmp1,2);\n";
70 ss <<" }\n";
72 else
74 ss << " int singleIndex =gid0;\n";
75 CheckAllSubArgumentIsNan(ss, vSubArguments);
76 ss << " tmp = pow(tmp0,2) - pow(tmp1,2);\n";
78 ss << "return tmp;\n";
79 ss << "}";
82 void OpSumX2PY2::GenSlidingWindowFunction(std::stringstream &ss,
83 const std::string &sSymName, SubArguments &vSubArguments)
85 ss << "\ndouble " << sSymName;
86 ss << "_"<< BinFuncName() <<"(";
87 for (unsigned i = 0; i < vSubArguments.size(); i++)
89 if (i)
90 ss << ",";
91 vSubArguments[i]->GenSlidingWindowDecl(ss);
93 ss << ")\n {\n";
94 ss << " int gid0=get_global_id(0);\n";
95 ss << " double tmp =0;\n";
96 GenTmpVariables(ss,vSubArguments);
97 if(vSubArguments[0]->GetFormulaToken()->GetType() ==
98 formula::svDoubleVectorRef)
100 FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
101 const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
102 formula::DoubleVectorRefToken *>(tmpCur);
103 size_t nCurWindowSize = pCurDVR->GetArrayLength() <
104 pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
105 pCurDVR->GetRefRowSize() ;
106 ss << " int i ;\n";
107 ss << " for (i = ";
108 if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
109 ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
110 } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
111 ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
112 } else {
113 ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
115 ss << " {\n";
116 if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
118 ss << " int doubleIndex =i+gid0;\n";
119 }else
121 ss << " int doubleIndex =i;\n";
124 CheckSubArgumentIsNan(ss,vSubArguments,0);
125 CheckSubArgumentIsNan(ss,vSubArguments,1);
126 ss << " tmp +=pow(tmp0,2) + pow(tmp1,2);\n";
127 ss <<" }\n";
129 else
131 ss << " int singleIndex =gid0;\n";
132 CheckAllSubArgumentIsNan(ss, vSubArguments);
133 ss << " tmp = pow(tmp0,2) + pow(tmp1,2);\n";
135 ss << " return tmp;\n";
136 ss << "}";
138 void OpSumXMY2::GenSlidingWindowFunction(std::stringstream &ss,
139 const std::string &sSymName, SubArguments &vSubArguments)
141 ss << "\ndouble " << sSymName;
142 ss << "_"<< BinFuncName() <<"(";
143 for (unsigned i = 0; i < vSubArguments.size(); i++)
145 if (i)
146 ss << ",";
147 vSubArguments[i]->GenSlidingWindowDecl(ss);
149 ss << ")\n {\n";
150 ss << " int gid0=get_global_id(0);\n";
151 ss << " double tmp =0;\n";
152 GenTmpVariables(ss,vSubArguments);
153 if(vSubArguments[0]->GetFormulaToken()->GetType() ==
154 formula::svDoubleVectorRef)
156 FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
157 const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
158 formula::DoubleVectorRefToken *>(tmpCur);
159 size_t nCurWindowSize = pCurDVR->GetArrayLength() <
160 pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
161 pCurDVR->GetRefRowSize() ;
162 ss << " int i ;\n";
163 ss << " for (i = ";
164 if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
165 ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
166 } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
167 ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
168 } else {
169 ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
171 ss << " {\n";
172 if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
174 ss << " int doubleIndex =i+gid0;\n";
175 }else
177 ss << " int doubleIndex =i;\n";
180 CheckSubArgumentIsNan(ss,vSubArguments,0);
181 CheckSubArgumentIsNan(ss,vSubArguments,1);
182 ss << " tmp +=pow((tmp0-tmp1),2);\n";
183 ss <<" }\n";
185 else
187 ss << " int singleIndex =gid0;\n";
188 CheckAllSubArgumentIsNan(ss, vSubArguments);
189 ss << " tmp = pow((tmp0-tmp1),2);\n";
191 ss << " return tmp;\n";
192 ss << "}";
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */