xmlsecurity: fix --without-system-nss build
[LibreOffice.git] / sc / source / core / opencl / op_statistical.hxx
blob827c6a0456afb83a2557bb21d6a46087b456749f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #pragma once
12 #include "opbase.hxx"
13 #include "utils.hxx"
15 namespace sc::opencl {
17 class OpStandard: public Normal
19 public:
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
26 public:
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
33 public:
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
41 public:
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
48 public:
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
56 public:
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
64 public:
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
72 public:
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
80 public:
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
88 public:
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
96 public:
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
104 public:
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
112 public:
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
120 public:
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
130 public:
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
139 public:
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{
147 public:
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{
153 public:
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{
159 public:
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{
166 public:
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{
173 public:
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{
180 public:
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{
186 public:
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
194 public:
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
206 public:
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
214 public:
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
226 public:
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
233 public:
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{
240 public:
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{
246 public:
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{
253 public:
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
261 public:
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
270 public:
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{
277 public:
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{
284 public:
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
293 public:
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
297 ) override;
298 virtual std::string BinFuncName() const override { return "GammaInv"; }
300 class OpFInv: public Normal
302 public:
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
306 ) override;
307 virtual std::string BinFuncName() const override { return "FInv"; }
309 class OpFTest: public Normal
311 public:
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
315 ) override;
316 virtual std::string BinFuncName() const override { return "FTest"; }
318 class OpDevSq: public Normal
320 public:
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
328 public:
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
332 ) override;
333 virtual std::string BinFuncName() const override { return "B"; }
335 class OpBetaDist: public Normal
337 public:
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
341 ) override;
342 virtual std::string BinFuncName() const override { return "BetaDist"; }
344 class OpBetainv:public Normal{
345 public:
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
354 public:
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
363 public:
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
371 public:
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
379 public:
380 virtual void GenSlidingWindowFunction(outputstream &ss,
381 const std::string &sSymName, SubArguments &vSubArguments) override = 0;
382 protected:
383 void GenerateCode( outputstream& ss, const std::string &sSymName,
384 SubArguments &vSubArguments, const char* finalComputeCode );
387 class OpIntercept: public OpInterceptSlopeBase
389 public:
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
397 public:
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
405 public:
406 virtual void GenSlidingWindowFunction(outputstream &ss,
407 const std::string &sSymName, SubArguments &vSubArguments) override = 0;
408 protected:
409 void GenerateCode( outputstream& ss, const std::string &sSymName,
410 SubArguments &vSubArguments, double minimalCountValue, const char* finalComputeCode );
413 class OpPearson: public OpPearsonCovarBase
415 public:
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
423 public:
424 virtual std::string BinFuncName() const override { return "Correl"; }
427 class OpSTEYX: public OpPearsonCovarBase
429 public:
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
437 public:
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
445 public:
446 virtual void BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs) override;
447 virtual bool canHandleMultiVector() const override { return true; }
448 protected:
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
457 public:
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
465 public:
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
473 public:
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
481 public:
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
489 public:
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
497 public:
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
505 public:
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
513 public:
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
529 public:
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
545 public:
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
551 outputstream ss;
552 ss << "fsum_count(" << lhs << "," << rhs << ", &nCount)";
553 return ss.str();
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
563 public:
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
569 outputstream ss;
570 ss << "(isnan(" << lhs << ")?" << rhs << ":" << rhs << "+1.0)";
571 return ss.str();
573 virtual std::string BinFuncName() const override { return "fcount"; }
574 virtual bool canHandleMultiVector() const override { return true; }
577 class OpCountA: public OpCount
579 public:
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
586 public:
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
593 public:
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
600 public:
601 virtual std::string BinFuncName() const override { return "OpVarA"; }
602 virtual bool forceStringsToZero() const override { return true; }
604 class OpVarPA: public OpVarP
606 public:
607 virtual std::string BinFuncName() const override { return "OpVarPA"; }
608 virtual bool forceStringsToZero() const override { return true; }
610 class OpStDevPA: public OpStDevP
612 public:
613 virtual std::string BinFuncName() const override { return "OpStDevPA"; }
614 virtual bool forceStringsToZero() const override { return true; }
616 class OpAverageA: public OpAverage
618 public:
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
625 public:
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: */