Class for carefully adding long list of numbers. More...
#include <opennurbs_math.h>
Public Member Functions | |
ON_Sum () | |
Creates a sum that is ready to be used. More... | |
void | Begin (double starting_value=0.0) |
If a sum is being used more than once, call Begin() before starting each sum. More... | |
void | operator+= (double x) |
Calls ON_Sum::Plus(x); More... | |
void | operator-= (double x) |
Calls ON_Sum::Plus(-x); More... | |
void | operator= (double x) |
Calls ON_Sum::Begin(x) More... | |
void | Plus (double x) |
Add x to the current sum. More... | |
void | Plus (double x, double dx) |
Add x to the current sum. More... | |
int | SummandCount () const |
double | Total (double *error_estimate=nullptr) |
Calculates the total sum. More... | |
Class for carefully adding long list of numbers.
ON_Sum::ON_Sum | ( | ) |
Creates a sum that is ready to be used.
void ON_Sum::Begin | ( | double | starting_value = 0.0 | ) |
If a sum is being used more than once, call Begin() before starting each sum.
starting_value | [in] Initial value of sum. |
void ON_Sum::operator+= | ( | double | x | ) |
Calls ON_Sum::Plus(x);
void ON_Sum::operator-= | ( | double | x | ) |
Calls ON_Sum::Plus(-x);
void ON_Sum::operator= | ( | double | x | ) |
Calls ON_Sum::Begin(x)
void ON_Sum::Plus | ( | double | x | ) |
Add x to the current sum.
x | [in] value to add to the current sum. |
void ON_Sum::Plus | ( | double | x, |
double | dx | ||
) |
Add x to the current sum.
x | [in] value to add to the current sum. |
dx | [in] symmetric uncertainty in x. (true value is in the range x-dx to x+dx |
int ON_Sum::SummandCount | ( | ) | const |
double ON_Sum::Total | ( | double * | error_estimate = nullptr | ) |
Calculates the total sum.
error_estimate | [out] if not nullptr, the returned value of *error_estimate is an estimate of the error in the sum. |
You can get subtotals by mixing calls to Plus() and Total(). In delicate sums, some precision may be lost in the final total if you call Total() to calculate subtotals.