GCC Code Coverage Report


Directory: src/gate/
File: src/gate/cxx_mathematics.cpp
Date: 2026-09-21 06:26:40
Exec Total Coverage
Lines: 129 149 86.6%
Functions: 63 72 87.5%
Branches: 2 4 50.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright (c) 2018-2026, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/mathematics.hpp"
30
31 #include "gate/mathematics.h"
32
33 namespace gate
34 {
35 namespace math
36 {
37 real64_t const PI = GATE_MATH_CONST_PI;
38 real64_t const E = GATE_MATH_CONST_E;
39
40
41 47 bool_t isZero(real32_t num)
42 {
43 47 return gate_math_iszerof(num);
44 }
45 58 bool_t isZero(real64_t num)
46 {
47 58 return gate_math_iszero(num);
48 }
49
50 1 bool_t isNan(real32_t num)
51 {
52 1 return gate_math_isnanf(num);
53 }
54 1 bool_t isNan(real64_t num)
55 {
56 1 return gate_math_isnan(num);
57 }
58
59 void buildNan(real32_t& num)
60 {
61 num = gate_math_build_nanf();
62 }
63
64 void buildNan(real64_t& num)
65 {
66 num = gate_math_build_nan();
67 }
68
69 1 bool_t isInfinite(real32_t num)
70 {
71 1 return gate_math_isinfinitef(num) != 0;
72 }
73 1 bool_t isInfinite(real64_t num)
74 {
75 1 return gate_math_isinfinite(num) != 0;
76 }
77
78 1 int signum(int8_t num)
79 {
80 1 return gate_math_signum_i8(num);
81 }
82 1 int signum(int16_t num)
83 {
84 1 return gate_math_signum_i16(num);
85 }
86 1 int signum(int32_t num)
87 {
88 1 return gate_math_signum_i32(num);
89 }
90 1 int signum(int64_t num)
91 {
92 1 return gate_math_signum_i64(num);
93 }
94 1 int signum(real32_t num)
95 {
96 1 return gate_math_signum_r32(num);
97 }
98 1 int signum(real64_t num)
99 {
100 1 return gate_math_signum_r64(num);
101 }
102
103 int8_t abs(int8_t num)
104 {
105 return gate_math_abs_i8(num);
106 }
107 int16_t abs(int16_t num)
108 {
109 return gate_math_abs_i16(num);
110 }
111 3 int32_t abs(int32_t num)
112 {
113 3 return gate_math_abs_i32(num);
114 }
115 int64_t abs(int64_t num)
116 {
117 return gate_math_abs_i64(num);
118 }
119 real32_t abs(real32_t num)
120 {
121 return gate_math_abs_r32(num);
122 }
123 1 real64_t abs(real64_t num)
124 {
125 1 return gate_math_abs_r64(num);
126 }
127
128
129 uint8_t decimal_length(real32_t num)
130 {
131 return gate_math_decimal_length(static_cast<real64_t>(num));
132 }
133 1 uint8_t decimal_length(real64_t num)
134 {
135 1 return gate_math_decimal_length(num);
136 }
137
138
139 1 real32_t cos(real32_t num)
140 {
141 1 return (real32_t)gate_math_cos(num);
142 }
143 7 real64_t cos(real64_t num)
144 {
145 7 return gate_math_cos(num);
146 }
147
148 1 real32_t sin(real32_t num)
149 {
150 1 return (real32_t)gate_math_sin(num);
151 }
152 1 real64_t sin(real64_t num)
153 {
154 1 return gate_math_sin(num);
155 }
156
157 1 real32_t tan(real32_t num)
158 {
159 1 return (real32_t)gate_math_tan(num);
160 }
161 1 real64_t tan(real64_t num)
162 {
163 1 return gate_math_tan(num);
164 }
165
166 1 real32_t acos(real32_t num)
167 {
168 1 return (real32_t)gate_math_acos(num);
169 }
170 1 real64_t acos(real64_t num)
171 {
172 1 return gate_math_acos(num);
173 }
174
175 1 real32_t asin(real32_t num)
176 {
177 1 return (real32_t)gate_math_asin(num);
178 }
179 1 real64_t asin(real64_t num)
180 {
181 1 return gate_math_asin(num);
182 }
183
184 1 real32_t atan(real32_t num)
185 {
186 1 return (real32_t)gate_math_atan(num);
187 }
188 1 real64_t atan(real64_t num)
189 {
190 1 return gate_math_atan(num);
191 }
192
193 1 real32_t atan2(real32_t y, real32_t x)
194 {
195 1 return (real32_t)gate_math_atan2(y, x);
196 }
197 1 real64_t atan2(real64_t y, real64_t x)
198 {
199 1 return gate_math_atan2(y, x);
200 }
201
202 1 real32_t cosh(real32_t num)
203 {
204 1 return (real32_t)gate_math_cosh(num);
205 }
206 1 real64_t cosh(real64_t num)
207 {
208 1 return gate_math_cosh(num);
209 }
210
211 1 real32_t sinh(real32_t num)
212 {
213 1 return (real32_t)gate_math_sinh(num);
214 }
215 1 real64_t sinh(real64_t num)
216 {
217 1 return gate_math_sinh(num);
218 }
219
220 1 real32_t tanh(real32_t num)
221 {
222 1 return (real32_t)gate_math_tanh(num);
223 }
224 1 real64_t tanh(real64_t num)
225 {
226 1 return gate_math_tanh(num);
227 }
228
229 1 real32_t acosh(real32_t num)
230 {
231 1 return (real32_t)gate_math_acosh(num);
232 }
233 1 real64_t acosh(real64_t num)
234 {
235 1 return gate_math_acosh(num);
236 }
237
238 1 real32_t asinh(real32_t num)
239 {
240 1 return (real32_t)gate_math_asinh(num);
241 }
242 1 real64_t asinh(real64_t num)
243 {
244 1 return gate_math_asinh(num);
245 }
246
247 1 real32_t atanh(real32_t num)
248 {
249 1 return (real32_t)gate_math_atanh(num);
250 }
251 1 real64_t atanh(real64_t num)
252 {
253 1 return gate_math_atanh(num);
254 }
255
256 1 real32_t exp(real32_t num)
257 {
258 1 return (real32_t)gate_math_exp(num);
259 }
260 1 real64_t exp(real64_t num)
261 {
262 1 return gate_math_exp(num);
263 }
264
265 1 real32_t frexp(real32_t num, int* exp)
266 {
267 1 return (real32_t)gate_math_frexp(num, exp);
268 }
269 1 real64_t frexp(real64_t num, int* exp)
270 {
271 1 return gate_math_frexp(num, exp);
272 }
273
274 real32_t ldexp(real32_t num, int exp)
275 {
276 return (real32_t)gate_math_ldexp(num, exp);
277 }
278 real64_t ldexp(real64_t num, int exp)
279 {
280 return gate_math_ldexp(num, exp);
281 }
282
283 1 real32_t log(real32_t num)
284 {
285 1 return (real32_t)gate_math_log(num);
286 }
287 1 real64_t log(real64_t num)
288 {
289 1 return gate_math_log(num);
290 }
291
292 1 real32_t log10(real32_t num)
293 {
294 1 return (real32_t)gate_math_log10(num);
295 }
296 1 real64_t log10(real64_t num)
297 {
298 1 return gate_math_log10(num);
299 }
300
301 1 real32_t modf(real32_t num, real32_t* exp)
302 {
303 1 real64_t exp64 = 0.0;
304
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 real64_t ret = gate_math_modf(num, &exp64);
305
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (exp) *exp = (real32_t)exp64;
306 1 return (real32_t)ret;
307 }
308 1 real64_t modf(real64_t num, real64_t* exp)
309 {
310 1 return gate_math_modf(num, exp);
311 }
312
313 1 real32_t pow(real32_t num, real32_t exp)
314 {
315 1 return (real32_t)gate_math_pow(num, exp);
316 }
317 1 real64_t pow(real64_t num, real64_t exp)
318 {
319 1 return gate_math_pow(num, exp);
320 }
321
322 1 real32_t sqrt(real32_t num)
323 {
324 1 return (real32_t)gate_math_sqrt(num);
325 }
326 1 real64_t sqrt(real64_t num)
327 {
328 1 return gate_math_sqrt(num);
329 }
330
331
332 1 real32_t ceil(real32_t num)
333 {
334 1 return (real32_t)gate_math_ceil(num);
335 }
336 1 real64_t ceil(real64_t num)
337 {
338 1 return gate_math_ceil(num);
339 }
340
341 1 real32_t floor(real32_t num)
342 {
343 1 return (real32_t)gate_math_floor(num);
344 }
345 1 real64_t floor(real64_t num)
346 {
347 1 return gate_math_floor(num);
348 }
349 1 real32_t deg2rad(real32_t num)
350 {
351 1 return (real32_t)gate_math_deg2rad(num);
352 }
353 3 real64_t deg2rad(real64_t num)
354 {
355 3 return gate_math_deg2rad(num);
356 }
357
358 1 real32_t rad2deg(real32_t num)
359 {
360 1 return (real32_t)gate_math_rad2deg(num);
361 }
362 1 real64_t rad2deg(real64_t num)
363 {
364 1 return gate_math_rad2deg(num);
365 }
366
367
368
369 } // end of namespace math
370
371 } // end of namespace gate
372