LibreOffice Module sc (master)  1
matrixoperators.hxx
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 #pragma once
11 
12 
13 #include <functional>
14 #include <vector>
15 #include "math.hxx"
16 
17 namespace sc::op {
18 
19 
20 template<typename T, typename tRes>
21 struct Op_
22 {
23  const double mInitVal;
24  const T maOp;
25  Op_(double InitVal, T aOp):
26  mInitVal(InitVal), maOp(aOp)
27  {
28  }
29  void operator()(tRes& rAccum, double fVal) const
30  {
31  maOp(rAccum, fVal);
32  }
33 };
34 
37 
38 void fkOpSum(KahanSum& rAccum, double fVal);
39 void fkOpSumSquare(KahanSum& rAccum, double fVal);
40 
41 extern kOp kOpSum;
43 extern std::vector<kOp> kOpSumAndSumSquare;
44 
45 struct Sum
46 {
47  static const double InitVal;
48  void operator()(KahanSum& rAccum, double fVal) const;
49 };
50 
51 struct SumSquare
52 {
53  static const double InitVal;
54  void operator()(KahanSum& rAccum, double fVal) const;
55 };
56 
57 struct Product
58 {
59  static const double InitVal;
60  void operator()(double& rAccum, double fVal) const;
61 };
62 
63 }
64 
65 
66 
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static const double InitVal
std::vector< kOp > kOpSumAndSumSquare
kOp kOpSum(0.0, fkOpSum)
void operator()(tRes &rAccum, double fVal) const
void fkOpSum(KahanSum &rAccum, double fVal)
kOp kOpSumSquare(0.0, fkOpSumSquare)
static const double InitVal
This class provides LO with Kahan summation algorithm About this algorithm: https://en.wikipedia.org/wiki/Kahan_summation_algorithm For general purpose software we assume first order error is enough.
Definition: kahan.hxx:23
void operator()(double &rAccum, double fVal) const
void operator()(KahanSum &rAccum, double fVal) const
void fkOpSumSquare(KahanSum &rAccum, double fVal)
const double mInitVal
void operator()(KahanSum &rAccum, double fVal) const
static const double InitVal
Op_(double InitVal, T aOp)