Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / source / core / tool / matrixoperators.cxx
blob9406d09255c4f7740cb894bbf3dba0f6707b7776
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 #include <matrixoperators.hxx>
12 namespace sc::op
14 /* Simple operators */
16 void Sum::operator()(KahanSum& rAccum, double fVal) const { rAccum += fVal; }
18 const double Sum::InitVal = 0.0;
20 void SumSquare::operator()(KahanSum& rAccum, double fVal) const { rAccum += fVal * fVal; }
22 const double SumSquare::InitVal = 0.0;
24 void Product::operator()(double& rAccum, double fVal) const { rAccum *= fVal; }
26 const double Product::InitVal = 1.0;
28 /* Op operators */
30 void fkOpSum(KahanSum& rAccum, double fVal) { rAccum += fVal; }
32 kOp kOpSum(0.0, fkOpSum);
34 void fkOpSumSquare(KahanSum& rAccum, double fVal) { rAccum += fVal * fVal; }
36 kOp kOpSumSquare(0.0, fkOpSumSquare);
38 std::vector<kOp> kOpSumAndSumSquare = { kOpSum, kOpSumSquare };
41 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */