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 may continue after intermediate summations.


Note: Exception and non-finite handling differ 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, *args)
Accumulate more values from positional arguments.
 
fadd(self, iterable)
Accumulate more values from the iterable.
 
fsum_(self, *args)
Accumulated more values from positional arguments and sum all.
 
fsum(self, iterable=())
Accumulated more values from the iterable and sum all.

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, *args)

 

Accumulate more values from positional arguments.

Parameters:
  • args - Values to add (scalars), all positional.
Raises:
  • OverflowError - Partial 2sum overflow.
  • ValueError - Invalid or infinite arg.

fadd(self, iterable)

 

Accumulate more values from the iterable.

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

fsum_(self, *args)

 

Accumulated more values from positional arguments and sum all.

Parameters:
  • args - Values to add (scalars), all positional.
Returns:
Accurate, running sum (float).
Raises:
  • OverflowError - Partial 2sum overflow.
  • ValueError - Invalid or infinite arg value.

Note: Accumulation can continue after summation.

fsum(self, iterable=())

 

Accumulated more values from the iterable and sum all.

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

Note: Accumulation can continue after summation.