# OpenGraph DrawingFramework

v. 2023.09 (Elderberry)

Searching...
No Matches
ogdf::Math Namespace Reference

## Namespaces

namespace  internal

## Functions

int binomial (int n, int k)
Returns $$n \choose k$$.

double binomial_d (int n, int k)
Returns $$n \choose k$$.

Converts an angle from degrees to radians.

int factorial (int n)
Returns n!.

double factorial_d (int n)
Returns n!.

int floorLog2 (int v)
A method to obtain the rounded down binary logarithm of v.

template<class T , class INDEX = int>
gcd (const Array< T, INDEX > &numbers)
Returns the greatest common divisor of a list of numbers.

template<typename T >
gcd (T a, T b)
Returns the greatest common divisor of two numbers.

void getFraction (double d, int &num, int &denom, const double epsilon=5e-10, const int count=10)
Converts a double to a fraction.

double harmonic (unsigned n)
Returns the n-th harmonic number or 1.0 if n < 1.

template<typename T >
lcm (T a, T b)
Returns the least common multipler of two numbers.

template<typename T >
log2 (T x)
Returns the logarithm of x to the base 2.

double log4 (double x)
Returns the logarithm of x to the base 4.

template<class Container >
Container::value_type maxValue (const Container &values)
Returns the maximum of an iterable container of given values.

template<class Container >
double mean (const Container &values)
Returns the mean of an iterable container of given values.

template<class Container >
Container::value_type minValue (const Container &values)
Returns the minimum of an iterable container of given values.

template<typename T , typename... Args>
staticnextPower2 (T arg1, T arg2, Args... args)
Returns the smallest power of 2 that is no less than the given (integral) arguments.

template<typename T >
nextPower2 (T x)
Returns the smallest power of 2 that is no less than the given (integral) argument.

Converts an angle from radians to degrees.

template<typename T >
int sgn (T val)
Returns +1 for val > 0, 0 for val = 0, and -1 for val < 0.

template<class Container >
double standardDeviation (const Container &values)
Returns the standard deviation of an iterable container of given values.

template<class Container >
double standardDeviation (const Container &values, double mean)
Returns the standard deviation of an iterable container of given values.

template<class Container >
Container::value_type sum (const Container &values)
Returns the sum of an iterable container of given values.

template<typename T >
void updateMax (T &max, const T &newValue)
Stores the maximum of max and newValue in max.

template<typename T >
void updateMin (T &min, const T &newValue)
Stores the minimum of min and newValue in min.

## Variables

constexpr double gamma = 0.57721566490153286061
The Euler-Mascheroni constant gamma.

const double log_of_4 = log(4.0)
The constant log(4.0).

The constant $$\frac{180}{\pi}$$.

constexpr double pi = 3.14159265358979323846
The constant $$\pi$$.

constexpr double pi_180 = 0.01745329251994329576
The constant $$\frac{\pi}{180}$$.

constexpr double pi_2 = 1.57079632679489661923
The constant $$\frac{\pi}{2}$$.

## ◆ binomial()

 int ogdf::Math::binomial ( int n, int k )

Returns $$n \choose k$$.

## ◆ binomial_d()

 double ogdf::Math::binomial_d ( int n, int k )

Returns $$n \choose k$$.

 double ogdf::Math::degreesToRadians ( const double & angleInDegrees )
inline

Converts an angle from degrees to radians.

Definition at line 125 of file Math.h.

## ◆ factorial()

 int ogdf::Math::factorial ( int n )
inline

Returns n!.

Deprecated:
"Use std::tgamma(n+1)."

Definition at line 143 of file Math.h.

## ◆ factorial_d()

 double ogdf::Math::factorial_d ( int n )
inline

Returns n!.

Deprecated:
"Use std::tgamma(n+1)."

Definition at line 148 of file Math.h.

## ◆ floorLog2()

 int ogdf::Math::floorLog2 ( int v )
inline

A method to obtain the rounded down binary logarithm of v.

Parameters
 v The number of which the binary logarithm is to be determined
Returns
The rounded down logarithm base 2 if v is positive, -1 otherwise
Deprecated:
"Use std::ilogb(v)."

Definition at line 161 of file Math.h.

## ◆ gcd() [1/2]

template<class T , class INDEX = int>
 T ogdf::Math::gcd ( const Array< T, INDEX > & numbers )
inline

Returns the greatest common divisor of a list of numbers.

Definition at line 183 of file Math.h.

## ◆ gcd() [2/2]

template<typename T >
 T ogdf::Math::gcd ( T a, T b )
inline

Returns the greatest common divisor of two numbers.

