Package com.irurueta.navigation.geodesic
Class Accumulator
java.lang.Object
com.irurueta.navigation.geodesic.Accumulator
An accumulator for sums.
This allows many double precision numbers to be added together with twice the normal
precision. Thus, the effective precision of the sum is 106 bits or about 32 decimal places.
The implementation follows J. R. Shewchuk,
Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric
Predicates, Discrete & Computational Geometry 18(3) 305–363 (1997).
In the documentation of the member functions, sum stands for the value currently held in the
accumulator.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAccumulator
(double y) Constructor from a double.Constructor from another Accumulator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double y) Add a number to the accumulator.double
getSum()
Returns the value held in the accumulator.void
negate()
Negate an accumulator.void
set
(double y) Sets the value to a double.double
sum
(double y) Returns the result of adding a number to sum (but don't change sum).
-
Field Details
-
s
private double ss + t accumulators for the sum. -
t
private double ts + t accumulators for the sum.
-
-
Constructor Details
-
Accumulator
public Accumulator(double y) Constructor from a double.- Parameters:
y
- set sum = y.
-
-
Method Details
-
set
public void set(double y) Sets the value to a double.- Parameters:
y
- set sum = y.
-
getSum
public double getSum()Returns the value held in the accumulator.- Returns:
- sum.
-
sum
public double sum(double y) Returns the result of adding a number to sum (but don't change sum).- Parameters:
y
- the number to be added to the sum.- Returns:
- sum + y.
-
add
public void add(double y) Add a number to the accumulator.- Parameters:
y
- set sum += y.
-
negate
public void negate()Negate an accumulator. Set sum = −sum.
-