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

# Class Fsum

    object --+
             |
            Fsum

Known Subclasses:
  - Fdot
  - , Fhorner
  - , Fpolynomial

Precision summation similar to standard Python function `math.fsum`.

Unlike `math.fsum`, this class accumulates the values repeatedly and provides intermediate, precision running sums. Accumulation may continue after intermediate summations.

Note: Exception and non-finite handling differ from `math.fsum`.

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

Instance Methods
__init__(self, *starts) Initialize a new accumulator with one or more start values. |
__add__(self, other) Sum of this and an other instance or a scalar. |
__iadd__(self, other) Add a scalar or an other instance to this instance. |
__imul__(self, other) Multiply this instance by a scalar or an other instance. |
__isub__(self, other) Subtract a scalar or an other instance from this instance. |
__len__(self) Return the number of accumulated values. |
__mul__(self, other) Product of this and an other instance or a scalar. |
__str__(self) str(x) |
__sub__(self, other) Difference of this and an other instance or a scalar. |
fadd(self, iterable) Accumulate more values from an iterable. |
fadd_(self, *xs) Accumulate more values from positional arguments. |
fcopy(self) Copy this instance. |
__copy__(self) Copy this instance. |
fmul(self, factor) Multiple the current, partial sum by a factor. |
fsub(self, *xs) Accumulate more values from positional arguments. |
fsum(self, iterable=`(``)`) Accumulate more values from an iterable and sum all. |
fsum_(self, *xs) Accumulate more values from positional arguments and sum all. |
fsum2_(self, *xs) Accumulate more values from positional arguments, sum all and provide the sum delta. |
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Class Variables
| _fsum2_ = `0` hash(x)

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, *starts) (Constructor) |
Initialize a new accumulator with one or more start values. Parameters: `starts` - No, one or more start values (`scalar`s). Raises: `OverflowError` - Partial `2sum` overflow. `TypeError` - Non-scalar starts value. `ValueError` - Invalid or infinite starts value. Overrides: object.__init__

### __add__(self, other) (Addition operator) |
Sum of this and an other instance or a scalar. Parameters: `other` - Fsum instance or `scalar`. Returns: The sum, a new instance (Fsum). See Also: Method Fsum.fadd.

### __iadd__(self, other) |
Add a scalar or an other instance to this instance. Parameters: `other` - Fsum instance or `scalar`. Returns: This instance, updated (Fsum). See Also: Method Fsum.fadd.

### __imul__(self, other) |
Multiply this instance by a scalar or an other instance. Parameters: `other` - Fsum instance or `scalar`. Returns: This instance, updated (Fsum). See Also: Method Fsum.fmul.

### __isub__(self, other) |
Subtract a scalar or an other instance from this instance. Parameters: `other` - Fsum instance or `scalar`. Returns: This instance, updated (Fsum). See Also: Method Fsum.fadd.

### __mul__(self, other) |
Product of this and an other instance or a scalar. Parameters: `other` - Fsum instance or `scalar`. Returns: The product, a new instance (Fsum). See Also: Method Fsum.fmul.

### __str__(self) (Informal representation operator) |
str(x) Overrides: object.__str__ (inherited documentation)

### __sub__(self, other) (Subtraction operator) |
Difference of this and an other instance or a scalar. Parameters: `other` - Fsum instance or `scalar`. Returns: The difference, a new instance (Fsum). See Also: Method Fsum.fadd.

### fadd(self, iterable) |
Accumulate more values from an iterable. Parameters: `iterable` - Sequence, list, tuple, etc. (`scalar`s). Raises: `OverflowError` - Partial `2sum` overflow. `TypeError` - Non-scalar iterable value. `ValueError` - Invalid or infinite iterable value.

### fadd_(self, *xs) |
Accumulate more values from positional arguments. Parameters: `xs` - Values to add (`scalar`s), all positional. Raises: `OverflowError` - Partial `2sum` overflow. `TypeError` - Non-scalar xs value. `ValueError` - Invalid or infinite arg.

### fcopy(self) |
Copy this instance. Returns: The copy, a new instance (Fsum).

### __copy__(self) |
Copy this instance. Returns: The copy, a new instance (Fsum).

### fmul(self, factor) |
Multiple the current, partial sum by a factor. Parameters: `factor` - The multiplier (`scalar`). Raises: `TypeError` - Non-scalar factor. `ValueError` - Invalid or infinite factor.

### fsub(self, *xs) |
Accumulate more values from positional arguments. Parameters: `xs` - Values to subtract (`scalar`s), all positional. Raises: `OverflowError` - Partial `2sum` overflow. `TypeError` - Non-scalar xs value. `ValueError` - Invalid or infinite arg.

### fsum(self, iterable=`(``)`) |
Accumulate more values from an iterable and sum all. Parameters: `iterable` - Sequence, list, tuple, etc. (`scalar`s), optional. Returns: Accurate, running sum (`float`). Raises: `OverflowError` - Partial `2sum` overflow. `TypeError` - Non-scalar iterable value. `ValueError` - Invalid or infinite iterable value. Note: Accumulation can continue after summation.

### fsum_(self, *xs) |
Accumulate more values from positional arguments and sum all. Parameters: `xs` - Values to add (`scalar`s), all positional. Returns: Accurate, running sum (`float`). Raises: `OverflowError` - Partial `2sum` overflow. `TypeError` - Non-scalar x value. `ValueError` - Invalid or infinite x value. Note: Accumulation can continue after summation.

### fsum2_(self, *xs) |
Accumulate more values from positional arguments, sum all and provide the sum delta. Parameters: `xs` - Values to add (`scalar`s), all positional. Returns: 2-Tuple (fsum_, delta) with athe ccurate, running sum and the delta with the previous sum (`float`s). Raises: `OverflowError` - Partial `2sum` overflow. `TypeError` - Non-scalar x value. `ValueError` - Invalid or infinite x value. Note: Accumulation can continue after summation.