Loading...
Searching...
No Matches
gpr::linalg::CompensatedSum Struct Reference

#include <gpr/linalg/CompensatedSum.h>

Public Member Functions

void add (double value)
void addProduct (double left, double right)
double value () const

Public Attributes

double sum = 0.0
double corr = 0.0

Detailed Description

Neumaier summation with explicit product residuals. The two components remain separate across distributed reductions until the final rounding.

Definition at line 85 of file CompensatedSum.h.

Member Function Documentation

◆ add()

void gpr::linalg::CompensatedSum::add ( double value)
inline

Definition at line 89 of file CompensatedSum.h.

90 {
91 const double next = sum + value;
92 corr += std::fabs(sum) >= std::fabs(value) ? (sum - next) + value
93 : (value - next) + sum;
94 sum = next;
95 }

◆ addProduct()

void gpr::linalg::CompensatedSum::addProduct ( double left,
double right )
inline

TwoProductFMA (Ogita, Rump, Oishi, 2005, Algorithm 3.5). The residual is exact when no intermediate operation overflows or underflows.

Definition at line 100 of file CompensatedSum.h.

101 {
102 const double product = left * right;
103 add(product);
104 add(std::fma(left, right, -product));
105 }

◆ value()

double gpr::linalg::CompensatedSum::value ( ) const
inline

Definition at line 107 of file CompensatedSum.h.

108 {
109 return sum + corr;
110 }

Member Data Documentation

◆ corr

double gpr::linalg::CompensatedSum::corr = 0.0

Definition at line 87 of file CompensatedSum.h.

◆ sum

double gpr::linalg::CompensatedSum::sum = 0.0

Definition at line 86 of file CompensatedSum.h.


The documentation for this struct was generated from the following file: