GCC Code Coverage Report


Directory: src/gate/
File: src/gate/cxx_mathematics.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 129 143 90.2%
Functions: 63 70 90.0%
Branches: 2 4 50.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, 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 30 bool_t isZero(real32_t num)
42 {
43 30 return gate_math_iszerof(num);
44 }
45 57 bool_t isZero(real64_t num)
46 {
47 57 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 1 bool_t isInfinite(real32_t num)
60 {
61 1 return gate_math_isinfinitef(num) != 0;
62 }
63 1 bool_t isInfinite(real64_t num)
64 {
65 1 return gate_math_isinfinite(num) != 0;
66 }
67
68 1 int signum(int8_t num)
69 {
70 1 return gate_math_signum_i8(num);
71 }
72 1 int signum(int16_t num)
73 {
74 1 return gate_math_signum_i16(num);
75 }
76 1 int signum(int32_t num)
77 {
78 1 return gate_math_signum_i32(num);
79 }
80 1 int signum(int64_t num)
81 {
82 1 return gate_math_signum_i64(num);
83 }
84 1 int signum(real32_t num)
85 {
86 1 return gate_math_signum_r32(num);
87 }
88 1 int signum(real64_t num)
89 {
90 1 return gate_math_signum_r64(num);
91 }
92
93 int8_t abs(int8_t num)
94 {
95 return gate_math_abs_i8(num);
96 }
97 int16_t abs(int16_t num)
98 {
99 return gate_math_abs_i16(num);
100 }
101 3 int32_t abs(int32_t num)
102 {
103 3 return gate_math_abs_i32(num);
104 }
105 int64_t abs(int64_t num)
106 {
107 return gate_math_abs_i64(num);
108 }
109 real32_t abs(real32_t num)
110 {
111 return gate_math_abs_r32(num);
112 }
113 1 real64_t abs(real64_t num)
114 {
115 1 return gate_math_abs_r64(num);
116 }
117
118
119 real32_t decimal_length(real32_t num)
120 {
121 return static_cast<real32_t>(gate_math_decimal_length(static_cast<real64_t>(num)));
122 }
123 1 real64_t decimal_length(real64_t num)
124 {
125 1 return gate_math_decimal_length(num);
126 }
127
128
129 1 real32_t cos(real32_t num)
130 {
131 1 return (real32_t)gate_math_cos(num);
132 }
133 7 real64_t cos(real64_t num)
134 {
135 7 return gate_math_cos(num);
136 }
137
138 1 real32_t sin(real32_t num)
139 {
140 1 return (real32_t)gate_math_sin(num);
141 }
142 1 real64_t sin(real64_t num)
143 {
144 1 return gate_math_sin(num);
145 }
146
147 1 real32_t tan(real32_t num)
148 {
149 1 return (real32_t)gate_math_tan(num);
150 }
151 1 real64_t tan(real64_t num)
152 {
153 1 return gate_math_tan(num);
154 }
155
156 1 real32_t acos(real32_t num)
157 {
158 1 return (real32_t)gate_math_acos(num);
159 }
160 1 real64_t acos(real64_t num)
161 {
162 1 return gate_math_acos(num);
163 }
164
165 1 real32_t asin(real32_t num)
166 {
167 1 return (real32_t)gate_math_asin(num);
168 }
169 1 real64_t asin(real64_t num)
170 {
171 1 return gate_math_asin(num);
172 }
173
174 1 real32_t atan(real32_t num)
175 {
176 1 return (real32_t)gate_math_atan(num);
177 }
178 1 real64_t atan(real64_t num)
179 {
180 1 return gate_math_atan(num);
181 }
182
183 1 real32_t atan2(real32_t y, real32_t x)
184 {
185 1 return (real32_t)gate_math_atan2(y, x);
186 }
187 1 real64_t atan2(real64_t y, real64_t x)
188 {
189 1 return gate_math_atan2(y, x);
190 }
191
192 1 real32_t cosh(real32_t num)
193 {
194 1 return (real32_t)gate_math_cosh(num);
195 }
196 1 real64_t cosh(real64_t num)
197 {
198 1 return gate_math_cosh(num);
199 }
200
201 1 real32_t sinh(real32_t num)
202 {
203 1 return (real32_t)gate_math_sinh(num);
204 }
205 1 real64_t sinh(real64_t num)
206 {
207 1 return gate_math_sinh(num);
208 }
209
210 1 real32_t tanh(real32_t num)
211 {
212 1 return (real32_t)gate_math_tanh(num);
213 }
214 1 real64_t tanh(real64_t num)
215 {
216 1 return gate_math_tanh(num);
217 }
218
219 1 real32_t acosh(real32_t num)
220 {
221 1 return (real32_t)gate_math_acosh(num);
222 }
223 1 real64_t acosh(real64_t num)
224 {
225 1 return gate_math_acosh(num);
226 }
227
228 1 real32_t asinh(real32_t num)
229 {
230 1 return (real32_t)gate_math_asinh(num);
231 }
232 1 real64_t asinh(real64_t num)
233 {
234 1 return gate_math_asinh(num);
235 }
236
237 1 real32_t atanh(real32_t num)
238 {
239 1 return (real32_t)gate_math_atanh(num);
240 }
241 1 real64_t atanh(real64_t num)
242 {
243 1 return gate_math_atanh(num);
244 }
245
246 1 real32_t exp(real32_t num)
247 {
248 1 return (real32_t)gate_math_exp(num);
249 }
250 1 real64_t exp(real64_t num)
251 {
252 1 return gate_math_exp(num);
253 }
254
255 1 real32_t frexp(real32_t num, int* exp)
256 {
257 1 return (real32_t)gate_math_frexp(num, exp);
258 }
259 1 real64_t frexp(real64_t num, int* exp)
260 {
261 1 return gate_math_frexp(num, exp);
262 }
263
264 real32_t ldexp(real32_t num, int exp)
265 {
266 return (real32_t)gate_math_ldexp(num, exp);
267 }
268 real64_t ldexp(real64_t num, int exp)
269 {
270 return gate_math_ldexp(num, exp);
271 }
272
273 1 real32_t log(real32_t num)
274 {
275 1 return (real32_t)gate_math_log(num);
276 }
277 1 real64_t log(real64_t num)
278 {
279 1 return gate_math_log(num);
280 }
281
282 1 real32_t log10(real32_t num)
283 {
284 1 return (real32_t)gate_math_log10(num);
285 }
286 1 real64_t log10(real64_t num)
287 {
288 1 return gate_math_log10(num);
289 }
290
291 1 real32_t modf(real32_t num, real32_t* exp)
292 {
293 1 real64_t exp64 = 0.0;
294
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 real64_t ret = gate_math_modf(num, &exp64);
295
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (exp) *exp = (real32_t)exp64;
296 1 return (real32_t)ret;
297 }
298 1 real64_t modf(real64_t num, real64_t* exp)
299 {
300 1 return gate_math_modf(num, exp);
301 }
302
303 1 real32_t pow(real32_t num, real32_t exp)
304 {
305 1 return (real32_t)gate_math_pow(num, exp);
306 }
307 1 real64_t pow(real64_t num, real64_t exp)
308 {
309 1 return gate_math_pow(num, exp);
310 }
311
312 1 real32_t sqrt(real32_t num)
313 {
314 1 return (real32_t)gate_math_sqrt(num);
315 }
316 1 real64_t sqrt(real64_t num)
317 {
318 1 return gate_math_sqrt(num);
319 }
320
321
322 1 real32_t ceil(real32_t num)
323 {
324 1 return (real32_t)gate_math_ceil(num);
325 }
326 1 real64_t ceil(real64_t num)
327 {
328 1 return gate_math_ceil(num);
329 }
330
331 1 real32_t floor(real32_t num)
332 {
333 1 return (real32_t)gate_math_floor(num);
334 }
335 1 real64_t floor(real64_t num)
336 {
337 1 return gate_math_floor(num);
338 }
339 1 real32_t deg2rad(real32_t num)
340 {
341 1 return (real32_t)gate_math_deg2rad(num);
342 }
343 3 real64_t deg2rad(real64_t num)
344 {
345 3 return gate_math_deg2rad(num);
346 }
347
348 1 real32_t rad2deg(real32_t num)
349 {
350 1 return (real32_t)gate_math_rad2deg(num);
351 }
352 1 real64_t rad2deg(real64_t num)
353 {
354 1 return gate_math_rad2deg(num);
355 }
356
357
358
359 } // end of namespace math
360
361 } // end of namespace gate
362