46 static const double pi;
60 static inline T log2(T x) {
66 static inline double log4(
double x) {
68 return log(x) / log_of_4;
73 static inline int sgn(T val) {
74 return (T(0) < val) - (val < T(0));
78 static int binomial(
int n,
int k);
81 static double binomial_d(
int n,
int k);
85 static inline
int factorial(
int n)
87 return (
int) std::tgamma(n+1);
92 static inline
double factorial_d(
int n)
94 return std::tgamma(n+1);
98 static double harmonic(
unsigned n);
107 static inline
int floorLog2(
int v) {
111 return std::ilogb(v);
129 template<
class T,
class INDEX =
int>
131 T current_gcd = numbers[numbers.
low()];
132 for (INDEX i = numbers.
low()+1; i<=numbers.
high(); i++) {
133 current_gcd = gcd(current_gcd, numbers[i]);
147 static void getFraction(
double d,
int &num,
int &denom,
const double epsilon = 5e-10,
const int count = 10)
153 continuedFrac.
push(z);
156 while (d > epsilon && i++ < count) {
159 continuedFrac.
push(z);
166 while (!continuedFrac.
empty()) {
167 int last = continuedFrac.
pop();
static const double pi
The constant .
The parameterized class Array implements dynamic arrays of type E.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
INDEX high() const
Returns the maximal array index.
bool empty() const
Returns true iff the stack is empty.
Declaration and implementation of Array class and Array algorithms.
static void getFraction(double d, int &num, int &denom, const double epsilon=5e-10, const int count=10)
Converts a double to a fraction.
static const double log_of_4
The constant log(4.0).
E pop()
Removes the top-most element from the stack and returns it.
void push(const E &x)
Adds element x as top-most element to the stack.
static T gcd(T a, T b)
Returns the greatest common divisor of two numbers.
static T lcm(T a, T b)
Returns the least common multipler of two numbers.
Basic declarations, included by all source files.
static T gcd(const Array< T, INDEX > &numbers)
Returns the greatest common divisor of a list of numbers.
static int sgn(T val)
Returns +1 for val > 0, 0 for val = 0, and -1 for val < 0.
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
The namespace for all OGDF objects.
static const double pi_2
The constant .
static const double gamma
The Euler-Mascheroni constant gamma.
INDEX low() const
Returns the minimal array index.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
static double log4(double x)
Returns the logarithm of x to the base 4.
The parameterized class Stack<E> implements list-based stacks.
Declaration and implementation of list-based stacks (StackPure<E> and Stack<E>).