LibreOffice Module sc (master)  1
matrixoperators.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 <matrixoperators.hxx>
11 
12 namespace sc::op
13 {
14 /* Simple operators */
15 
16 void Sum::operator()(KahanSum& rAccum, double fVal) const { rAccum += fVal; }
17 
18 const double Sum::InitVal = 0.0;
19 
20 void SumSquare::operator()(KahanSum& rAccum, double fVal) const { rAccum += fVal * fVal; }
21 
22 const double SumSquare::InitVal = 0.0;
23 
24 void Product::operator()(double& rAccum, double fVal) const { rAccum *= fVal; }
25 
26 const double Product::InitVal = 1.0;
27 
28 /* Op operators */
29 
30 void fkOpSum(KahanSum& rAccum, double fVal) { rAccum += fVal; }
31 
32 kOp kOpSum(0.0, fkOpSum);
33 
34 void fkOpSumSquare(KahanSum& rAccum, double fVal) { rAccum += fVal * fVal; }
35 
37 
38 std::vector<kOp> kOpSumAndSumSquare = { kOpSum, kOpSumSquare };
39 }
40 
41 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static const double InitVal
std::vector< kOp > kOpSumAndSumSquare
kOp kOpSum(0.0, fkOpSum)
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)
void operator()(KahanSum &rAccum, double fVal) const
static const double InitVal
Op_< std::function< void(KahanSum &, double)>, KahanSum > kOp