Definition at line 171 of file Math.h.

## ◆ getFraction()

 void ogdf::Math::getFraction ( double d, int & num, int & denom, const double epsilon = 5e-10, const int count = 10 )
inline

Converts a double to a fraction.

Definition at line 200 of file Math.h.

## ◆ harmonic()

 double ogdf::Math::harmonic ( unsigned n )

Returns the n-th harmonic number or 1.0 if n < 1.

## ◆ lcm()

template<typename T >
 T ogdf::Math::lcm ( T a, T b )
inline

Returns the least common multipler of two numbers.

Definition at line 193 of file Math.h.

## ◆ log2()

template<typename T >
 T ogdf::Math::log2 ( T x )
inline

Returns the logarithm of x to the base 2.

Deprecated:
"Use std::log2(x)."

Definition at line 107 of file Math.h.

## ◆ log4()

 double ogdf::Math::log4 ( double x )
inline

Returns the logarithm of x to the base 4.

Definition at line 113 of file Math.h.

## ◆ maxValue()

template<class Container >
 Container::value_type ogdf::Math::maxValue ( const Container & values )
inline

Returns the maximum of an iterable container of given values.

Definition at line 235 of file Math.h.

## ◆ mean()

template<class Container >
 double ogdf::Math::mean ( const Container & values )
inline

Returns the mean of an iterable container of given values.

Definition at line 249 of file Math.h.

## ◆ minValue()

template<class Container >
 Container::value_type ogdf::Math::minValue ( const Container & values )
inline

Returns the minimum of an iterable container of given values.

Definition at line 228 of file Math.h.

## ◆ nextPower2() [1/2]

template<typename T , typename... Args>
 static T ogdf::Math::nextPower2 ( T arg1, T arg2, Args... args )
inlinestatic

Returns the smallest power of 2 that is no less than the given (integral) arguments.

Definition at line 84 of file Math.h.

## ◆ nextPower2() [2/2]

template<typename T >
 T ogdf::Math::nextPower2 ( T x )
inline

Returns the smallest power of 2 that is no less than the given (integral) argument.

Definition at line 78 of file Math.h.

inline

Converts an angle from radians to degrees.

Definition at line 130 of file Math.h.

## ◆ sgn()

template<typename T >
 int ogdf::Math::sgn ( T val )
inline

Returns +1 for val > 0, 0 for val = 0, and -1 for val < 0.

Definition at line 120 of file Math.h.

## ◆ standardDeviation() [1/2]

template<class Container >
 double ogdf::Math::standardDeviation ( const Container & values )
inline

Returns the standard deviation of an iterable container of given values.

Definition at line 269 of file Math.h.

## ◆ standardDeviation() [2/2]

template<class Container >
 double ogdf::Math::standardDeviation ( const Container & values, double mean )
inline

Returns the standard deviation of an iterable container of given values.

The given mean is used instead of computing a new one.

Definition at line 257 of file Math.h.

## ◆ sum()

template<class Container >
 Container::value_type ogdf::Math::sum ( const Container & values )
inline

Returns the sum of an iterable container of given values.

Definition at line 242 of file Math.h.

## ◆ updateMax()

template<typename T >
 void ogdf::Math::updateMax ( T & max, const T & newValue )
inline

Stores the maximum of max and newValue in max.

Definition at line 90 of file Math.h.

## ◆ updateMin()

template<typename T >
 void ogdf::Math::updateMin ( T & min, const T & newValue )
inline

Stores the minimum of min and newValue in min.

Definition at line 98 of file Math.h.

## ◆ gamma

 constexpr double ogdf::Math::gamma = 0.57721566490153286061
constexpr

The Euler-Mascheroni constant gamma.

Definition at line 74 of file Math.h.

## ◆ log_of_4

 const double ogdf::Math::log_of_4 = log(4.0)

The constant log(4.0).

Definition at line 71 of file Math.h.

constexpr

The constant $$\frac{180}{\pi}$$.

Definition at line 68 of file Math.h.

## ◆ pi

 constexpr double ogdf::Math::pi = 3.14159265358979323846
constexpr

The constant $$\pi$$.

Definition at line 59 of file Math.h.

## ◆ pi_180

 constexpr double ogdf::Math::pi_180 = 0.01745329251994329576
constexpr

The constant $$\frac{\pi}{180}$$.

Definition at line 65 of file Math.h.

## ◆ pi_2

 constexpr double ogdf::Math::pi_2 = 1.57079632679489661923
constexpr

The constant $$\frac{\pi}{2}$$.

Definition at line 62 of file Math.h.