31 #ifndef __TASMANIAN_SPARSE_GRID_MATHUTILS_HPP
32 #define __TASMANIAN_SPARSE_GRID_MATHUTILS_HPP
67 while (i >>= 1){ result++; }
76 while (i >>= 1){ result <<= 1; }
85 while(i >= 1){ i /= 3; result *= 3; }
92 inline int pow2(
int p){
return (1 << p); }
99 for(
int i=0; i<p; i++) result *= 3;
107 inline double sign(
double p){
return (p >= 0.0) ? 1.0 : -1.0; }
117 constexpr
double pi = 3.14159265358979323846;
int pow3(int p)
Computes std::pow(3, p), but uses only integer operations.
Definition: tsgMathUtils.hpp:97
double sign(double p)
Returns +1 or -1 with the same sign as p.
Definition: tsgMathUtils.hpp:107
int int3log3(int i)
Computes std::pow(3, std::floor(std::log(i) / std::log(2))), but uses only integer operations.
Definition: tsgMathUtils.hpp:83
constexpr double num_tol
Numerical tolerance for various algorithms.
Definition: tsgMathUtils.hpp:132
constexpr double pi
Half-period of the std::sin() and std::cos() functions.
Definition: tsgMathUtils.hpp:117
int pow2(int p)
Computes std::pow(2, p), but uses only integer operations.
Definition: tsgMathUtils.hpp:92
int int2log2(int i)
Computes std::pow(2, std::floor(std::log2(i))), but uses only integer operations.
Definition: tsgMathUtils.hpp:74
int intlog2(int i)
Computes std::floor(std::log2(i)), but uses only integer operations.
Definition: tsgMathUtils.hpp:65
Encapsulates the Tasmanian Sparse Grid module.
Definition: TasmanianSparseGrid.hpp:68