Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / inc / matrixoperators.hxx
blobcd0295bb20dfd2bb24fbd3807e45c1c117e1032d
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
13 #include <functional>
14 #include <utility>
15 #include <vector>
16 #include "kahan.hxx"
18 namespace sc::op {
21 template<typename T, typename tRes>
22 struct Op_
24 const double mInitVal;
25 const T maOp;
26 Op_(double InitVal, T aOp):
27 mInitVal(InitVal), maOp(std::move(aOp))
30 void operator()(tRes& rAccum, double fVal) const
32 maOp(rAccum, fVal);
36 using Op = Op_<std::function<void(double&, double)>, double>;
37 using kOp = Op_<std::function<void(KahanSum&, double)>, KahanSum>;
39 void fkOpSum(KahanSum& rAccum, double fVal);
40 void fkOpSumSquare(KahanSum& rAccum, double fVal);
42 extern kOp kOpSum;
43 extern kOp kOpSumSquare;
44 extern std::vector<kOp> kOpSumAndSumSquare;
46 struct Sum
48 static const double InitVal;
49 void operator()(KahanSum& rAccum, double fVal) const;
52 struct SumSquare
54 static const double InitVal;
55 void operator()(KahanSum& rAccum, double fVal) const;
58 struct Product
60 static const double InitVal;
61 void operator()(double& rAccum, double fVal) const;
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */