LibreOffice Module sc (master)  1
op_database.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_database.hxx"
11 
12 #include <formula/vectortoken.hxx>
13 #include <sstream>
14 
15 namespace sc::opencl {
16 
17 void OpDmax::GenSlidingWindowFunction(std::stringstream &ss,
18  const std::string &sSymName, SubArguments &vSubArguments)
19 {
20  ss << "\ndouble " << sSymName;
21  ss << "_"<< BinFuncName() <<"(";
22  for (size_t i = 0; i < vSubArguments.size(); i++)
23  {
24  if (i)
25  ss << ",";
26  vSubArguments[i]->GenSlidingWindowDecl(ss);
27  }
28  ss << ")\n {\n";
29  ss << " int gid0=get_global_id(0);\n";
30  ss << " double max = -1000000000000;\n";
31  ss << " double value=0.0;\n";
32  GenTmpVariables(ss,vSubArguments);
33  int dataCol = 0;
34  int dataRow = 0;
35  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
37  throw Unhandled(__FILE__, __LINE__);
38 
39  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
40  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
42  dataCol = pCurDVR->GetArrays().size();
43  dataRow = pCurDVR->GetArrayLength();
44 
45  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
47  throw Unhandled(__FILE__, __LINE__);
48 
49  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
50  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
51  GetFormulaToken());
52  ss << " tmp"<<dataCol<<"=";
53  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
54  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
55  ss << "tmp"<<dataCol<<"))\n";
56  ss << " tmp"<<dataCol<<"=0;\n";
57 
58  int conditionCol = 0;
59  int conditionRow = 0;
60  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
62  {
63  throw Unhandled(__FILE__, __LINE__);
64  }
65  tmpCur = vSubArguments[dataCol + 1]->
66  GetFormulaToken();
67  pCurDVR= static_cast<const
69  conditionCol = pCurDVR->GetArrays().size();
70  conditionRow = pCurDVR->GetArrayLength();
71 
72  if(dataCol!=conditionCol)
73  throw Unhandled(__FILE__, __LINE__);
74  if(dataCol > 0 && dataRow > 0)
75  {
76  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
77  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
78  GetFormulaToken();
79  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
81  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
83 
84  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
85  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
86  {
87  ss << " int i,j,p;\n";
88  ss << " bool flag;\n";
89  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
90  ss << " {\n";
91  ss << " i = p;\n";
92  for(int i = 0; i < dataCol; ++i){
93  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
95  throw Unhandled(__FILE__, __LINE__);
96  ss << " tmp"<<i<<"=";
97  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
98  ss << " if(isnan(tmp"<<i<<"))\n";
99  ss <<" tmp"<<i<<" = 0;\n";
100  }
101  ss << " flag = false;\n";
102  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
103  ss << " {\n";
104  ss << " i = j;\n";
105  ss << " if (flag)\n";
106  ss << " break;\n";
107  ss << " else{\n";
108  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
109  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
111  throw Unhandled(__FILE__, __LINE__);
112  ss << " tmp"<<i<<"=";
113  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
114  ss << " if(!isnan(tmp"<<i<<")){\n";
115  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
116  ss << i<<"){\n";
117  ss << " continue;\n";
118  ss << " }\n";
119  ss << " }\n";
120  }
121  ss << " flag=true;\n";
122  ss << " }\n";
123  ss << " }\n";
124  ss << " if (flag){\n";
125  for(int i = 0; i < dataCol; ++i){
126  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
127  ss << " value=tmp"<<i<<";\n";
128  ss << " }\n";
129  }
130  ss << " if(max<value)\n";
131  ss << " max=value;";
132  ss << " }\n";
133  ss << " }\n";
134  }
135  else
136  ss << "max = -1;\n";
137  }
138  else
139  ss << "max = -1;\n";
140  ss << " return max;\n";
141  ss << "}";
142 }
143 
144 void OpDmin::GenSlidingWindowFunction(std::stringstream &ss,
145  const std::string &sSymName, SubArguments &vSubArguments)
146 {
147  ss << "\ndouble " << sSymName;
148  ss << "_"<< BinFuncName() <<"(";
149  for (size_t i = 0; i < vSubArguments.size(); i++)
150  {
151  if (i)
152  ss << ",";
153  vSubArguments[i]->GenSlidingWindowDecl(ss);
154  }
155  ss << ")\n {\n";
156  ss << " int gid0=get_global_id(0);\n";
157  ss << " double min = 1000000000000;\n";
158  ss << " double value=0.0;\n";
159  GenTmpVariables(ss,vSubArguments);
160  int dataCol = 0;
161  int dataRow = 0;
162  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
164  throw Unhandled(__FILE__, __LINE__);
165 
166  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
167  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
169  dataCol = pCurDVR->GetArrays().size();
170  dataRow = pCurDVR->GetArrayLength();
171 
172  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
174  throw Unhandled(__FILE__, __LINE__);
175 
176  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
177  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
178  GetFormulaToken());
179  ss << " tmp"<<dataCol<<"=";
180  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
181  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
182  ss << "tmp"<<dataCol<<"))\n";
183  ss << " tmp"<<dataCol<<"=0;\n";
184 
185  int conditionCol = 0;
186  int conditionRow = 0;
187  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
189  {
190  throw Unhandled(__FILE__, __LINE__);
191  }
192  tmpCur = vSubArguments[dataCol + 1]->
193  GetFormulaToken();
194  pCurDVR= static_cast<const
196  conditionCol = pCurDVR->GetArrays().size();
197  conditionRow = pCurDVR->GetArrayLength();
198 
199  if(dataCol!=conditionCol)
200  throw Unhandled(__FILE__, __LINE__);
201  if(dataCol > 0 && dataRow > 0)
202  {
203  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
204  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
205  GetFormulaToken();
206  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
207  formula::DoubleVectorRefToken *>(tmpCur1);
208  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
209  formula::DoubleVectorRefToken *>(tmpCur2);
210 
211  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
212  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
213  {
214  ss << " int i,j,p;\n";
215  ss << " bool flag;\n";
216 
217  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
218  ss << " {\n";
219  ss << " i = p;\n";
220  for(int i = 0; i < dataCol; ++i){
221  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
223  throw Unhandled(__FILE__, __LINE__);
224  ss << " tmp"<<i<<"=";
225  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
226  ss << " if(isnan(tmp"<<i<<"))\n";
227  ss <<" tmp"<<i<<" = 0;\n";
228  }
229  ss << " flag = false;\n";
230  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
231  ss << " {\n";
232  ss << " i = j;\n";
233  ss << " if (flag)\n";
234  ss << " break;\n";
235  ss << " else{\n";
236  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
237  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
239  throw Unhandled(__FILE__, __LINE__);
240  ss << " tmp"<<i<<"=";
241  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
242  ss << " if(!isnan(tmp"<<i<<")){\n";
243  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
244  ss << i<<"){\n";
245  ss << " continue;\n";
246  ss << " }\n";
247  ss << " }\n";
248  }
249  ss << " flag=true;\n";
250  ss << " }\n";
251  ss << " }\n";
252  ss << " if (flag){\n";
253  for(int i = 0; i < dataCol; ++i){
254  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
255  ss << " value=tmp"<<i<<";\n";
256  ss << " }\n";
257  }
258  ss << " if(min>value)\n";
259  ss << " min=value;";
260  ss << " }\n";
261  ss << " }\n";
262  }
263  else
264  ss << "min = -1;\n";
265  }
266  else
267  ss << "min = -1;\n";
268  ss << " return min;\n";
269  ss << "}";
270 }
271 
272 void OpDproduct::GenSlidingWindowFunction(std::stringstream &ss,
273  const std::string &sSymName, SubArguments &vSubArguments)
274 {
275  ss << "\ndouble " << sSymName;
276  ss << "_"<< BinFuncName() <<"(";
277  for (size_t i = 0; i < vSubArguments.size(); i++)
278  {
279  if (i)
280  ss << ",";
281  vSubArguments[i]->GenSlidingWindowDecl(ss);
282  }
283  ss << ")\n {\n";
284  ss << " int gid0=get_global_id(0);\n";
285  ss << " double product = 1;\n";
286  ss << " double value =0;\n";
287  GenTmpVariables(ss,vSubArguments);
288  int dataCol = 0;
289  int dataRow = 0;
290  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
292  throw Unhandled(__FILE__, __LINE__);
293 
294  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
295  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
297  dataCol = pCurDVR->GetArrays().size();
298  dataRow = pCurDVR->GetArrayLength();
299 
300  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
302  throw Unhandled(__FILE__, __LINE__);
303 
304  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
305  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
306  GetFormulaToken());
307  ss << " tmp"<<dataCol<<"=";
308  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
309  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
310  ss << "tmp"<<dataCol<<"))\n";
311  ss << " tmp"<<dataCol<<"=0;\n";
312 
313  int conditionCol = 0;
314  int conditionRow = 0;
315  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
317  {
318  throw Unhandled(__FILE__, __LINE__);
319  }
320  tmpCur = vSubArguments[dataCol + 1]->
321  GetFormulaToken();
322  pCurDVR= static_cast<const
324  conditionCol = pCurDVR->GetArrays().size();
325  conditionRow = pCurDVR->GetArrayLength();
326 
327  if(dataCol!=conditionCol)
328  throw Unhandled(__FILE__, __LINE__);
329  if(dataCol > 0 && dataRow > 0)
330  {
331  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
332  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
333  GetFormulaToken();
334  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
335  formula::DoubleVectorRefToken *>(tmpCur1);
336  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
337  formula::DoubleVectorRefToken *>(tmpCur2);
338 
339  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
340  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
341  {
342  ss << " int i,j,p;\n";
343  ss << " bool flag;\n";
344  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
345  ss << " {\n";
346  ss << " i = p;\n";
347  for(int i = 0; i < dataCol; ++i){
348  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
350  throw Unhandled(__FILE__, __LINE__);
351  ss << " tmp"<<i<<"=";
352  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
353  ss << " if(isnan(tmp"<<i<<"))\n";
354  ss <<" tmp"<<i<<" = 0;\n";
355  }
356  ss << " flag = false;\n";
357  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
358  ss << " {\n";
359  ss << " i = j;\n";
360  ss << " if (flag)\n";
361  ss << " break;\n";
362  ss << " else{\n";
363  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
364  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
366  throw Unhandled(__FILE__, __LINE__);
367  ss << " tmp"<<i<<"=";
368  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
369  ss << " if(!isnan(tmp"<<i<<")){\n";
370  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
371  ss << i<<"){\n";
372  ss << " continue;\n";
373  ss << " }\n";
374  ss << " }\n";
375  }
376  ss << " flag=true;\n";
377  ss << " }\n";
378  ss << " }\n";
379  ss << " if (flag){\n";
380  for(int i = 0; i < dataCol; ++i){
381  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
382  ss << " value=tmp"<<i<<";\n";
383  ss << " }\n";
384  }
385  ss << " product*=value;\n";
386  ss << " }\n";
387  ss << " }\n";
388  }
389  else
390  ss << "product = -1;\n";
391  }
392  else
393  ss << "product = -1;\n";
394  ss << " return product;\n";
395  ss << "}";
396 }
397 
398 void OpDaverage::GenSlidingWindowFunction(std::stringstream &ss,
399  const std::string &sSymName, SubArguments &vSubArguments)
400 {
401  ss << "\ndouble " << sSymName;
402  ss << "_"<< BinFuncName() <<"(";
403  for (size_t i = 0; i < vSubArguments.size(); i++)
404  {
405  if (i)
406  ss << ",";
407  vSubArguments[i]->GenSlidingWindowDecl(ss);
408  }
409  ss << ")\n {\n";
410  ss << " int gid0=get_global_id(0);\n";
411  ss << " double sum = 0;\n";
412  ss << " int count = 0;\n";
413  ss << " double value =0;\n";
414  GenTmpVariables(ss,vSubArguments);
415  int dataCol = 0;
416  int dataRow = 0;
417  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
419  throw Unhandled(__FILE__, __LINE__);
420 
421  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
422  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
424  dataCol = pCurDVR->GetArrays().size();
425  dataRow = pCurDVR->GetArrayLength();
426 
427  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
429  throw Unhandled(__FILE__, __LINE__);
430 
431  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
432  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
433  GetFormulaToken());
434  ss << " tmp"<<dataCol<<"=";
435  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
436  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
437  ss << "tmp"<<dataCol<<"))\n";
438  ss << " tmp"<<dataCol<<"=0;\n";
439 
440  int conditionCol = 0;
441  int conditionRow = 0;
442  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
444  {
445  throw Unhandled(__FILE__, __LINE__);
446  }
447  tmpCur = vSubArguments[dataCol + 1]->
448  GetFormulaToken();
449  pCurDVR= static_cast<const
451  conditionCol = pCurDVR->GetArrays().size();
452  conditionRow = pCurDVR->GetArrayLength();
453 
454  if(dataCol!=conditionCol)
455  throw Unhandled(__FILE__, __LINE__);
456  if(dataCol > 0 && dataRow > 0)
457  {
458  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
459  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
460  GetFormulaToken();
461  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
462  formula::DoubleVectorRefToken *>(tmpCur1);
463  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
464  formula::DoubleVectorRefToken *>(tmpCur2);
465 
466  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
467  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
468  {
469  ss << " int i,j,p;\n";
470  ss << " bool flag;\n";
471 
472  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
473  ss << " {\n";
474  ss << " i = p;\n";
475  for(int i = 0; i < dataCol; ++i){
476  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
478  throw Unhandled(__FILE__, __LINE__);
479  ss << " tmp"<<i<<"=";
480  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
481  ss << " if(isnan(tmp"<<i<<"))\n";
482  ss <<" tmp"<<i<<" = 0;\n";
483  }
484  ss << " flag = false;\n";
485  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
486  ss << " {\n";
487  ss << " i = j;\n";
488  ss << " if (flag)\n";
489  ss << " break;\n";
490  ss << " else{\n";
491  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
492  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
494  throw Unhandled(__FILE__, __LINE__);
495  ss << " tmp"<<i<<"=";
496  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
497  ss << " if(!isnan(tmp"<<i<<")){\n";
498  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
499  ss << i<<"){\n";
500  ss << " continue;\n";
501  ss << " }\n";
502  ss << " }\n";
503  }
504  ss << " flag=true;\n";
505  ss << " }\n";
506  ss << " }\n";
507  ss << " if (flag){\n";
508  ss << " count++;\n";
509  for(int i = 0; i < dataCol; ++i){
510  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
511  ss << " value=tmp"<<i<<";\n";
512  ss << " }\n";
513  }
514  ss << " sum+=value;\n";
515  ss << " }\n";
516  ss << " }\n";
517  }
518  else
519  ss << "sum = -1;\n";
520  }
521  else
522  ss << "sum = -1;\n";
523  ss << " if(count==0)\n";
524  ss << " return 0;\n";
525  ss << " return sum/count;\n";
526  ss << "}";
527 }
528 
529 void OpDstdev::GenSlidingWindowFunction(std::stringstream &ss,
530  const std::string &sSymName, SubArguments &vSubArguments)
531 {
532  ss << "\ndouble " << sSymName;
533  ss << "_"<< BinFuncName() <<"(";
534  for (size_t i = 0; i < vSubArguments.size(); i++)
535  {
536  if (i)
537  ss << ",";
538  vSubArguments[i]->GenSlidingWindowDecl(ss);
539  }
540  ss << ")\n {\n";
541  ss << " int gid0=get_global_id(0);\n";
542  ss << " double var = 0;\n";
543  ss << " double mean = 0;\n";
544  ss << " double value =0;\n";
545  ss << " int count = 0;\n";
546  GenTmpVariables(ss,vSubArguments);
547  int dataCol = 0;
548  int dataRow = 0;
549  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
551  throw Unhandled(__FILE__, __LINE__);
552 
553  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
554  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
556  dataCol = pCurDVR->GetArrays().size();
557  dataRow = pCurDVR->GetArrayLength();
558 
559  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
561  throw Unhandled(__FILE__, __LINE__);
562 
563  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
564  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
565  GetFormulaToken());
566  ss << " tmp"<<dataCol<<"=";
567  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
568  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
569  ss << "tmp"<<dataCol<<"))\n";
570  ss << " tmp"<<dataCol<<"=0;\n";
571 
572  int conditionCol = 0;
573  int conditionRow = 0;
574  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
576  {
577  throw Unhandled(__FILE__, __LINE__);
578  }
579  tmpCur = vSubArguments[dataCol + 1]->
580  GetFormulaToken();
581  pCurDVR= static_cast<const
583  conditionCol = pCurDVR->GetArrays().size();
584  conditionRow = pCurDVR->GetArrayLength();
585 
586  if(dataCol!=conditionCol)
587  throw Unhandled(__FILE__, __LINE__);
588  if(dataCol > 0 && dataRow > 0)
589  {
590  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
591  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
592  GetFormulaToken();
593  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
594  formula::DoubleVectorRefToken *>(tmpCur1);
595  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
596  formula::DoubleVectorRefToken *>(tmpCur2);
597 
598  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
599  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
600  {
601  ss << " int i,j,p;\n";
602  ss << " bool flag;\n";
603 
604  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
605  ss << " {\n";
606  ss << " i = p;\n";
607  for(int i = 0; i < dataCol; ++i){
608  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
610  throw Unhandled(__FILE__, __LINE__);
611  ss << " tmp"<<i<<"=";
612  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
613  ss << " if(isnan(tmp"<<i<<"))\n";
614  ss <<" tmp"<<i<<" = 0;\n";
615  }
616  ss << " flag = false;\n";
617  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
618  ss << " {\n";
619  ss << " i = j;\n";
620  ss << " if (flag)\n";
621  ss << " break;\n";
622  ss << " else{\n";
623  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
624  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
626  throw Unhandled(__FILE__, __LINE__);
627  ss << " tmp"<<i<<"=";
628  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
629  ss << " if(!isnan(tmp"<<i<<")){\n";
630  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
631  ss << i<<"){\n";
632  ss << " continue;\n";
633  ss << " }\n";
634  ss << " }\n";
635  }
636  ss << " flag=true;\n";
637  ss << " }\n";
638  ss << " }\n";
639  ss << " if (flag){\n";
640  ss << " count++;\n";
641  for(int i = 0; i < dataCol; ++i){
642  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
643  ss << " value=tmp"<<i<<";\n";
644  ss << " }\n";
645  }
646  ss << " mean+=value;\n";
647  ss << " }\n";
648  ss << " }\n";
649 
650  ss << " if(count<=1)\n";
651  ss << " return 0;\n";
652 
653  ss << " mean/=count;\n";
654 
655  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
656  ss << " {\n";
657  ss << " i = p;\n";
658  for(int i = 0; i < dataCol; ++i){
659  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
661  throw Unhandled(__FILE__, __LINE__);
662  ss << " tmp"<<i<<"=";
663  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
664  ss << " if(isnan(tmp"<<i<<"))\n";
665  ss <<" tmp"<<i<<" = 0;\n";
666  }
667  ss << " flag = false;\n";
668  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
669  ss << " {\n";
670  ss << " i = j;\n";
671  ss << " if (flag)\n";
672  ss << " break;\n";
673  ss << " else{\n";
674  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
675  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
677  throw Unhandled(__FILE__, __LINE__);
678  ss << " tmp"<<i<<"=";
679  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
680  ss << " if(!isnan(tmp"<<i<<")){\n";
681  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
682  ss << i<<"){\n";
683  ss << " continue;\n";
684  ss << " }\n";
685  ss << " }\n";
686  }
687  ss << " flag=true;\n";
688  ss << " }\n";
689  ss << " }\n";
690  ss << " if (flag){\n";
691  for(int i = 0; i < dataCol; ++i){
692  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
693  ss << " value=tmp"<<i<<";\n";
694  ss << " }\n";
695  }
696  ss << " var+=pow(mean-value,2);\n";
697  ss << " }\n";
698  ss << " }\n";
699 
700  ss << " var = sqrt( var/(count-1) );\n";
701  }
702  else
703  ss << "var = -1;\n";
704  }
705  else
706  ss << "var = -1;\n";
707  ss << " return var;\n";
708  ss << "}";
709 }
710 
711 void OpDstdevp::GenSlidingWindowFunction(std::stringstream &ss,
712  const std::string &sSymName, SubArguments &vSubArguments)
713 {
714  ss << "\ndouble " << sSymName;
715  ss << "_"<< BinFuncName() <<"(";
716  for (size_t i = 0; i < vSubArguments.size(); i++)
717  {
718  if (i)
719  ss << ",";
720  vSubArguments[i]->GenSlidingWindowDecl(ss);
721  }
722  ss << ")\n {\n";
723  ss << " int gid0=get_global_id(0);\n";
724  ss << " double var = 0;\n";
725  ss << " double mean = 0;\n";
726  ss << " double value =0;\n";
727  ss << " int count = 0;\n";
728  GenTmpVariables(ss,vSubArguments);
729  int dataCol = 0;
730  int dataRow = 0;
731  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
733  throw Unhandled(__FILE__, __LINE__);
734 
735  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
736  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
738  dataCol = pCurDVR->GetArrays().size();
739  dataRow = pCurDVR->GetArrayLength();
740 
741  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
743  throw Unhandled(__FILE__, __LINE__);
744 
745  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
746  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
747  GetFormulaToken());
748  ss << " tmp"<<dataCol<<"=";
749  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
750  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
751  ss << "tmp"<<dataCol<<"))\n";
752  ss << " tmp"<<dataCol<<"=0;\n";
753 
754  int conditionCol = 0;
755  int conditionRow = 0;
756  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
758  {
759  throw Unhandled(__FILE__, __LINE__);
760  }
761  tmpCur = vSubArguments[dataCol + 1]->
762  GetFormulaToken();
763  pCurDVR= static_cast<const
765  conditionCol = pCurDVR->GetArrays().size();
766  conditionRow = pCurDVR->GetArrayLength();
767 
768  if(dataCol!=conditionCol)
769  throw Unhandled(__FILE__, __LINE__);
770  if(dataCol > 0 && dataRow > 0)
771  {
772  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
773  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
774  GetFormulaToken();
775  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
776  formula::DoubleVectorRefToken *>(tmpCur1);
777  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
778  formula::DoubleVectorRefToken *>(tmpCur2);
779 
780  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
781  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
782  {
783  ss << " int i,j,p;\n";
784  ss << " bool flag;\n";
785 
786  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
787  ss << " {\n";
788  ss << " i = p;\n";
789  for(int i = 0; i < dataCol; ++i){
790  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
792  throw Unhandled(__FILE__, __LINE__);
793  ss << " tmp"<<i<<"=";
794  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
795  ss << " if(isnan(tmp"<<i<<"))\n";
796  ss <<" tmp"<<i<<" = 0;\n";
797  }
798  ss << " flag = false;\n";
799  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
800  ss << " {\n";
801  ss << " i = j;\n";
802  ss << " if (flag)\n";
803  ss << " break;\n";
804  ss << " else{\n";
805  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
806  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
808  throw Unhandled(__FILE__, __LINE__);
809  ss << " tmp"<<i<<"=";
810  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
811  ss << " if(!isnan(tmp"<<i<<")){\n";
812  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
813  ss << i<<"){\n";
814  ss << " continue;\n";
815  ss << " }\n";
816  ss << " }\n";
817  }
818  ss << " flag=true;\n";
819  ss << " }\n";
820  ss << " }\n";
821  ss << " if (flag){\n";
822  ss << " count++;\n";
823  for(int i = 0; i < dataCol; ++i){
824  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
825  ss << " value=tmp"<<i<<";\n";
826  ss << " }\n";
827  }
828  ss << " mean+=value;\n";
829  ss << " }\n";
830  ss << " }\n";
831 
832  ss << " if(count<=1)\n";
833  ss << " return 0;\n";
834 
835  ss << " mean/=count;\n";
836 
837  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
838  ss << " {\n";
839  ss << " i = p;\n";
840  for(int i = 0; i < dataCol; ++i){
841  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
843  throw Unhandled(__FILE__, __LINE__);
844  ss << " tmp"<<i<<"=";
845  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
846  ss << " if(isnan(tmp"<<i<<"))\n";
847  ss <<" tmp"<<i<<" = 0;\n";
848  }
849  ss << " flag = false;\n";
850  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
851  ss << " {\n";
852  ss << " i = j;\n";
853  ss << " if (flag)\n";
854  ss << " break;\n";
855  ss << " else{\n";
856  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
857  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
859  throw Unhandled(__FILE__, __LINE__);
860  ss << " tmp"<<i<<"=";
861  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
862  ss << " if(!isnan(tmp"<<i<<")){\n";
863  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
864  ss << i<<"){\n";
865  ss << " continue;\n";
866  ss << " }\n";
867  ss << " }\n";
868  }
869  ss << " flag=true;\n";
870  ss << " }\n";
871  ss << " }\n";
872  ss << " if (flag){\n";
873  for(int i = 0; i < dataCol; ++i){
874  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
875  ss << " value=tmp"<<i<<";\n";
876  ss << " }\n";
877  }
878  ss << " var+=pow(mean-value,2);\n";
879  ss << " }\n";
880  ss << " }\n";
881 
882  ss << " var = sqrt( var/count );\n";
883  }
884  else
885  ss << "var = -1;\n";
886  }
887  else
888  ss << "var = -1;\n";
889  ss << " return var;\n";
890  ss << "}";
891 }
892 
893 void OpDsum::GenSlidingWindowFunction(std::stringstream &ss,
894  const std::string &sSymName, SubArguments &vSubArguments)
895 {
896  ss << "\ndouble " << sSymName;
897  ss << "_"<< BinFuncName() <<"(";
898  for (size_t i = 0; i < vSubArguments.size(); i++)
899  {
900  if (i)
901  ss << ",";
902  vSubArguments[i]->GenSlidingWindowDecl(ss);
903  }
904  ss << ")\n {\n";
905  ss << " int gid0=get_global_id(0);\n";
906  ss << " double sum = 0;\n";
907  ss << " double value =0;\n";
908  GenTmpVariables(ss,vSubArguments);
909  int dataCol = 0;
910  int dataRow = 0;
911  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
913  throw Unhandled(__FILE__, __LINE__);
914 
915  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
916  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
918  dataCol = pCurDVR->GetArrays().size();
919  dataRow = pCurDVR->GetArrayLength();
920 
921  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
923  throw Unhandled(__FILE__, __LINE__);
924 
925  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
926  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
927  GetFormulaToken());
928  ss << " tmp"<<dataCol<<"=";
929  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
930  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
931  ss << "tmp"<<dataCol<<"))\n";
932  ss << " tmp"<<dataCol<<"=0;\n";
933 
934  int conditionCol = 0;
935  int conditionRow = 0;
936  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
938  {
939  throw Unhandled(__FILE__, __LINE__);
940  }
941  tmpCur = vSubArguments[dataCol + 1]->
942  GetFormulaToken();
943  pCurDVR= static_cast<const
945  conditionCol = pCurDVR->GetArrays().size();
946  conditionRow = pCurDVR->GetArrayLength();
947 
948  if(dataCol!=conditionCol)
949  throw Unhandled(__FILE__, __LINE__);
950  if(dataCol > 0 && dataRow > 0)
951  {
952  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
953  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
954  GetFormulaToken();
955  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
956  formula::DoubleVectorRefToken *>(tmpCur1);
957  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
958  formula::DoubleVectorRefToken *>(tmpCur2);
959 
960  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
961  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
962  {
963  ss << " int i,j,p;\n";
964  ss << " bool flag;\n";
965 
966  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
967  ss << " {\n";
968  ss << " i = p;\n";
969  for(int i = 0; i < dataCol; ++i){
970  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
972  throw Unhandled(__FILE__, __LINE__);
973  ss << " tmp"<<i<<"=";
974  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
975  ss << " if(isnan(tmp"<<i<<"))\n";
976  ss <<" tmp"<<i<<" = 0;\n";
977  }
978  ss << " flag = false;\n";
979  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
980  ss << " {\n";
981  ss << " i = j;\n";
982  ss << " if (flag)\n";
983  ss << " break;\n";
984  ss << " else{\n";
985  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
986  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
988  throw Unhandled(__FILE__, __LINE__);
989  ss << " tmp"<<i<<"=";
990  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
991  ss << " if(!isnan(tmp"<<i<<")){\n";
992  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
993  ss << i<<"){\n";
994  ss << " continue;\n";
995  ss << " }\n";
996  ss << " }\n";
997  }
998  ss << " flag=true;\n";
999  ss << " }\n";
1000  ss << " }\n";
1001  ss << " if (flag){\n";
1002  for(int i = 0; i < dataCol; ++i){
1003  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
1004  ss << " value=tmp"<<i<<";\n";
1005  ss << " }\n";
1006  }
1007  ss << " sum+=value;\n";
1008  ss << " }\n";
1009  ss << " }\n";
1010  }
1011  else
1012  ss << "sum = -1;\n";
1013  }
1014  else
1015  ss << "sum = -1;\n";
1016  ss << " return sum;\n";
1017  ss << "}";
1018 }
1019 
1020 void OpDvar::GenSlidingWindowFunction(std::stringstream &ss,
1021  const std::string &sSymName, SubArguments &vSubArguments)
1022 {
1023  ss << "\ndouble " << sSymName;
1024  ss << "_"<< BinFuncName() <<"(";
1025  for (size_t i = 0; i < vSubArguments.size(); i++)
1026  {
1027  if (i)
1028  ss << ",";
1029  vSubArguments[i]->GenSlidingWindowDecl(ss);
1030  }
1031  ss << ")\n {\n";
1032  ss << " int gid0=get_global_id(0);\n";
1033  ss << " double var = 0;\n";
1034  ss << " double mean = 0;\n";
1035  ss << " double value =0;\n";
1036  ss << " int count = 0;\n";
1037  GenTmpVariables(ss,vSubArguments);
1038  int dataCol = 0;
1039  int dataRow = 0;
1040  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
1042  throw Unhandled(__FILE__, __LINE__);
1043 
1044  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
1045  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
1046  formula::DoubleVectorRefToken *>(tmpCur);
1047  dataCol = pCurDVR->GetArrays().size();
1048  dataRow = pCurDVR->GetArrayLength();
1049 
1050  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
1052  throw Unhandled(__FILE__, __LINE__);
1053 
1054  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
1055  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
1056  GetFormulaToken());
1057  ss << " tmp"<<dataCol<<"=";
1058  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
1059  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
1060  ss << "tmp"<<dataCol<<"))\n";
1061  ss << " tmp"<<dataCol<<"=0;\n";
1062 
1063  int conditionCol = 0;
1064  int conditionRow = 0;
1065  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
1067  {
1068  throw Unhandled(__FILE__, __LINE__);
1069  }
1070  tmpCur = vSubArguments[dataCol + 1]->
1071  GetFormulaToken();
1072  pCurDVR= static_cast<const
1073  formula::DoubleVectorRefToken *>(tmpCur);
1074  conditionCol = pCurDVR->GetArrays().size();
1075  conditionRow = pCurDVR->GetArrayLength();
1076 
1077  if(dataCol!=conditionCol)
1078  throw Unhandled(__FILE__, __LINE__);
1079  if(dataCol > 0 && dataRow > 0)
1080  {
1081  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
1082  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
1083  GetFormulaToken();
1084  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
1085  formula::DoubleVectorRefToken *>(tmpCur1);
1086  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
1087  formula::DoubleVectorRefToken *>(tmpCur2);
1088 
1089  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
1090  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
1091  {
1092  ss << " int i,j,p;\n";
1093  ss << " bool flag;\n";
1094 
1095  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
1096  ss << " {\n";
1097  ss << " i = p;\n";
1098  for(int i = 0; i < dataCol; ++i){
1099  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1101  throw Unhandled(__FILE__, __LINE__);
1102  ss << " tmp"<<i<<"=";
1103  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1104  ss << " if(isnan(tmp"<<i<<"))\n";
1105  ss <<" tmp"<<i<<" = 0;\n";
1106  }
1107  ss << " flag = false;\n";
1108  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
1109  ss << " {\n";
1110  ss << " i = j;\n";
1111  ss << " if (flag)\n";
1112  ss << " break;\n";
1113  ss << " else{\n";
1114  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
1115  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1117  throw Unhandled(__FILE__, __LINE__);
1118  ss << " tmp"<<i<<"=";
1119  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1120  ss << " if(!isnan(tmp"<<i<<")){\n";
1121  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
1122  ss << i<<"){\n";
1123  ss << " continue;\n";
1124  ss << " }\n";
1125  ss << " }\n";
1126  }
1127  ss << " flag=true;\n";
1128  ss << " }\n";
1129  ss << " }\n";
1130  ss << " if (flag){\n";
1131  ss << " count++;\n";
1132  for(int i = 0; i < dataCol; ++i){
1133  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
1134  ss << " value=tmp"<<i<<";\n";
1135  ss << " }\n";
1136  }
1137  ss << " mean+=value;\n";
1138  ss << " }\n";
1139  ss << " }\n";
1140 
1141  ss << " if(count<=1)\n";
1142  ss << " return 0;\n";
1143 
1144  ss << " mean/=count;\n";
1145 
1146  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
1147  ss << " {\n";
1148  ss << " i = p;\n";
1149  for(int i = 0; i < dataCol; ++i){
1150  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1152  throw Unhandled(__FILE__, __LINE__);
1153  ss << " tmp"<<i<<"=";
1154  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1155  ss << " if(isnan(tmp"<<i<<"))\n";
1156  ss <<" tmp"<<i<<" = 0;\n";
1157  }
1158  ss << " flag = false;\n";
1159  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
1160  ss << " {\n";
1161  ss << " i = j;\n";
1162  ss << " if (flag)\n";
1163  ss << " break;\n";
1164  ss << " else{\n";
1165  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
1166  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1168  throw Unhandled(__FILE__, __LINE__);
1169  ss << " tmp"<<i<<"=";
1170  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1171  ss << " if(!isnan(tmp"<<i<<")){\n";
1172  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
1173  ss << i<<"){\n";
1174  ss << " continue;\n";
1175  ss << " }\n";
1176  ss << " }\n";
1177  }
1178  ss << " flag=true;\n";
1179  ss << " }\n";
1180  ss << " }\n";
1181  ss << " if (flag){\n";
1182  for(int i = 0; i < dataCol; ++i){
1183  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
1184  ss << " value=tmp"<<i<<";\n";
1185  ss << " }\n";
1186  }
1187  ss << " var+=pow(mean-value,2);\n";
1188  ss << " }\n";
1189  ss << " }\n";
1190 
1191  ss << " var = var/(count-1);\n";
1192  }
1193  else
1194  ss << "var = -1;\n";
1195  }
1196  else
1197  ss << "var = -1;\n";
1198  ss << " return var;\n";
1199  ss << "}";
1200 }
1201 
1202 void OpDvarp::GenSlidingWindowFunction(std::stringstream &ss,
1203  const std::string &sSymName, SubArguments &vSubArguments)
1204 {
1205  ss << "\ndouble " << sSymName;
1206  ss << "_"<< BinFuncName() <<"(";
1207  for (size_t i = 0; i < vSubArguments.size(); i++)
1208  {
1209  if (i)
1210  ss << ",";
1211  vSubArguments[i]->GenSlidingWindowDecl(ss);
1212  }
1213  ss << ")\n {\n";
1214  ss << " int gid0=get_global_id(0);\n";
1215  ss << " double var = 0;\n";
1216  ss << " double mean = 0;\n";
1217  ss << " double value =0;\n";
1218  ss << " int count = 0;\n";
1219  GenTmpVariables(ss,vSubArguments);
1220  int dataCol = 0;
1221  int dataRow = 0;
1222  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
1224  throw Unhandled(__FILE__, __LINE__);
1225 
1226  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
1227  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
1228  formula::DoubleVectorRefToken *>(tmpCur);
1229  dataCol = pCurDVR->GetArrays().size();
1230  dataRow = pCurDVR->GetArrayLength();
1231 
1232  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
1234  throw Unhandled(__FILE__, __LINE__);
1235 
1236  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
1237  formula::SingleVectorRefToken *>(vSubArguments[dataCol]->
1238  GetFormulaToken());
1239  ss << " tmp"<<dataCol<<"=";
1240  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
1241  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
1242  ss << "tmp"<<dataCol<<"))\n";
1243  ss << " tmp"<<dataCol<<"=0;\n";
1244 
1245  int conditionCol = 0;
1246  int conditionRow = 0;
1247  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
1249  {
1250  throw Unhandled(__FILE__, __LINE__);
1251  }
1252  tmpCur = vSubArguments[dataCol + 1]->
1253  GetFormulaToken();
1254  pCurDVR= static_cast<const
1255  formula::DoubleVectorRefToken *>(tmpCur);
1256  conditionCol = pCurDVR->GetArrays().size();
1257  conditionRow = pCurDVR->GetArrayLength();
1258 
1259  if(dataCol!=conditionCol)
1260  throw Unhandled(__FILE__, __LINE__);
1261  if(dataCol > 0 && dataRow > 0)
1262  {
1263  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
1264  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
1265  GetFormulaToken();
1266  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
1267  formula::DoubleVectorRefToken *>(tmpCur1);
1268  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
1269  formula::DoubleVectorRefToken *>(tmpCur2);
1270 
1271  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
1272  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
1273  {
1274  ss << " int i,j,p;\n";
1275  ss << " bool flag;\n";
1276 
1277  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
1278  ss << " {\n";
1279  ss << " i = p;\n";
1280  for(int i = 0; i < dataCol; ++i){
1281  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1283  throw Unhandled(__FILE__, __LINE__);
1284  ss << " tmp"<<i<<"=";
1285  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1286  ss << " if(isnan(tmp"<<i<<"))\n";
1287  ss <<" tmp"<<i<<" = 0;\n";
1288  }
1289  ss << " flag = false;\n";
1290  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
1291  ss << " {\n";
1292  ss << " i = j;\n";
1293  ss << " if (flag)\n";
1294  ss << " break;\n";
1295  ss << " else{\n";
1296  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
1297  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1299  throw Unhandled(__FILE__, __LINE__);
1300  ss << " tmp"<<i<<"=";
1301  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1302  ss << " if(!isnan(tmp"<<i<<")){\n";
1303  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
1304  ss << i<<"){\n";
1305  ss << " continue;\n";
1306  ss << " }\n";
1307  ss << " }\n";
1308  }
1309  ss << " flag=true;\n";
1310  ss << " }\n";
1311  ss << " }\n";
1312  ss << " if (flag){\n";
1313  ss << " count++;\n";
1314  for(int i = 0; i < dataCol; ++i){
1315  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
1316  ss << " value=tmp"<<i<<";\n";
1317  ss << " }\n";
1318  }
1319  ss << " mean+=value;\n";
1320  ss << " }\n";
1321  ss << " }\n";
1322 
1323  ss << " if(count<=0)\n";
1324  ss << " return 0;\n";
1325 
1326  ss << " mean/=count;\n";
1327 
1328  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
1329  ss << " {\n";
1330  ss << " i = p;\n";
1331  for(int i = 0; i < dataCol; ++i){
1332  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1334  throw Unhandled(__FILE__, __LINE__);
1335  ss << " tmp"<<i<<"=";
1336  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1337  ss << " if(isnan(tmp"<<i<<"))\n";
1338  ss <<" tmp"<<i<<" = 0;\n";
1339  }
1340  ss << " flag = false;\n";
1341  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
1342  ss << " {\n";
1343  ss << " i = j;\n";
1344  ss << " if (flag)\n";
1345  ss << " break;\n";
1346  ss << " else{\n";
1347  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
1348  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1350  throw Unhandled(__FILE__, __LINE__);
1351  ss << " tmp"<<i<<"=";
1352  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1353  ss << " if(!isnan(tmp"<<i<<")){\n";
1354  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
1355  ss << i<<"){\n";
1356  ss << " continue;\n";
1357  ss << " }\n";
1358  ss << " }\n";
1359  }
1360  ss << " flag=true;\n";
1361  ss << " }\n";
1362  ss << " }\n";
1363  ss << " if (flag){\n";
1364  for(int i = 0; i < dataCol; ++i){
1365  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
1366  ss << " value=tmp"<<i<<";\n";
1367  ss << " }\n";
1368  }
1369  ss << " var+=pow(mean-value,2);\n";
1370  ss << " }\n";
1371  ss << " }\n";
1372 
1373  ss << " var = var/count;\n";
1374  }
1375  else
1376  ss << "var = -1;\n";
1377  }
1378  else
1379  ss << "var = -1;\n";
1380  ss << " return var;\n";
1381  ss << "}";
1382 }
1383 
1384 void OpDcount::GenSlidingWindowFunction(std::stringstream &ss,
1385  const std::string &sSymName, SubArguments &vSubArguments)
1386 {
1387  ss << "\ndouble " << sSymName;
1388  ss << "_"<< BinFuncName() <<"(";
1389  for (size_t i = 0; i < vSubArguments.size(); i++)
1390  {
1391  if (i)
1392  ss << ",";
1393  vSubArguments[i]->GenSlidingWindowDecl(ss);
1394  }
1395  ss << ")\n {\n";
1396  ss << " int gid0=get_global_id(0);\n";
1397  ss << " double value=0;\n";
1398  ss << " int count = 0;\n";
1399  GenTmpVariables(ss,vSubArguments);
1400  int dataCol = 0;
1401  int dataRow = 0;
1402  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
1404  throw Unhandled(__FILE__, __LINE__);
1405 
1406  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
1407  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
1408  formula::DoubleVectorRefToken *>(tmpCur);
1409  dataCol = pCurDVR->GetArrays().size();
1410  dataRow = pCurDVR->GetArrayLength();
1411 
1412  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
1414  throw Unhandled(__FILE__, __LINE__);
1415 
1416  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
1417  formula::SingleVectorRefToken *>(vSubArguments[dataCol]
1418  ->GetFormulaToken());
1419  ss << " tmp"<<dataCol<<"=";
1420  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
1421  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
1422  ss << "tmp"<<dataCol<<"))\n";
1423  ss << " tmp"<<dataCol<<"=DBL_MIN;\n";
1424 
1425  int conditionCol = 0;
1426  int conditionRow = 0;
1427  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
1429  {
1430  throw Unhandled(__FILE__, __LINE__);
1431  }
1432  tmpCur = vSubArguments[dataCol + 1]
1433  ->GetFormulaToken();
1434  pCurDVR= static_cast<const
1435  formula::DoubleVectorRefToken *>(tmpCur);
1436  conditionCol = pCurDVR->GetArrays().size();
1437  conditionRow = pCurDVR->GetArrayLength();
1438 
1439  if(dataCol!=conditionCol)
1440  throw Unhandled(__FILE__, __LINE__);
1441  if(dataCol > 0 && dataRow > 0)
1442  {
1443  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
1444  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]
1445  ->GetFormulaToken();
1446  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
1447  formula::DoubleVectorRefToken *>(tmpCur1);
1448  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
1449  formula::DoubleVectorRefToken *>(tmpCur2);
1450 
1451  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
1452  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
1453  {
1454  ss << " int i,j,p;\n";
1455  ss << " bool flag;\n";
1456 
1457  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
1458  ss << " {\n";
1459  ss << " i = p;\n";
1460  for(int i = 0; i < dataCol; ++i){
1461  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1463  throw Unhandled(__FILE__, __LINE__);
1464  ss << " tmp"<<i<<"=";
1465  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1466  ss << " if(isnan(tmp"<<i<<"))\n";
1467  ss <<" tmp"<<i<<" = 0;\n";
1468  }
1469  ss << " flag = false;\n";
1470  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
1471  ss << " {\n";
1472  ss << " i = j;\n";
1473  ss << " if (flag)\n";
1474  ss << " break;\n";
1475  ss << " else{\n";
1476  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
1477  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1479  throw Unhandled(__FILE__, __LINE__);
1480  ss << " tmp"<<i<<"=";
1481  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1482  ss << " if(!isnan(tmp"<<i<<")){\n";
1483  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
1484  ss << i<<"){\n";
1485  ss << " continue;\n";
1486  ss << " }\n";
1487  ss << " }\n";
1488  }
1489  ss << " flag=true;\n";
1490  ss << " }\n";
1491  ss << " }\n";
1492  ss << " if (flag){\n";
1493  for(int i = 0; i < dataCol; ++i){
1494  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
1495  ss << " value=tmp"<<i<<";\n";
1496  ss << " }\n";
1497  }
1498  ss << " if(value > DBL_MIN)\n";
1499  ss << " count++;\n";
1500  ss << " }\n";
1501  ss << " }\n";
1502  }
1503  else
1504  ss << "count = -1;\n";
1505  }
1506  else
1507  ss << "count = -1;\n";
1508  ss << " return count;\n";
1509  ss << "}";
1510 }
1511 
1512 void OpDcount2::GenSlidingWindowFunction(std::stringstream &ss,
1513  const std::string &sSymName, SubArguments &vSubArguments)
1514 {
1515  ss << "\ndouble " << sSymName;
1516  ss << "_"<< BinFuncName() <<"(";
1517  for (size_t i = 0; i < vSubArguments.size(); i++)
1518  {
1519  if (i)
1520  ss << ",";
1521  vSubArguments[i]->GenSlidingWindowDecl(ss);
1522  }
1523  ss << ")\n {\n";
1524  ss << " int gid0=get_global_id(0);\n";
1525  ss << " double value=0;\n";
1526  ss << " int count = 0;\n";
1527  GenTmpVariables(ss,vSubArguments);
1528  int dataCol = 0;
1529  int dataRow = 0;
1530  if(vSubArguments[0]->GetFormulaToken()->GetType() !=
1532  throw Unhandled(__FILE__, __LINE__);
1533 
1534  formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
1535  const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
1536  formula::DoubleVectorRefToken *>(tmpCur);
1537  dataCol = pCurDVR->GetArrays().size();
1538  dataRow = pCurDVR->GetArrayLength();
1539 
1540  if(vSubArguments[dataCol]->GetFormulaToken()->GetType() !=
1542  throw Unhandled(__FILE__, __LINE__);
1543 
1544  const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const
1545  formula::SingleVectorRefToken *>(vSubArguments[dataCol]
1546  ->GetFormulaToken());
1547  ss << " tmp"<<dataCol<<"=";
1548  ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n";
1549  ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan(";
1550  ss << "tmp"<<dataCol<<"))\n";
1551  ss << " tmp"<<dataCol<<"=DBL_MIN;\n";
1552 
1553  int conditionCol = 0;
1554  int conditionRow = 0;
1555  if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() !=
1557  {
1558  throw Unhandled(__FILE__, __LINE__);
1559  }
1560  tmpCur = vSubArguments[dataCol + 1]->
1561  GetFormulaToken();
1562  pCurDVR= static_cast<const
1563  formula::DoubleVectorRefToken *>(tmpCur);
1564  conditionCol = pCurDVR->GetArrays().size();
1565  conditionRow = pCurDVR->GetArrayLength();
1566 
1567  if(dataCol!=conditionCol)
1568  throw Unhandled(__FILE__, __LINE__);
1569  if(dataCol > 0 && dataRow > 0)
1570  {
1571  formula::FormulaToken *tmpCur1 = vSubArguments[0]->GetFormulaToken();
1572  formula::FormulaToken *tmpCur2 = vSubArguments[dataCol + 1]->
1573  GetFormulaToken();
1574  const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const
1575  formula::DoubleVectorRefToken *>(tmpCur1);
1576  const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
1577  formula::DoubleVectorRefToken *>(tmpCur2);
1578 
1579  if(pCurDVR1->IsStartFixed() && pCurDVR1->IsEndFixed() &&
1580  pCurDVR2->IsStartFixed() && pCurDVR2->IsEndFixed())
1581  {
1582  ss << " int i,j,p;\n";
1583  ss << " bool flag;\n";
1584 
1585  ss << " for(p = 1;p < " << dataRow << ";++p)\n";
1586  ss << " {\n";
1587  ss << " i = p;\n";
1588  for(int i = 0; i < dataCol; ++i){
1589  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1591  throw Unhandled(__FILE__, __LINE__);
1592  ss << " tmp"<<i<<"=";
1593  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1594  ss << " if(isnan(tmp"<<i<<"))\n";
1595  ss <<" tmp"<<i<<" = 0;\n";
1596  }
1597  ss << " flag = false;\n";
1598  ss << " for(j = 1; j < " << conditionRow << ";++j)\n";
1599  ss << " {\n";
1600  ss << " i = j;\n";
1601  ss << " if (flag)\n";
1602  ss << " break;\n";
1603  ss << " else{\n";
1604  for(int i = dataCol + 1; i < dataCol + 1 + conditionCol; ++i){
1605  if(vSubArguments[i]->GetFormulaToken()->GetType() !=
1607  throw Unhandled(__FILE__, __LINE__);
1608  ss << " tmp"<<i<<"=";
1609  ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
1610  ss << " if(!isnan(tmp"<<i<<")){\n";
1611  ss << " if(tmp"<<(i-dataCol-1)<<"!=tmp";
1612  ss << i<<"){\n";
1613  ss << " continue;\n";
1614  ss << " }\n";
1615  ss << " }\n";
1616  }
1617  ss << " flag=true;\n";
1618  ss << " }\n";
1619  ss << " }\n";
1620  ss << " if (flag){\n";
1621  for(int i = 0; i < dataCol; ++i){
1622  ss << " if(tmp"<<dataCol<<"=="<<(i+1)<<"){\n";
1623  ss << " value=tmp"<<i<<";\n";
1624  ss << " }\n";
1625  }
1626  ss << " if(value > DBL_MIN)\n";
1627  ss << " count++;\n";
1628  ss << " }\n";
1629  ss << " }\n";
1630  }
1631  else
1632  ss << "count = -1;\n";
1633  }
1634  else
1635  ss << "count = -1;\n";
1636  ss << " return count;\n";
1637  ss << "}";
1638 }
1639 
1640 }
1641 
1642 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Inconsistent state.
Definition: opbase.hxx:54
virtual std::string BinFuncName() const override
Definition: op_database.hxx:30
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
const std::vector< VectorRefArray > & GetArrays() const
virtual std::string BinFuncName() const override
Definition: op_database.hxx:70
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string BinFuncName() const override
Definition: op_database.hxx:86
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
static void GenTmpVariables(std::stringstream &ss, const SubArguments &vSubArguments)
Definition: opbase.cxx:199
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string BinFuncName() const override
Definition: op_database.hxx:38
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string BinFuncName() const override
Definition: op_database.hxx:46
int i
virtual std::string BinFuncName() const override
Definition: op_database.hxx:78
std::vector< DynamicKernelArgumentRef > SubArguments
Definition: opbase.hxx:215
Arguments that are actually compile-time constant string Currently, only the hash is passed...
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string BinFuncName() const override
Definition: op_database.hxx:94
virtual std::string BinFuncName() const override
Definition: op_database.hxx:62
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
size_t GetArrayLength() const
size_t GetArrayLength() const
virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
Definition: op_database.cxx:17
virtual std::string BinFuncName() const override
virtual std::string BinFuncName() const override
Definition: op_database.hxx:22
virtual std::string BinFuncName() const override
Definition: op_database.hxx:54