Lightmetrica  0.0.1.50dbee3 (yosakoi)
 All Classes Functions Variables Typedefs Enumerations Enumerator
math.common.h
1 /*
2  Lightmetrica : A research-oriented renderer
3 
4  Copyright (c) 2014 Hisanari Otsu
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 #ifndef LIB_LIGHTMETRICA_MATH_COMMON_H
22 #define LIB_LIGHTMETRICA_MATH_COMMON_H
23 
24 #include "common.h"
25 #include <cmath>
26 
27 #define LM_MATH_NAMESPACE_BEGIN namespace Math {
28 #define LM_MATH_NAMESPACE_END }
29 
30 // Precision mode
31 #ifdef LM_USE_SINGLE_PRECISION
32  #define LM_SINGLE_PRECISION 1
33 #else
34  #define LM_SINGLE_PRECISION 0
35 #endif
36 #ifdef LM_USE_DOUBLE_PRECISION
37  #define LM_DOUBLE_PRECISION 1
38 #else
39  #define LM_DOUBLE_PRECISION 0
40 #endif
41 #ifdef LM_USE_MULTI_PRECISION
42  #define LM_MULTI_PRECISION 1
43 #else
44  #define LM_MULTI_PRECISION 0
45 #endif
46 #if LM_SINGLE_PRECISION + LM_DOUBLE_PRECISION + LM_MULTI_PRECISION != 1
47  #error "Invalid precision mode"
48 #endif
49 
50 // Multiprecision support
51 // Note that the multiprecision support can be enabled irrelevant to
52 // the macro LM_MULTI_PRECISION for testing.
53 #ifdef LM_ENABLE_MULTI_PRECISION
54  #include <boost/multiprecision/cpp_dec_float.hpp>
55  #ifndef LM_PRECISION_NUM
56  // Default precision : 50 decimal digits
57  #define LM_PRECISION_NUM 50
58  #endif
59  LM_NAMESPACE_BEGIN
60  LM_MATH_NAMESPACE_BEGIN
61  #ifdef LM_ENABLE_MULTI_PRECISION
62  typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<LM_PRECISION_NUM>> BigFloat;
63  #endif
64  LM_MATH_NAMESPACE_END
65  LM_NAMESPACE_END
66 #endif
67 
68 #endif // LIB_LIGHTMETRICA_MATH_COMMON_H