Functions
exactmath.hpp File Reference

Exact math. More...

#include <stdlib.h>
#include <cmath>
#include <vector>
#include <boost/array.hpp>
Include dependency graph for exactmath.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void fastTwoSum (double a, double b, double &res, double &err)
 Calculates the sum of two numbers. More...
 
void fastTwoDiff (double a, double b, double &res, double &err)
 Subtracts two numbers. More...
 
void twoSum (double a, double b, double &res, double &err)
 Calculates the sum of a and b. More...
 
void twoDiff (double a, double b, double &res, double &err)
 Difference between two numbers. More...
 
void split (double num, double &high, double &low)
 Splits a given number into two, Used for multiplication. More...
 
void twoProduct (double a, double b, double &res, double &err)
 Product of two number. More...
 
void square (double num, double &res, double &err)
 Calculates the square of a number. More...
 
boost::array< double, 3 > twoOneSum (boost::array< double, 2 > const &a, double b)
 Calculates the sum of a two-expansion and a double. More...
 
boost::array< double, 3 > twoOneDiff (boost::array< double, 2 > const &a, double b)
 Calculates the difference between a two-expansion and a double. More...
 
vector< double > twoTwoSum (boost::array< double, 2 > const &a, boost::array< double, 2 > const &b)
 Calculates the sum of two two-expansions. More...
 
vector< double > twoTwoDiff (boost::array< double, 2 > const &a, boost::array< double, 2 > const &b)
 Calculates the difference between two two-expansions. More...
 
vector< double > growExpansionZeroElim (vector< double > const &e, double b)
 Adds a scalar to an existing expansion. More...
 
vector< double > expansionSumZeroElim (vector< double > const &e, vector< double > const &f)
 Adds up two expansions. More...
 
vector< double > fastExpansionSumZeroElim (vector< double > const &e, vector< double > const &f)
 Adds up two expansions. More...
 
vector< double > linearExpansionSumZeroElim (vector< double > const &e, vector< double > const &f)
 Adds up two expansions. More...
 
void scaleExpansionZeroElim (vector< double > const &e, double b, vector< double > &result)
 Multiplies a scalar by an expansion. More...
 
vector< double > compress (vector< double > const &e)
 Compresses an expansion. More...
 
double estimate (vector< double > const &e)
 Calculate a double precision approximation of the expansion. More...
 

Detailed Description

Exact math.

Author
Elad Steinberg

Definition in file exactmath.hpp.

Function Documentation

◆ compress()

vector<double> compress ( vector< double > const &  e)

Compresses an expansion.

Parameters
eExpansion
Returns
Expansion

Definition at line 450 of file exactmath.cpp.

Here is the call graph for this function:

◆ estimate()

double estimate ( vector< double > const &  e)

Calculate a double precision approximation of the expansion.

Parameters
eExpansion
Returns
A number

Definition at line 488 of file exactmath.cpp.

Here is the caller graph for this function:

◆ expansionSumZeroElim()

vector<double> expansionSumZeroElim ( vector< double > const &  e,
vector< double > const &  f 
)

Adds up two expansions.

Parameters
eFirst expansion
fSecond expansion
Returns
Sum

Definition at line 173 of file exactmath.cpp.

Here is the call graph for this function:

◆ fastExpansionSumZeroElim()

vector<double> fastExpansionSumZeroElim ( vector< double > const &  e,
vector< double > const &  f 
)

Adds up two expansions.

Parameters
eFirst expansion
fSecond expansion
Returns
Sum

Definition at line 213 of file exactmath.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fastTwoDiff()

void fastTwoDiff ( double  a,
double  b,
double &  res,
double &  err 
)

Subtracts two numbers.

Parameters
aFirst number
bSecond number
resOutput
errRoundoff error

Definition at line 26 of file exactmath.cpp.

◆ fastTwoSum()

void fastTwoSum ( double  a,
double  b,
double &  res,
double &  err 
)

Calculates the sum of two numbers.

Parameters
aFirst number
bSecond number
resOutput
errRoundoff error

Definition at line 12 of file exactmath.cpp.

Here is the caller graph for this function:

◆ growExpansionZeroElim()

vector<double> growExpansionZeroElim ( vector< double > const &  e,
double  b 
)

Adds a scalar to an existing expansion.

Parameters
eExpansion
bScalar
Returns
Expansion

Definition at line 150 of file exactmath.cpp.

Here is the call graph for this function:

◆ linearExpansionSumZeroElim()

vector<double> linearExpansionSumZeroElim ( vector< double > const &  e,
vector< double > const &  f 
)

Adds up two expansions.

Parameters
eFirst expansion
fSecond expansion
Returns
Expansion

Definition at line 330 of file exactmath.cpp.

Here is the call graph for this function:

◆ scaleExpansionZeroElim()

void scaleExpansionZeroElim ( vector< double > const &  e,
double  b,
vector< double > &  result 
)

Multiplies a scalar by an expansion.

Parameters
eExpansion
bScalar
resultResult

Definition at line 416 of file exactmath.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ split()

void split ( double  num,
double &  high,
double &  low 
)

Splits a given number into two, Used for multiplication.

Parameters
numNumber
highHigher part
lowLower part

Definition at line 66 of file exactmath.cpp.

Here is the caller graph for this function:

◆ square()

void square ( double  num,
double &  res,
double &  err 
)

Calculates the square of a number.

Parameters
numNumber
resResult
errRoundoff error

Definition at line 104 of file exactmath.cpp.

Here is the caller graph for this function:

◆ twoDiff()

void twoDiff ( double  a,
double  b,
double &  res,
double &  err 
)

Difference between two numbers.

Parameters
aFirst number
bSecond number
resResult
errRoundoff error

Definition at line 60 of file exactmath.cpp.

Here is the caller graph for this function:

◆ twoOneDiff()

boost::array<double,3> twoOneDiff ( boost::array< double, 2 > const &  a,
double  b 
)

Calculates the difference between a two-expansion and a double.

Parameters
aTwo expansion
bNumber
Returns
Difference

Definition at line 119 of file exactmath.cpp.

Here is the call graph for this function:

◆ twoOneSum()

boost::array<double,3> twoOneSum ( boost::array< double, 2 > const &  a,
double  b 
)

Calculates the sum of a two-expansion and a double.

Parameters
aTwo expansion
bA number
Returns
Sum

Definition at line 110 of file exactmath.cpp.

Here is the call graph for this function:

◆ twoProduct()

void twoProduct ( double  a,
double  b,
double &  res,
double &  err 
)

Product of two number.

Parameters
aFirst number
bSecond number
resResult
errError

Definition at line 87 of file exactmath.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twoSum()

void twoSum ( double  a,
double  b,
double &  res,
double &  err 
)

Calculates the sum of a and b.

Parameters
aFirst number
bSecond number
resResult
errRoundoff error

Definition at line 43 of file exactmath.cpp.

Here is the caller graph for this function:

◆ twoTwoDiff()

vector<double> twoTwoDiff ( boost::array< double, 2 > const &  a,
boost::array< double, 2 > const &  b 
)

Calculates the difference between two two-expansions.

Parameters
aFirst two expansion
bSecond two expansion
Returns
Difference

Definition at line 139 of file exactmath.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twoTwoSum()

vector<double> twoTwoSum ( boost::array< double, 2 > const &  a,
boost::array< double, 2 > const &  b 
)

Calculates the sum of two two-expansions.

Parameters
aFirst two expansion
bSecond two expansio
Returns
sum

Definition at line 128 of file exactmath.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: