2 * \brief Inline functions providing Kahan summation.
9 static inline void kahaninit(double * const sum
, double * const compensation
) {
14 static inline void kahanadd(double *sum
, double *compensation
, double input
) {
15 double compensated_input
= input
- *compensation
;
16 double nsum
= *sum
+ compensated_input
;
17 *compensation
= (nsum
- *sum
) - compensated_input
;
22 static inline void ckahaninit(complex double * const sum
, complex double * const compensation
) {
27 static inline void ckahanadd(complex double *sum
, complex double *compensation
, complex double input
) {
28 complex double compensated_input
= input
- *compensation
;
29 complex double nsum
= *sum
+ compensated_input
;
30 *compensation
= (nsum
- *sum
) - compensated_input
;