LibreOffice Module sc (master)  1
arraysum.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 
11 #pragma once
12 
13 #include <cmath>
14 
15 namespace sc::op
16 {
17 // Code must not be shared between different CPU instrinsics flags (e.g. in debug mode the compiler would not
18 // inline them, and merge the copies, keeping only the one with the most demanding CPU set that's not available otherwise).
19 // Put everything in a different namespace and additionally try to force inlining.
21 {
22 #if defined _MSC_VER
23 #define INLINE __forceinline static
24 #elif defined __GNUC__
25 #define INLINE __attribute__((always_inline)) static inline
26 #else
27 #define static inline
28 #endif
29 
37 INLINE void sumNeumanierNormal(double& sum, double& err, const double& value)
38 {
39  double t = sum + value;
40  if (std::abs(sum) >= std::abs(value))
41  err += (sum - t) + value;
42  else
43  err += (value - t) + sum;
44  sum = t;
45 }
46 
47 #undef INLINE
48 
49 } // end namespace LO_ARRAYSUM_SPACE
50 } // end namespace sc::op
51 
52 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define LO_ARRAYSUM_SPACE
Definition: arraysumAVX.cxx:11
XPropertyListType t
INLINE void sumNeumanierNormal(double &sum, double &err, const double &value)
Performs one step of the Neumanier sum between doubles Overwrites the summand and error sum...
Definition: arraysum.hxx:37