ThreeB 1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | Private Attributes
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 245 of file multispot5.cc.

## Constructor & Destructor Documentation

Kahan::Kahan | ( |  | ) | `[inline]`

Definition at line 253 of file multispot5.cc.

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

## Member Function Documentation

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

Add a number to the running sum.

Parameters:

  i | Number to add

Definition at line 259 of file multispot5.cc.

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

            {
                //y = input -c
                y = i;
                y-= c;

                //t = sum + y
                t = sum;
                t += y;

                //c = (t - sum) - y
                //c = ((sum + y) - sum) - y)
                c = t;
                c -= sum;
                c -= y;
                sum = t;
            }

## Member Data Documentation

double Kahan::y`[private]`

Input with the compensation removed. Temporary working space.

Definition at line 247 of file multispot5.cc.

double Kahan::c`[private]`

Running compenstation for low-order bits.

Definition at line 248 of file multispot5.cc.

double Kahan::t`[private]`

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

Definition at line 249 of file multispot5.cc.

double Kahan::sum

running sum

Definition at line 251 of file multispot5.cc.

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

- multispot5.cc