PLaSK library

Loading...
Searching...
No Matches
Public Member Functions | List of all members
plask::AccurateSum Class Reference

Allow to compute sum of doubles much more accurate than directly. More...

`#include <plask/math.hpp>`

## Public Member Functions
| AccurateSum (double initial=0.0)
AccurateSum & | operator= (double v)
| AccurateSum (const AccurateSum &initial)=default
AccurateSum & | operator= (const AccurateSum &v)=default
AccurateSum & | operator+= (double v)
AccurateSum & | operator-= (double v)
| operator double () const
AccurateSum & | operator+= (const AccurateSum &other)

## Detailed Description

Allow to compute sum of doubles much more accurate than directly.

It uses O(1) memory (stores 2 doubles) and all it's operation has O(1) time complexity.

It uses Kahan method http://en.wikipedia.org/wiki/Kahan_summation_algorithm

Definition at line 422 of file math.hpp.

## Constructor & Destructor Documentation

## ◆ AccurateSum() [1/2]

plask::AccurateSum::AccurateSum | ( | double | initial = `0.0` | ) |
| inline

Definition at line 428 of file math.hpp.

## ◆ AccurateSum() [2/2]

plask::AccurateSum::AccurateSum | ( | const AccurateSum & | initial | ) |
| default

## Member Function Documentation

## ◆ operator double()

plask::AccurateSum::operator double | ( |  | ) | const
| inline

Definition at line 438 of file math.hpp.

## ◆ operator+=() [1/2]

AccurateSum & plask::AccurateSum::operator+= | ( | const AccurateSum & | other | ) |

Definition at line 46 of file math.cpp.

## ◆ operator+=() [2/2]

AccurateSum & plask::AccurateSum::operator+= | ( | double | v | ) |

Definition at line 52 of file math.cpp.

## ◆ operator-=()

AccurateSum & plask::AccurateSum::operator-= | ( | double | v | ) |
| inline

Definition at line 436 of file math.hpp.

## ◆ operator=() [1/2]

AccurateSum & plask::AccurateSum::operator= | ( | const AccurateSum & | v | ) |
| default

## ◆ operator=() [2/2]

AccurateSum & plask::AccurateSum::operator= | ( | double | v | ) |

Definition at line 20 of file math.cpp.

The documentation for this class was generated from the following files:

- plask/math.hpp
- plask/math.cpp