1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 namespace sc::opencl
{
17 class OpStandard
: public Normal
20 virtual void GenSlidingWindowFunction(outputstream
&ss
,
21 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
22 virtual std::string
BinFuncName() const override
{ return "Standard"; }
24 class OpExponDist
: public Normal
27 virtual void GenSlidingWindowFunction(outputstream
&ss
,
28 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
29 virtual std::string
BinFuncName() const override
{ return "ExponDist"; }
31 class OpZTest
: public Normal
34 virtual void GenSlidingWindowFunction(outputstream
&ss
,
35 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
36 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
37 virtual std::string
BinFuncName() const override
{ return "ZTest"; }
39 class OpWeibull
: public Normal
42 virtual void GenSlidingWindowFunction(outputstream
&ss
,
43 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
44 virtual std::string
BinFuncName() const override
{ return "Weibull"; }
46 class OpFdist
: public Normal
49 virtual void GenSlidingWindowFunction(outputstream
&ss
,
50 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
51 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
52 virtual std::string
BinFuncName() const override
{ return "Fdist"; }
54 class OpTDist
: public Normal
57 virtual void GenSlidingWindowFunction(outputstream
&ss
,
58 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
59 virtual std::string
BinFuncName() const override
{ return "TDist"; }
60 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
62 class OpTInv
: public Normal
65 virtual void GenSlidingWindowFunction(outputstream
&ss
,
66 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
67 virtual std::string
BinFuncName() const override
{ return "TInv"; }
68 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
70 class OpTTest
: public Normal
73 virtual void GenSlidingWindowFunction(outputstream
&ss
,
74 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
75 virtual std::string
BinFuncName() const override
{ return "TTest"; }
76 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
78 class OpFisher
: public Normal
81 virtual void GenSlidingWindowFunction(outputstream
&ss
,
82 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
83 virtual std::string
BinFuncName() const override
{ return "Fisher"; }
86 class OpFisherInv
: public Normal
89 virtual void GenSlidingWindowFunction(outputstream
&ss
,
90 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
91 virtual std::string
BinFuncName() const override
{ return "FisherInv"; }
94 class OpGamma
: public Normal
97 virtual void GenSlidingWindowFunction(outputstream
&ss
,
98 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
99 virtual std::string
BinFuncName() const override
{ return "Gamma"; }
102 class OpNegbinomdist
: public Normal
105 virtual void GenSlidingWindowFunction(outputstream
&ss
,
106 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
107 virtual std::string
BinFuncName() const override
{ return "OpNegbinomdist"; }
110 class OpGammaLn
: public Normal
113 virtual void GenSlidingWindowFunction(outputstream
&ss
,
114 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
115 virtual std::string
BinFuncName() const override
{ return "GammaLn"; }
118 class OpGauss
: public Normal
121 virtual void GenSlidingWindowFunction(outputstream
&ss
,
122 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
123 virtual void BinInlineFun(std::set
<std::string
>& ,
124 std::set
<std::string
>& ) override
;
125 virtual std::string
BinFuncName() const override
{ return "Gauss"; }
128 class OpGeoMean
: public Normal
131 virtual void GenSlidingWindowFunction(outputstream
&ss
,
132 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
133 virtual std::string
BinFuncName() const override
{ return "GeoMean"; }
134 virtual bool canHandleMultiVector() const override
{ return true; }
137 class OpHarMean
: public Normal
140 virtual void GenSlidingWindowFunction(outputstream
&ss
,
141 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
142 virtual std::string
BinFuncName() const override
{ return "HarMean"; }
143 virtual bool canHandleMultiVector() const override
{ return true; }
146 class OpNormdist
:public Normal
{
148 virtual void GenSlidingWindowFunction(outputstream
&ss
,
149 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
150 virtual std::string
BinFuncName() const override
{ return "OpNormdist"; }
152 class OpNormsdist
:public Normal
{
154 virtual void GenSlidingWindowFunction(outputstream
&ss
,
155 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
156 virtual std::string
BinFuncName() const override
{ return "OpNormsdist"; }
158 class OpNorminv
:public Normal
{
160 virtual void GenSlidingWindowFunction(outputstream
&ss
,
161 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
162 virtual std::string
BinFuncName() const override
{ return "OpNorminv"; }
163 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
165 class OpNormsinv
:public Normal
{
167 virtual void GenSlidingWindowFunction(outputstream
&ss
,
168 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
169 virtual std::string
BinFuncName() const override
{ return "OpNormsinv"; }
170 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
172 class OpPhi
:public Normal
{
174 virtual void GenSlidingWindowFunction(outputstream
&ss
,
175 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
176 virtual std::string
BinFuncName() const override
{ return "OpPhi"; }
179 class OpPermut
:public Normal
{
181 virtual void GenSlidingWindowFunction(outputstream
&ss
,
182 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
183 virtual std::string
BinFuncName() const override
{ return "OpPermut"; }
185 class OpPermutationA
:public Normal
{
187 virtual void GenSlidingWindowFunction(outputstream
&ss
,
188 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
189 virtual std::string
BinFuncName() const override
{ return "OpPermutationA";}
192 class OpConfidence
: public Normal
195 virtual std::string
GetBottom() override
{ return "0"; }
197 virtual void GenSlidingWindowFunction(outputstream
& ss
,
198 const std::string
&sSymName
, SubArguments
& vSubArguments
) override
;
199 virtual void BinInlineFun(std::set
<std::string
>& ,
200 std::set
<std::string
>& ) override
;
202 virtual std::string
BinFuncName() const override
{ return "Confidence"; }
204 class OpLogInv
: public Normal
207 virtual void GenSlidingWindowFunction(outputstream
&ss
,
208 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
209 virtual std::string
BinFuncName() const override
{ return "LogInv"; }
210 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
212 class OpCritBinom
: public Normal
215 virtual std::string
GetBottom() override
{ return "0"; }
217 virtual void GenSlidingWindowFunction(outputstream
& ss
,
218 const std::string
&sSymName
, SubArguments
& vSubArguments
) override
;
219 virtual void BinInlineFun(std::set
<std::string
>& ,
220 std::set
<std::string
>& ) override
;
222 virtual std::string
BinFuncName() const override
{ return "CritBinom"; }
224 class OpLogNormDist
: public Normal
227 virtual void GenSlidingWindowFunction(outputstream
&ss
,
228 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
229 virtual std::string
BinFuncName() const override
{ return "LogNormdist"; }
231 class OpGammaDist
: public Normal
234 virtual void GenSlidingWindowFunction(outputstream
&ss
,
235 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
236 void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
) override
;
237 virtual std::string
BinFuncName() const override
{ return "GammaDist"; }
239 class OpHypGeomDist
:public Normal
{
241 virtual void GenSlidingWindowFunction(outputstream
&ss
,
242 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
243 virtual std::string
BinFuncName() const override
{ return "OpHypGeomDist"; }
245 class OpChiDist
:public Normal
{
247 virtual void GenSlidingWindowFunction(outputstream
&ss
,
248 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
249 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
250 virtual std::string
BinFuncName() const override
{ return "OpChiDist"; }
252 class OpBinomdist
:public Normal
{
254 virtual void GenSlidingWindowFunction(outputstream
&ss
,
255 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
256 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
257 virtual std::string
BinFuncName() const override
{ return "OpBinomdist"; }
259 class OpChiSqDist
: public CheckVariables
262 virtual void GenSlidingWindowFunction(outputstream
&ss
,
263 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
264 virtual std::string
BinFuncName() const override
{ return "ChiSqDist"; }
265 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>& ) override
;
268 class OpChiSqInv
: public CheckVariables
271 virtual void GenSlidingWindowFunction(outputstream
&ss
,
272 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
273 virtual std::string
BinFuncName() const override
{ return "ChiSqInv"; }
274 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>& ) override
;
276 class OpChiInv
:public Normal
{
278 virtual void GenSlidingWindowFunction(outputstream
&ss
,
279 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
280 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
281 virtual std::string
BinFuncName() const override
{ return "OpChiInv"; }
283 class OpPoisson
:public Normal
{
285 virtual void GenSlidingWindowFunction(outputstream
&ss
,
286 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
287 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
288 virtual std::string
BinFuncName() const override
{ return "OpPoisson"; }
291 class OpGammaInv
: public Normal
294 virtual void GenSlidingWindowFunction(outputstream
&ss
,
295 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
296 void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
298 virtual std::string
BinFuncName() const override
{ return "GammaInv"; }
300 class OpFInv
: public Normal
303 virtual void GenSlidingWindowFunction(outputstream
&ss
,
304 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
305 void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
307 virtual std::string
BinFuncName() const override
{ return "FInv"; }
309 class OpFTest
: public Normal
312 virtual void GenSlidingWindowFunction(outputstream
&ss
,
313 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
314 void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
316 virtual std::string
BinFuncName() const override
{ return "FTest"; }
318 class OpDevSq
: public Normal
321 virtual void GenSlidingWindowFunction(outputstream
&ss
,
322 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
323 virtual std::string
BinFuncName() const override
{ return "DevSq"; }
324 virtual bool canHandleMultiVector() const override
{ return true; }
326 class OpB
: public Normal
329 virtual void GenSlidingWindowFunction(outputstream
&ss
,
330 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
331 void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
333 virtual std::string
BinFuncName() const override
{ return "B"; }
335 class OpBetaDist
: public Normal
338 virtual void GenSlidingWindowFunction(outputstream
&ss
,
339 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
340 void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
342 virtual std::string
BinFuncName() const override
{ return "BetaDist"; }
344 class OpBetainv
:public Normal
{
346 virtual void GenSlidingWindowFunction(outputstream
&ss
,
347 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
348 virtual void BinInlineFun(std::set
<std::string
>& ,std::set
<std::string
>&) override
;
349 virtual std::string
BinFuncName() const override
{ return "OpBetainv"; }
352 class OpAveDev
: public Normal
355 virtual void GenSlidingWindowFunction(outputstream
&ss
,
356 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
357 virtual std::string
BinFuncName() const override
{ return "AveDev"; }
358 virtual bool canHandleMultiVector() const override
{ return true; }
361 class OpCovar
: public Normal
364 virtual void GenSlidingWindowFunction(outputstream
& ss
,
365 const std::string
&sSymName
, SubArguments
& vSubArguments
) override
;
366 virtual std::string
BinFuncName() const override
{ return "Covar"; }
369 class OpForecast
: public Normal
372 virtual void GenSlidingWindowFunction(outputstream
&ss
,
373 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
374 virtual std::string
BinFuncName() const override
{ return "Forecast"; }
377 class OpInterceptSlopeBase
: public Normal
380 virtual void GenSlidingWindowFunction(outputstream
&ss
,
381 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
= 0;
383 void GenerateCode( outputstream
& ss
, const std::string
&sSymName
,
384 SubArguments
&vSubArguments
, const char* finalComputeCode
);
387 class OpIntercept
: public OpInterceptSlopeBase
390 virtual void GenSlidingWindowFunction(outputstream
&ss
,
391 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
392 virtual std::string
BinFuncName() const override
{ return "Intercept"; }
395 class OpSlope
: public OpInterceptSlopeBase
398 virtual void GenSlidingWindowFunction(outputstream
&ss
,
399 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
400 virtual std::string
BinFuncName() const override
{ return "Slope"; }
403 class OpPearsonCovarBase
: public Normal
406 virtual void GenSlidingWindowFunction(outputstream
&ss
,
407 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
= 0;
409 void GenerateCode( outputstream
& ss
, const std::string
&sSymName
,
410 SubArguments
&vSubArguments
, double minimalCountValue
, const char* finalComputeCode
);
413 class OpPearson
: public OpPearsonCovarBase
416 virtual void GenSlidingWindowFunction(outputstream
&ss
,
417 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
418 virtual std::string
BinFuncName() const override
{ return "OpPearson"; }
421 class OpCorrel
: public OpPearson
// they are identical
424 virtual std::string
BinFuncName() const override
{ return "Correl"; }
427 class OpSTEYX
: public OpPearsonCovarBase
430 virtual void GenSlidingWindowFunction(outputstream
&ss
,
431 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
432 virtual std::string
BinFuncName() const override
{ return "STEYX"; }
435 class OpRsq
: public OpPearsonCovarBase
438 virtual void GenSlidingWindowFunction(outputstream
&ss
,
439 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
440 virtual std::string
BinFuncName() const override
{ return "OpRsq"; }
443 class OpVarStDevBase
: public Normal
446 virtual void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
) override
;
447 virtual bool canHandleMultiVector() const override
{ return true; }
449 // Generates function setup and checks, then generates a loop that will calculate
450 // fMean and fCount from all arguments (ranges) and then a second loop that will
451 // calculate vSum (pown(fsub_approx(arg,fMean),2)) from all arguments.
452 void GenerateCode( outputstream
& ss
, const std::string
& sSymName
, SubArguments
&vSubArguments
);
455 class OpVar
: public OpVarStDevBase
458 virtual void GenSlidingWindowFunction(outputstream
&ss
,
459 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
460 virtual std::string
BinFuncName() const override
{ return "Var"; }
463 class OpVarP
: public OpVarStDevBase
466 virtual void GenSlidingWindowFunction(outputstream
&ss
,
467 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
468 virtual std::string
BinFuncName() const override
{ return "VarP"; }
471 class OpStDev
: public OpVarStDevBase
474 virtual void GenSlidingWindowFunction(outputstream
&ss
,
475 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
476 virtual std::string
BinFuncName() const override
{ return "StDev"; }
479 class OpStDevP
: public OpVarStDevBase
482 virtual void GenSlidingWindowFunction(outputstream
&ss
,
483 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
484 virtual std::string
BinFuncName() const override
{ return "StDevP"; }
487 class OpSkew
: public OpVarStDevBase
490 virtual void GenSlidingWindowFunction(outputstream
&ss
,
491 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
492 virtual std::string
BinFuncName() const override
{ return "Skew"; }
495 class OpSkewp
: public OpVarStDevBase
498 virtual void GenSlidingWindowFunction(outputstream
&ss
,
499 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
500 virtual std::string
BinFuncName() const override
{ return "Skewp"; }
503 class OpKurt
: public OpVarStDevBase
506 virtual void GenSlidingWindowFunction(outputstream
&ss
,
507 const std::string
&sSymName
, SubArguments
&vSubArguments
) override
;
508 virtual std::string
BinFuncName() const override
{ return "Kurt"; }
511 class OpMin
: public Reduction
514 explicit OpMin(int nResultSize
) : Reduction(nResultSize
) {}
516 virtual std::string
GetBottom() override
{ return "NAN"; }
517 virtual std::string
Gen2( const std::string
& lhs
, const std::string
& rhs
) const override
519 return "fmin_count(" + lhs
+ "," + rhs
+ ", &nCount)";
521 virtual void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
) override
;
522 virtual std::string
BinFuncName() const override
{ return "min"; }
523 virtual bool isMinOrMax() const override
{ return true; }
524 virtual bool canHandleMultiVector() const override
{ return true; }
527 class OpMax
: public Reduction
530 explicit OpMax(int nResultSize
) : Reduction(nResultSize
) {}
532 virtual std::string
GetBottom() override
{ return "NAN"; }
533 virtual std::string
Gen2( const std::string
& lhs
, const std::string
& rhs
) const override
535 return "fmax_count(" + lhs
+ "," + rhs
+ ", &nCount)";
537 virtual void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
) override
;
538 virtual std::string
BinFuncName() const override
{ return "max"; }
539 virtual bool isMinOrMax() const override
{ return true; }
540 virtual bool canHandleMultiVector() const override
{ return true; }
543 class OpAverage
: public Reduction
546 explicit OpAverage(int nResultSize
) : Reduction(nResultSize
) {}
548 virtual std::string
GetBottom() override
{ return "0"; }
549 virtual std::string
Gen2( const std::string
& lhs
, const std::string
& rhs
) const override
552 ss
<< "fsum_count(" << lhs
<< "," << rhs
<< ", &nCount)";
555 virtual void BinInlineFun(std::set
<std::string
>& decls
,std::set
<std::string
>& funs
) override
;
556 virtual std::string
BinFuncName() const override
{ return "average"; }
557 virtual bool isAverage() const override
{ return true; }
558 virtual bool canHandleMultiVector() const override
{ return true; }
561 class OpCount
: public Reduction
564 explicit OpCount(int nResultSize
) : Reduction(nResultSize
) {}
566 virtual std::string
GetBottom() override
{ return "0"; }
567 virtual std::string
Gen2( const std::string
& lhs
, const std::string
& rhs
) const override
570 ss
<< "(isnan(" << lhs
<< ")?" << rhs
<< ":" << rhs
<< "+1.0)";
573 virtual std::string
BinFuncName() const override
{ return "fcount"; }
574 virtual bool canHandleMultiVector() const override
{ return true; }
577 class OpCountA
: public OpCount
580 explicit OpCountA(int nResultSize
) : OpCount(nResultSize
) {}
581 virtual std::string
BinFuncName() const override
{ return "OpCountA"; }
582 virtual bool forceStringsToZero() const override
{ return true; }
584 class OpMaxA
: public OpMax
587 explicit OpMaxA(int nResultSize
) : OpMax(nResultSize
) {}
588 virtual std::string
BinFuncName() const override
{ return "OpMaxA"; }
589 virtual bool forceStringsToZero() const override
{ return true; }
591 class OpMinA
: public OpMin
594 explicit OpMinA(int nResultSize
) : OpMin(nResultSize
) {}
595 virtual std::string
BinFuncName() const override
{ return "OpMinA"; }
596 virtual bool forceStringsToZero() const override
{ return true; }
598 class OpVarA
: public OpVar
601 virtual std::string
BinFuncName() const override
{ return "OpVarA"; }
602 virtual bool forceStringsToZero() const override
{ return true; }
604 class OpVarPA
: public OpVarP
607 virtual std::string
BinFuncName() const override
{ return "OpVarPA"; }
608 virtual bool forceStringsToZero() const override
{ return true; }
610 class OpStDevPA
: public OpStDevP
613 virtual std::string
BinFuncName() const override
{ return "OpStDevPA"; }
614 virtual bool forceStringsToZero() const override
{ return true; }
616 class OpAverageA
: public OpAverage
619 explicit OpAverageA(int nResultSize
) : OpAverage(nResultSize
) {}
620 virtual std::string
BinFuncName() const override
{ return "OpAverageA"; }
621 virtual bool forceStringsToZero() const override
{ return true; }
623 class OpStDevA
: public OpStDev
626 virtual std::string
BinFuncName() const override
{ return "OpStDevA"; }
627 virtual bool forceStringsToZero() const override
{ return true; }
632 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */