Class Accumulator

java.lang.Object
com.irurueta.navigation.geodesic.Accumulator

public class Accumulator extends Object
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
    Modifier and Type
    Field
    Description
    private double
    s + t accumulators for the sum.
    private double
    s + t accumulators for the sum.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Accumulator(double y)
    Constructor from a double.
    Constructor from another Accumulator.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(double y)
    Add a number to the accumulator.
    double
    Returns the value held in the accumulator.
    void
    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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • s

      private double s
      s + t accumulators for the sum.
    • t

      private double t
      s + t accumulators for the sum.
  • Constructor Details

    • Accumulator

      public Accumulator(double y)
      Constructor from a double.
      Parameters:
      y - set sum = y.
    • Accumulator

      public Accumulator(Accumulator a)
      Constructor from another Accumulator.
      Parameters:
      a - set sum = a.
  • 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.