exactmath.hpp
Go to the documentation of this file.
1 
6 #ifndef EXACTMATH_HPP
7 #define EXACTMATH_HPP 1
8 
9 #include <stdlib.h>
10 #include <cmath>
11 #include <vector>
12 #include <boost/array.hpp>
13 
14 using std::vector;
15 using std::min;
16 
23 void fastTwoSum(double a, double b, double& res, double& err);
24 
31 void fastTwoDiff(double a, double b, double& res, double& err);
32 
39 void twoSum(double a, double b, double& res, double& err);
40 
47 void twoDiff(double a, double b, double& res, double& err);
48 
54 void split(double num, double& high, double& low);
55 
62 void twoProduct(double a, double b, double& res, double& err);
63 
69 void square(double num, double& res, double& err);
70 
76 boost::array<double,3> twoOneSum(boost::array<double,2> const& a, double b);
77 
83 boost::array<double,3> twoOneDiff(boost::array<double,2> const& a, double b);
84 
90 vector<double> twoTwoSum(boost::array<double,2> const& a,boost::array<double,2> const& b);
91 
97 vector<double> twoTwoDiff(boost::array<double,2> const& a, boost::array<double,2> const& b);
98 
104 vector<double> growExpansionZeroElim(vector<double> const& e, double b);
105 
111 vector<double> expansionSumZeroElim(vector<double> const& e, vector<double> const& f);
112 
118 vector<double> fastExpansionSumZeroElim(vector<double> const& e, vector<double> const& f);
119 
125 vector<double> linearExpansionSumZeroElim(vector<double> const& e, vector<double> const& f);
126 
132 void scaleExpansionZeroElim(vector<double> const& e, double b,
133  vector<double> &result);
134 
139 vector<double> compress(vector<double> const& e);
140 
145 double estimate(vector<double> const& e);
146 
147 #endif //EXACTMATH_HPP
vector< double > expansionSumZeroElim(vector< double > const &e, vector< double > const &f)
Adds up two expansions.
Definition: exactmath.cpp:173
void twoDiff(double a, double b, double &res, double &err)
Difference between two numbers.
Definition: exactmath.cpp:60
boost::array< double, 3 > twoOneSum(boost::array< double, 2 > const &a, double b)
Calculates the sum of a two-expansion and a double.
Definition: exactmath.cpp:110
double estimate(vector< double > const &e)
Calculate a double precision approximation of the expansion.
Definition: exactmath.cpp:488
vector< double > growExpansionZeroElim(vector< double > const &e, double b)
Adds a scalar to an existing expansion.
Definition: exactmath.cpp:150
vector< double > twoTwoSum(boost::array< double, 2 > const &a, boost::array< double, 2 > const &b)
Calculates the sum of two two-expansions.
Definition: exactmath.cpp:128
void twoProduct(double a, double b, double &res, double &err)
Product of two number.
Definition: exactmath.cpp:87
vector< double > compress(vector< double > const &e)
Compresses an expansion.
Definition: exactmath.cpp:450
void twoSum(double a, double b, double &res, double &err)
Calculates the sum of a and b.
Definition: exactmath.cpp:43
void fastTwoDiff(double a, double b, double &res, double &err)
Subtracts two numbers.
Definition: exactmath.cpp:26
boost::array< double, 3 > twoOneDiff(boost::array< double, 2 > const &a, double b)
Calculates the difference between a two-expansion and a double.
Definition: exactmath.cpp:119
vector< double > twoTwoDiff(boost::array< double, 2 > const &a, boost::array< double, 2 > const &b)
Calculates the difference between two two-expansions.
Definition: exactmath.cpp:139
double min(vector< double > const &v)
Returns the minimal term in a vector.
Definition: utils.cpp:44
void split(double num, double &high, double &low)
Splits a given number into two, Used for multiplication.
Definition: exactmath.cpp:66
vector< double > fastExpansionSumZeroElim(vector< double > const &e, vector< double > const &f)
Adds up two expansions.
Definition: exactmath.cpp:213
void scaleExpansionZeroElim(vector< double > const &e, double b, vector< double > &result)
Multiplies a scalar by an expansion.
Definition: exactmath.cpp:416
void fastTwoSum(double a, double b, double &res, double &err)
Calculates the sum of two numbers.
Definition: exactmath.cpp:12
vector< double > linearExpansionSumZeroElim(vector< double > const &e, vector< double > const &f)
Adds up two expansions.
Definition: exactmath.cpp:330
void square(double num, double &res, double &err)
Calculates the square of a number.
Definition: exactmath.cpp:104