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