Kahan Class Reference
[General utility functions.]

Class implementing the Kahan summation algorithm to allow accurate summation of very large numbers of doubles. More...

List of all members.

Public Member Functions

 Kahan ()
void add (double i)

Public Attributes

double sum

Private Attributes

double y
double c
double t

Detailed Description

Class implementing the Kahan summation algorithm to allow accurate summation of very large numbers of doubles.

Definition at line 223 of file multispot5.cc.


Constructor & Destructor Documentation

Kahan::Kahan (  )  [inline]

Definition at line 231 of file multispot5.cc.

00232         :c(0),sum(0)
00233         {}


Member Function Documentation

void Kahan::add ( double  i  )  [inline]

Add a number to the running sum.

Parameters:
i Number to add

Definition at line 237 of file multispot5.cc.

References c, sum, t, and y.

Referenced by NegativeFreeEnergy::compute_with_mask(), and NegativeFreeEnergy::operator()().

00238         {
00239             //y = input -c
00240             y = i;
00241             y-= c;
00242 
00243             //t = sum + y
00244             t = sum;
00245             t += y;
00246             
00247             //c = (t - sum) - y
00248             //c = ((sum + y) - sum) - y)
00249             c = t;
00250             c -= sum;
00251             c -= y;
00252             sum = t;
00253         }


Member Data Documentation

double Kahan::y [private]

Input with the compensation removed. Temporary working space.

Definition at line 225 of file multispot5.cc.

Referenced by add().

double Kahan::c [private]

Running compenstation for low-order bits.

Definition at line 226 of file multispot5.cc.

Referenced by add().

double Kahan::t [private]

y + sum, which loses low order bits of y. Temporary working space.

Definition at line 227 of file multispot5.cc.

Referenced by add().

double Kahan::sum

running sum

Definition at line 229 of file multispot5.cc.

Referenced by add().


The documentation for this class was generated from the following file:
Generated on Wed Nov 2 18:00:03 2011 for BCUBED by  doxygen 1.6.3