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 <utility>
15#include <vector>
16#include "kahan.hxx"
17
18namespace sc::op {
19
20
21template<typename T, typename tRes>
22struct Op_
23{
24 const double mInitVal;
25 const T maOp;
26 Op_(double InitVal, T aOp):
27 mInitVal(InitVal), maOp(std::move(aOp))
28 {
29 }
30 void operator()(tRes& rAccum, double fVal) const
31 {
32 maOp(rAccum, fVal);
33 }
34};
35
36using Op = Op_<std::function<void(double&, double)>, double>;
37using kOp = Op_<std::function<void(KahanSum&, double)>, KahanSum>;
38
39void fkOpSum(KahanSum& rAccum, double fVal);
40void fkOpSumSquare(KahanSum& rAccum, double fVal);
41
42extern kOp kOpSum;
44extern std::vector<kOp> kOpSumAndSumSquare;
45
46struct Sum
47{
48 static const double InitVal;
49 void operator()(KahanSum& rAccum, double fVal) const;
50};
51
53{
54 static const double InitVal;
55 void operator()(KahanSum& rAccum, double fVal) const;
56};
57
58struct Product
59{
60 static const double InitVal;
61 void operator()(double& rAccum, double fVal) const;
62};
63
64}
65
66
67
68/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class provides LO with Kahan summation algorithm About this algorithm: https://en....
Definition: kahan.hxx:26
kOp kOpSum(0.0, fkOpSum)
kOp kOpSumSquare(0.0, fkOpSumSquare)
std::vector< kOp > kOpSumAndSumSquare
void fkOpSumSquare(KahanSum &rAccum, double fVal)
void fkOpSum(KahanSum &rAccum, double fVal)
Op_(double InitVal, T aOp)
const double mInitVal
void operator()(tRes &rAccum, double fVal) const
static const double InitVal
void operator()(double &rAccum, double fVal) const
void operator()(KahanSum &rAccum, double fVal) const
static const double InitVal
void operator()(KahanSum &rAccum, double fVal) const
static const double InitVal