Package pygeodesy :: Module fmath :: Class Fsum
[frames] | no frames]

Class Fsum

object --+
         |
        Fsum

Precision floating point summation similar to standard Python function math.fsum.

Unlike math.fsum, this class accumulates the values to be added incrementally and provides intermediate, precision summations. Accumulation can continue after intermediate summations.

Exception and non-finite handling differs from math.fsum.


See Also: Hettinger, Klein, Kahan, Python 2.6+ file Modules/mathmodule.c and the issue log Full precision summation.

Instance Methods
 
__init__(self, start=0)
Initialize a new accumulator.
 
__len__(self)
Return the number of accumulated values.
 
fadd(self, arg)
Accumulate another value.
 
fadd2(self, iterable)
Accumulate multiple values.
 
fsum(self)
Summation of the values accumulated so far.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, start=0)
(Constructor)

 

Initialize a new accumulator.

Overrides: object.__init__

fadd(self, arg)

 

Accumulate another value.

Parameters:
  • arg - Value to add (scalar).
Raises:
  • OverflowError - Partial 2sum overflow.
  • ValueError - Invalid or infinite arg.

fadd2(self, iterable)

 

Accumulate multiple values.

Parameters:
  • iterable - Sequence, list, tuple, etc. (scalars).
Raises:
  • OverflowError - Partial 2sum overflow.
  • ValueError - Invalid or infinite iterable value.

fsum(self)

 

Summation of the values accumulated so far.

Returns:
Precision sum (float).
Raises:
  • OverflowError - Partial 2sum overflow.

Note: Accumulation can continue after summation.