Open
Graph Drawing
Framework
v.2012.07
Overview
Class Hierarchy
Class Index
Class List
Members
Namespaces
Source Files
Math.h
Go to the documentation of this file.
1
/*
2
* $Revision: 2523 $
3
*
4
* last checkin:
5
* $Author: gutwenger $
6
* $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7
***************************************************************/
8
43
#ifndef OGDF_MATH_H
44
#define OGDF_MATH_H
45
46
#include <
ogdf/basic/basic.h
>
47
#include <
math.h
>
48
49
namespace
ogdf {
50
51
52
//#define DOUBLE_EPS 0.000001
53
54
55
class
OGDF_EXPORT
Math
{
56
57
public
:
59
static
const
double
pi
;
60
62
static
const
double
pi_2
;
63
65
static
const
double
pi_4
;
66
68
static
const
double
two_pi
;
69
71
static
const
double
e
;
72
74
static
const
double
log_of_2
;
75
77
static
const
double
log_of_4
;
78
80
static
double
log2
(
double
x) {
81
OGDF_ASSERT
(x >= 0)
82
return
log(x) / log_of_2;
83
}
84
86
static
double
log4
(
double
x) {
87
OGDF_ASSERT
(x >= 0)
88
return
log(x) / log_of_4;
89
}
90
92
static
int
binomial(
int
n,
int
k);
93
95
static
double
binomial_d(
int
n,
int
k);
96
98
static
int
factorial(
int
n);
99
101
static
double
factorial_d(
int
n);
102
103
//static bool equald(double a, double b) {
104
// double d = a-b;
105
// return d < DOUBLE_EPS && d > -DOUBLE_EPS;
106
//}
107
115
static
int
floorLog2
(
int
v) {
116
if
(v <= 0) {
117
return
-1;
118
}
else
{
119
int
result = 0;
120
if
(v >= (1 << 16)) {
121
v >>= 16;
122
result += 16;
123
}
124
if
(v >= (1 << 8)) {
125
v >>= 8;
126
result += 8;
127
}
128
if
(v >= (1 << 4)) {
129
v >>= 4;
130
result += 4;
131
}
132
if
(v >= (1 << 2)) {
133
v >>= 2;
134
result += 2;
135
}
136
if
(v >= (1 << 1)) {
137
result += 1;
138
}
139
return
result;
140
}
141
}
142
};
143
144
145
}
146
147
#endif // OGDF_MATH_H
ogdf
basic
Math.h
© 1999-2012 by
TU Dortmund
,
University of Jena
,
University of Cologne
,
University of Sydney
,
oreas GmbH