/src/libreoffice/sc/inc/matrixoperators.hxx
Line | Count | Source |
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 "kahan.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 | 44 | mInitVal(InitVal), maOp(std::move(aOp)) |
27 | 44 | { |
28 | 44 | } |
29 | | void operator()(tRes& rAccum, double fVal) const |
30 | 2.14k | { |
31 | 2.14k | maOp(rAccum, fVal); |
32 | 2.14k | } |
33 | | }; |
34 | | |
35 | | using Op = Op_<std::function<void(double&, double)>, double>; |
36 | | using kOp = Op_<std::function<void(KahanSum&, double)>, KahanSum>; |
37 | | |
38 | | void fkOpSum(KahanSum& rAccum, double fVal); |
39 | | void fkOpSumSquare(KahanSum& rAccum, double fVal); |
40 | | |
41 | | extern kOp kOpSum; |
42 | | extern kOp kOpSumSquare; |
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: */ |