WPILibC++ 2024.3.2
gcem_options.hpp
Go to the documentation of this file.
1/*################################################################################
2 ##
3 ## Copyright (C) 2016-2023 Keith O'Hara
4 ##
5 ## This file is part of the GCE-Math C++ library.
6 ##
7 ## Licensed under the Apache License, Version 2.0 (the "License");
8 ## you may not use this file except in compliance with the License.
9 ## You may obtain a copy of the License at
10 ##
11 ## http://www.apache.org/licenses/LICENSE-2.0
12 ##
13 ## Unless required by applicable law or agreed to in writing, software
14 ## distributed under the License is distributed on an "AS IS" BASIS,
15 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 ## See the License for the specific language governing permissions and
17 ## limitations under the License.
18 ##
19 ################################################################################*/
20
21#include <cstddef> // size_t
22#include <limits>
23#include <type_traits>
24
25// undef some functions from math.h
26// see issue #29
27
28#ifdef abs
29 #undef abs
30#endif
31
32#ifdef min
33 #undef min
34#endif
35
36#ifdef max
37 #undef max
38#endif
39
40#ifdef round
41 #undef round
42#endif
43
44#ifdef signbit
45 #undef signbit
46#endif
47
48//
49// version
50
51#ifndef GCEM_VERSION_MAJOR
52 #define GCEM_VERSION_MAJOR 1
53#endif
54
55#ifndef GCEM_VERSION_MINOR
56 #define GCEM_VERSION_MINOR 17
57#endif
58
59#ifndef GCEM_VERSION_PATCH
60 #define GCEM_VERSION_PATCH 0
61#endif
62
63//
64// types
65
66namespace gcem
67{
68 using uint_t = unsigned int;
69 using ullint_t = unsigned long long int;
70
71 using llint_t = long long int;
72
73 template<class T>
74 using GCLIM = std::numeric_limits<T>;
75
76 template<typename T>
77 using return_t = typename std::conditional<std::is_integral<T>::value,double,T>::type;
78
79 template<typename ...T>
80 using common_t = typename std::common_type<T...>::type;
81
82 template<typename ...T>
84}
85
86//
87// constants
88
89#ifndef GCEM_LOG_2
90 #define GCEM_LOG_2 0.6931471805599453094172321214581765680755L
91#endif
92
93#ifndef GCEM_LOG_10
94 #define GCEM_LOG_10 2.3025850929940456840179914546843642076011L
95#endif
96
97#ifndef GCEM_PI
98 #define GCEM_PI 3.1415926535897932384626433832795028841972L
99#endif
100
101#ifndef GCEM_LOG_PI
102 #define GCEM_LOG_PI 1.1447298858494001741434273513530587116473L
103#endif
104
105#ifndef GCEM_LOG_2PI
106 #define GCEM_LOG_2PI 1.8378770664093454835606594728112352797228L
107#endif
108
109#ifndef GCEM_LOG_SQRT_2PI
110 #define GCEM_LOG_SQRT_2PI 0.9189385332046727417803297364056176398614L
111#endif
112
113#ifndef GCEM_SQRT_2
114 #define GCEM_SQRT_2 1.4142135623730950488016887242096980785697L
115#endif
116
117#ifndef GCEM_HALF_PI
118 #define GCEM_HALF_PI 1.5707963267948966192313216916397514420986L
119#endif
120
121#ifndef GCEM_SQRT_PI
122 #define GCEM_SQRT_PI 1.7724538509055160272981674833411451827975L
123#endif
124
125#ifndef GCEM_SQRT_HALF_PI
126 #define GCEM_SQRT_HALF_PI 1.2533141373155002512078826424055226265035L
127#endif
128
129#ifndef GCEM_E
130 #define GCEM_E 2.7182818284590452353602874713526624977572L
131#endif
132
133//
134// convergence settings
135
136#ifndef GCEM_ERF_MAX_ITER
137 #define GCEM_ERF_MAX_ITER 60
138#endif
139
140#ifndef GCEM_ERF_INV_MAX_ITER
141 #define GCEM_ERF_INV_MAX_ITER 60
142#endif
143
144#ifndef GCEM_EXP_MAX_ITER_SMALL
145 #define GCEM_EXP_MAX_ITER_SMALL 25
146#endif
147
148// #ifndef GCEM_LOG_TOL
149// #define GCEM_LOG_TOL 1E-14
150// #endif
151
152#ifndef GCEM_LOG_MAX_ITER_SMALL
153 #define GCEM_LOG_MAX_ITER_SMALL 25
154#endif
155
156#ifndef GCEM_LOG_MAX_ITER_BIG
157 #define GCEM_LOG_MAX_ITER_BIG 255
158#endif
159
160#ifndef GCEM_INCML_BETA_TOL
161 #define GCEM_INCML_BETA_TOL 1E-15
162#endif
163
164#ifndef GCEM_INCML_BETA_MAX_ITER
165 #define GCEM_INCML_BETA_MAX_ITER 205
166#endif
167
168#ifndef GCEM_INCML_BETA_INV_MAX_ITER
169 #define GCEM_INCML_BETA_INV_MAX_ITER 35
170#endif
171
172#ifndef GCEM_INCML_GAMMA_MAX_ITER
173 #define GCEM_INCML_GAMMA_MAX_ITER 55
174#endif
175
176#ifndef GCEM_INCML_GAMMA_INV_MAX_ITER
177 #define GCEM_INCML_GAMMA_INV_MAX_ITER 35
178#endif
179
180#ifndef GCEM_SQRT_MAX_ITER
181 #define GCEM_SQRT_MAX_ITER 100
182#endif
183
184#ifndef GCEM_INV_SQRT_MAX_ITER
185 #define GCEM_INV_SQRT_MAX_ITER 100
186#endif
187
188#ifndef GCEM_TAN_MAX_ITER
189 #define GCEM_TAN_MAX_ITER 35
190#endif
191
192#ifndef GCEM_TANH_MAX_ITER
193 #define GCEM_TANH_MAX_ITER 35
194#endif
195
196//
197// Macros
198
199#ifdef _MSC_VER
200 #ifndef GCEM_SIGNBIT
201 #define GCEM_SIGNBIT(x) _signbit(x)
202 #endif
203 #ifndef GCEM_COPYSIGN
204 #define GCEM_COPYSIGN(x,y) _copysign(x,y)
205 #endif
206#else
207 #ifndef GCEM_SIGNBIT
208 #define GCEM_SIGNBIT(x) __builtin_signbit(x)
209 #endif
210 #ifndef GCEM_COPYSIGN
211 #define GCEM_COPYSIGN(x,y) __builtin_copysign(x,y)
212 #endif
213#endif
type
Definition: core.h:556
Definition: is_even.hpp:29
unsigned long long int ullint_t
Definition: gcem_options.hpp:69
long long int llint_t
Definition: gcem_options.hpp:71
return_t< common_t< T... > > common_return_t
Definition: gcem_options.hpp:83
std::numeric_limits< T > GCLIM
Definition: gcem_options.hpp:74
typename std::common_type< T... >::type common_t
Definition: gcem_options.hpp:80
unsigned int uint_t
Definition: gcem_options.hpp:68
typename std::conditional< std::is_integral< T >::value, double, T >::type return_t
Definition: gcem_options.hpp:77