Mathematical Helpers. More...
#include <ogdf/basic/Array.h>
#include <ogdf/basic/ArrayBuffer.h>
#include <ogdf/basic/basic.h>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <utility>
Go to the source code of this file.
Namespaces | |
ogdf | |
The namespace for all OGDF objects. | |
ogdf::Math | |
ogdf::Math::internal | |
Functions | |
int | ogdf::Math::binomial (int n, int k) |
Returns \(n \choose k\). More... | |
double | ogdf::Math::binomial_d (int n, int k) |
Returns \(n \choose k\). More... | |
double | ogdf::Math::degreesToRadians (const double &angleInDegrees) |
Converts an angle from degrees to radians. More... | |
int | ogdf::Math::factorial (int n) |
Returns n! . More... | |
double | ogdf::Math::factorial_d (int n) |
Returns n! . More... | |
int | ogdf::Math::floorLog2 (int v) |
A method to obtain the rounded down binary logarithm of v . More... | |
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. More... | |
template<typename T > | |
T | ogdf::Math::gcd (T a, T b) |
Returns the greatest common divisor of two numbers. More... | |
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. More... | |
double | ogdf::Math::harmonic (unsigned n) |
Returns the n-th harmonic number or 1.0 if n < 1. More... | |
template<typename T > | |
T | ogdf::Math::lcm (T a, T b) |
Returns the least common multipler of two numbers. More... | |
template<typename T > | |
T | ogdf::Math::log2 (T x) |
Returns the logarithm of x to the base 2. More... | |
double | ogdf::Math::log4 (double x) |
Returns the logarithm of x to the base 4. More... | |
template<class Container > | |
Container::value_type | ogdf::Math::maxValue (const Container &values) |
Returns the maximum of an iterable container of given values . More... | |
template<class Container > | |
double | ogdf::Math::mean (const Container &values) |
Returns the mean of an iterable container of given values . More... | |
template<class Container > | |
Container::value_type | ogdf::Math::minValue (const Container &values) |
Returns the minimum of an iterable container of given values . More... | |
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. More... | |
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. More... | |
template<typename T > | |
T | ogdf::Math::nextPower2 (T x) |
Returns the smallest power of 2 that is no less than the given (integral) argument. More... | |
double | ogdf::Math::radiansToDegrees (const double &angleInRadians) |
Converts an angle from radians to degrees. More... | |
template<typename T > | |
int | ogdf::Math::sgn (T val) |
Returns +1 for val > 0, 0 for val = 0, and -1 for val < 0. More... | |
template<class Container > | |
double | ogdf::Math::standardDeviation (const Container &values) |
Returns the standard deviation of an iterable container of given values . More... | |
template<class Container > | |
double | ogdf::Math::standardDeviation (const Container &values, double mean) |
Returns the standard deviation of an iterable container of given values . More... | |
template<class Container > | |
Container::value_type | ogdf::Math::sum (const Container &values) |
Returns the sum of an iterable container of given values . More... | |
template<typename T > | |
void | ogdf::Math::updateMax (T &max, const T &newValue) |
Stores the maximum of max and newValue in max . More... | |
template<typename T > | |
void | ogdf::Math::updateMin (T &min, const T &newValue) |
Stores the minimum of min and newValue in min . More... | |
Variables | |
constexpr double | ogdf::Math::gamma = 0.57721566490153286061 |
The Euler-Mascheroni constant gamma. More... | |
const double | ogdf::Math::log_of_4 = log(4.0) |
The constant log(4.0). More... | |
constexpr double | ogdf::Math::one_rad = 57.29577951308232087679 |
The constant \(\frac{180}{\pi}\). More... | |
constexpr double | ogdf::Math::pi = 3.14159265358979323846 |
The constant \(\pi\). More... | |
constexpr double | ogdf::Math::pi_180 = 0.01745329251994329576 |
The constant \(\frac{\pi}{180}\). More... | |
constexpr double | ogdf::Math::pi_2 = 1.57079632679489661923 |
The constant \(\frac{\pi}{2}\). More... | |
Mathematical Helpers.
Definition in file Math.h.