Mathematical Helpers. More...
Go to the source code of this file.
Namespaces | |
namespace | ogdf |
The namespace for all OGDF objects. | |
namespace | ogdf::Math |
namespace | ogdf::Math::internal |
Functions | |
int | ogdf::Math::binomial (int n, int k) |
Returns \(n \choose k\). | |
double | ogdf::Math::binomial_d (int n, int k) |
Returns \(n \choose k\). | |
double | ogdf::Math::degreesToRadians (const double &angleInDegrees) |
Converts an angle from degrees to radians. | |
int | ogdf::Math::factorial (int n) |
Returns n! . | |
double | ogdf::Math::factorial_d (int n) |
Returns n! . | |
int | ogdf::Math::floorLog2 (int v) |
A method to obtain the rounded down binary logarithm of v . | |
template<class T , class INDEX = int> | |
T | ogdf::Math::gcd (const Array< T, INDEX > &numbers) |
Returns the greatest common divisor of a list of numbers. | |
template<typename T > | |
T | ogdf::Math::gcd (T a, T b) |
Returns the greatest common divisor of two numbers. | |
void | ogdf::Math::getFraction (double d, int &num, int &denom, const double epsilon=5e-10, const int count=10) |
Converts a double to a fraction. | |
double | ogdf::Math::harmonic (unsigned n) |
Returns the n-th harmonic number or 1.0 if n < 1. | |
template<typename T > | |
T | ogdf::Math::lcm (T a, T b) |
Returns the least common multipler of two numbers. | |
template<typename T > | |
T | ogdf::Math::log2 (T x) |
Returns the logarithm of x to the base 2. | |
double | ogdf::Math::log4 (double x) |
Returns the logarithm of x to the base 4. | |
template<class Container > | |
Container::value_type | ogdf::Math::maxValue (const Container &values) |
Returns the maximum of an iterable container of given values . | |
template<class Container > | |
double | ogdf::Math::mean (const Container &values) |
Returns the mean of an iterable container of given values . | |
template<class Container > | |
Container::value_type | ogdf::Math::minValue (const Container &values) |
Returns the minimum of an iterable container of given values . | |
template<typename T , typename... Args> | |
static T | ogdf::Math::nextPower2 (T arg1, T arg2, Args... args) |
Returns the smallest power of 2 that is no less than the given (integral) arguments. | |
template<typename T , int size> | |
std::enable_if< size==1, T >::type | ogdf::Math::internal::nextPower2 (T x) |
template<typename T , int size> | |
std::enable_if< size!=1, T >::type | ogdf::Math::internal::nextPower2 (T x) |
Efficiently computes the next power of 2 without branching. See "Hacker's Delight" 2nd Edition, by Henry S. Warren, Fig. 3.3. | |
template<typename T > | |
T | ogdf::Math::nextPower2 (T x) |
Returns the smallest power of 2 that is no less than the given (integral) argument. | |
double | ogdf::Math::radiansToDegrees (const double &angleInRadians) |
Converts an angle from radians to degrees. | |
template<typename T > | |
int | ogdf::Math::sgn (T val) |
Returns +1 for val > 0, 0 for val = 0, and -1 for val < 0. | |
template<class Container > | |
double | ogdf::Math::standardDeviation (const Container &values) |
Returns the standard deviation of an iterable container of given values . | |
template<class Container > | |
double | ogdf::Math::standardDeviation (const Container &values, double mean) |
Returns the standard deviation of an iterable container of given values . | |
template<class Container > | |
Container::value_type | ogdf::Math::sum (const Container &values) |
Returns the sum of an iterable container of given values . | |
template<typename T > | |
void | ogdf::Math::updateMax (T &max, const T &newValue) |
Stores the maximum of max and newValue in max . | |
template<typename T > | |
void | ogdf::Math::updateMin (T &min, const T &newValue) |
Stores the minimum of min and newValue in min . | |
Variables | |
constexpr double | ogdf::Math::gamma = 0.57721566490153286061 |
The Euler-Mascheroni constant gamma. | |
const double | ogdf::Math::log_of_4 = log(4.0) |
The constant log(4.0). | |
constexpr double | ogdf::Math::one_rad = 57.29577951308232087679 |
The constant \(\frac{180}{\pi}\). | |
constexpr double | ogdf::Math::pi = 3.14159265358979323846 |
The constant \(\pi\). | |
constexpr double | ogdf::Math::pi_180 = 0.01745329251994329576 |
The constant \(\frac{\pi}{180}\). | |
constexpr double | ogdf::Math::pi_2 = 1.57079632679489661923 |
The constant \(\frac{\pi}{2}\). | |
Mathematical Helpers.
Definition in file Math.h.