

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object mpicbg.util.RealSum
public class RealSum
RealSum
implements a method to reduce numerical instabilities
when summing up a very large number of double precision numbers. Numerical
problems occur when a small number is added to an already very large sum.
In such case, the reduced accuracy of the very large number may lead to the
small number being entirely ignored. The method here stores and updates
intermediate sums for all power of two elements such that the final sum can
be generated from intermediate sums that result from equal number of
summands.
Field Summary  

protected boolean[] 
flags

protected double[] 
sums

Constructor Summary  

RealSum()
Create a new RealSum . 

RealSum(int capacity)
Create a new RealSum . 
Method Summary  

void 
add(double a)
Add an element to the sum. 
protected void 
expand(double s)

double 
getSum()
Get the current sum by summing up all intermediate sums. 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 

protected boolean[] flags
protected double[] sums
Constructor Detail 

public RealSum()
RealSum
. The fields for intermediate sums is
initialized with a single element and expanded on demand as new
elements are added.
public RealSum(int capacity)
RealSum
. The fields for intermediate sums is
initialized with a given number of elements and will only be expanded
on demand as new elements are added and the number of existing elements
is not sufficient. This may be faster in cases where the required
number of elements is known in prior.
capacity
 Method Detail 

public final double getSum()
protected final void expand(double s)
public final void add(double a)
a
 the summand to be added


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 