liballofw
basic.h
Go to the documentation of this file.
1 #ifndef IV_MATH_BASIC_H
2 #define IV_MATH_BASIC_H
3 
4 #include "../common.h"
5 #include <cmath>
6 #include <limits>
7 
8 namespace allofw {
9 
10  const double PI = 3.1415926535897932384626433832795028841971693993751;
11  const double E = 2.7182818284590452353602874713526624977572470937000;
12  const double NaN = std::numeric_limits<double>::quiet_NaN();
13  const double Infinity = std::numeric_limits<double>::infinity();
14 
15  using std::isnan;
16 
18  template<typename number_t>
19  inline number_t min(number_t a, number_t b) { return a < b ? a : b; }
20 
22  template<typename number_t>
23  inline number_t max(number_t a, number_t b) { return a > b ? a : b; }
24 
26  template<typename number_t>
27  inline number_t abs(number_t a) { return a > 0 ? a : -a; }
28 
30  template<typename number_t>
31  inline number_t sign(number_t a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }
32 
33 }
34 
35 #endif
number_t max(number_t a, number_t b)
Compute maximum.
Definition: basic.h:23
const double E
Definition: basic.h:11
Definition: allofw.h:12
const double Infinity
Definition: basic.h:13
number_t sign(number_t a)
Compute sign of a number.
Definition: basic.h:31
bool isnan(const Vector2_< T > &v)
Definition: vector.h:181
number_t abs(number_t a)
Compute absolute value.
Definition: basic.h:27
const double NaN
Definition: basic.h:12
const double PI
Definition: basic.h:10
number_t min(number_t a, number_t b)
Compute minimum.
Definition: basic.h:19