Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1#ifndef STORM_UTILITY_MATH_H_
2#define STORM_UTILITY_MATH_H_
3
4#include <cmath>
5
8
9namespace storm {
10namespace utility {
11namespace math {
12// We provide this method explicitly, because MSVC does not offer it (non-C99 compliant).
13template<typename ValueType>
14static inline double log2(ValueType number) {
15#ifndef WINDOWS
16 return std::log2(number);
17#else
18 return std::log(number) / std::log(2);
19#endif
20}
21
22inline uint64_t uint64_log2(uint64_t n) {
23 STORM_LOG_ASSERT(n != 0, "N is 0.");
24#define S(k) \
25 if (n >= (UINT64_C(1) << k)) { \
26 i += k; \
27 n >>= k; \
28 }
29 uint64_t i = 0;
30 S(32);
31 S(16);
32 S(8);
33 S(4);
34 S(2);
35 S(1);
36 return i;
37#undef S
38}
39} // namespace math
40} // namespace utility
41} // namespace storm
42
43#endif /* STORM_UTILITY_MATH_H_ */
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define S(k)
static double log2(ValueType number)
Definition math.h:14
uint64_t uint64_log2(uint64_t n)
Definition math.h:22
LabParser.cpp.
Definition cli.cpp:18