Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | ****************************************************************** |
3 | | * C++ Mathematical Expression Toolkit Library * |
4 | | * * |
5 | | * Author: Arash Partow (1999-2023) * |
6 | | * URL: https://www.partow.net/programming/exprtk/index.html * |
7 | | * * |
8 | | * Copyright notice: * |
9 | | * Free use of the C++ Mathematical Expression Toolkit Library is * |
10 | | * permitted under the guidelines and in accordance with the most * |
11 | | * current version of the MIT License. * |
12 | | * https://www.opensource.org/licenses/MIT * |
13 | | * * |
14 | | * Example expressions: * |
15 | | * (00) (y + x / y) * (x - y / x) * |
16 | | * (01) (x^2 / sin(2 * pi / y)) - x / 2 * |
17 | | * (02) sqrt(1 - (x^2)) * |
18 | | * (03) 1 - sin(2 * x) + cos(pi / y) * |
19 | | * (04) a * exp(2 * t) + c * |
20 | | * (05) if(((x + 2) == 3) and ((y + 5) <= 9),1 + w, 2 / z) * |
21 | | * (06) (avg(x,y) <= x + y ? x - y : x * y) + 2 * pi / x * |
22 | | * (07) z := x + sin(2 * pi / y) * |
23 | | * (08) u := 2 * (pi * z) / (w := x + cos(y / pi)) * |
24 | | * (09) clamp(-1,sin(2 * pi * x) + cos(y / 2 * pi),+1) * |
25 | | * (10) inrange(-2,m,+2) == if(({-2 <= m} and [m <= +2]),1,0) * |
26 | | * (11) (2sin(x)cos(2y)7 + 1) == (2 * sin(x) * cos(2*y) * 7 + 1) * |
27 | | * (12) (x ilike 's*ri?g') and [y < (3 z^7 + w)] * |
28 | | * * |
29 | | ****************************************************************** |
30 | | */ |
31 | | |
32 | | |
33 | | #ifndef INCLUDE_EXPRTK_HPP |
34 | | #define INCLUDE_EXPRTK_HPP |
35 | | |
36 | | |
37 | | #include <algorithm> |
38 | | #include <cassert> |
39 | | #include <cctype> |
40 | | #include <cmath> |
41 | | #include <cstdio> |
42 | | #include <cstdlib> |
43 | | #include <cstring> |
44 | | #include <deque> |
45 | | #include <exception> |
46 | | #include <functional> |
47 | | #include <iterator> |
48 | | #include <limits> |
49 | | #include <list> |
50 | | #include <map> |
51 | | #include <set> |
52 | | #include <stack> |
53 | | #include <stdexcept> |
54 | | #include <string> |
55 | | #include <utility> |
56 | | #include <vector> |
57 | | |
58 | | |
59 | | namespace exprtk |
60 | | { |
61 | | #ifdef exprtk_enable_debugging |
62 | | #define exprtk_debug(params) printf params |
63 | | #else |
64 | 42.4M | #define exprtk_debug(params) (void)0 |
65 | | #endif |
66 | | |
67 | | #define exprtk_error_location \ |
68 | 183k | "exprtk.hpp:" + details::to_str(__LINE__) \ |
69 | | |
70 | | #if defined(__GNUC__) && (__GNUC__ >= 7) |
71 | | |
72 | | #define exprtk_disable_fallthrough_begin \ |
73 | | _Pragma ("GCC diagnostic push") \ |
74 | | _Pragma ("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") \ |
75 | | |
76 | | #define exprtk_disable_fallthrough_end \ |
77 | | _Pragma ("GCC diagnostic pop") \ |
78 | | |
79 | | #else |
80 | 120k | #define exprtk_disable_fallthrough_begin (void)0; |
81 | 120k | #define exprtk_disable_fallthrough_end (void)0; |
82 | | #endif |
83 | | |
84 | | #if __cplusplus >= 201103L |
85 | | #define exprtk_override override |
86 | | #define exprtk_final final |
87 | | #define exprtk_delete = delete |
88 | | #else |
89 | | #define exprtk_override |
90 | | #define exprtk_final |
91 | | #define exprtk_delete |
92 | | #endif |
93 | | |
94 | | namespace details |
95 | | { |
96 | | typedef char char_t; |
97 | | typedef char_t* char_ptr; |
98 | | typedef char_t const* char_cptr; |
99 | | typedef unsigned char uchar_t; |
100 | | typedef uchar_t* uchar_ptr; |
101 | | typedef uchar_t const* uchar_cptr; |
102 | | typedef unsigned long long int _uint64_t; |
103 | | typedef long long int _int64_t; |
104 | | |
105 | | inline bool is_whitespace(const char_t c) |
106 | 624M | { |
107 | 624M | return (' ' == c) || ('\n' == c) || |
108 | 624M | ('\r' == c) || ('\t' == c) || |
109 | 624M | ('\b' == c) || ('\v' == c) || |
110 | 624M | ('\f' == c) ; |
111 | 624M | } |
112 | | |
113 | | inline bool is_operator_char(const char_t c) |
114 | 67.4M | { |
115 | 67.4M | return ('+' == c) || ('-' == c) || |
116 | 67.4M | ('*' == c) || ('/' == c) || |
117 | 67.4M | ('^' == c) || ('<' == c) || |
118 | 67.4M | ('>' == c) || ('=' == c) || |
119 | 67.4M | (',' == c) || ('!' == c) || |
120 | 67.4M | ('(' == c) || (')' == c) || |
121 | 67.4M | ('[' == c) || (']' == c) || |
122 | 67.4M | ('{' == c) || ('}' == c) || |
123 | 67.4M | ('%' == c) || (':' == c) || |
124 | 67.4M | ('?' == c) || ('&' == c) || |
125 | 67.4M | ('|' == c) || (';' == c) ; |
126 | 67.4M | } |
127 | | |
128 | | inline bool is_letter(const char_t c) |
129 | 162M | { |
130 | 162M | return (('a' <= c) && (c <= 'z')) || |
131 | 162M | (('A' <= c) && (c <= 'Z')) ; |
132 | 162M | } |
133 | | |
134 | | inline bool is_digit(const char_t c) |
135 | 85.5M | { |
136 | 85.5M | return ('0' <= c) && (c <= '9'); |
137 | 85.5M | } |
138 | | |
139 | | inline bool is_letter_or_digit(const char_t c) |
140 | 99.8M | { |
141 | 99.8M | return is_letter(c) || is_digit(c); |
142 | 99.8M | } |
143 | | |
144 | | inline bool is_left_bracket(const char_t c) |
145 | 181M | { |
146 | 181M | return ('(' == c) || ('[' == c) || ('{' == c); |
147 | 181M | } |
148 | | |
149 | | inline bool is_right_bracket(const char_t c) |
150 | 188M | { |
151 | 188M | return (')' == c) || (']' == c) || ('}' == c); |
152 | 188M | } |
153 | | |
154 | | inline bool is_bracket(const char_t c) |
155 | 51.2M | { |
156 | 51.2M | return is_left_bracket(c) || is_right_bracket(c); |
157 | 51.2M | } |
158 | | |
159 | | inline bool is_sign(const char_t c) |
160 | 229k | { |
161 | 229k | return ('+' == c) || ('-' == c); |
162 | 229k | } |
163 | | |
164 | | inline bool is_invalid(const char_t c) |
165 | 0 | { |
166 | 0 | return !is_whitespace (c) && |
167 | 0 | !is_operator_char(c) && |
168 | 0 | !is_letter (c) && |
169 | 0 | !is_digit (c) && |
170 | 0 | ('.' != c) && |
171 | 0 | ('_' != c) && |
172 | 0 | ('$' != c) && |
173 | 0 | ('~' != c) && |
174 | 0 | ('\'' != c); |
175 | 0 | } |
176 | | |
177 | | inline bool is_valid_string_char(const char_t c) |
178 | 1.63M | { |
179 | 1.63M | return std::isprint(static_cast<uchar_t>(c)) || |
180 | 1.63M | is_whitespace(c); |
181 | 1.63M | } |
182 | | |
183 | | #ifndef exprtk_disable_caseinsensitivity |
184 | | inline void case_normalise(std::string& s) |
185 | 0 | { |
186 | 0 | for (std::size_t i = 0; i < s.size(); ++i) |
187 | 0 | { |
188 | 0 | s[i] = static_cast<std::string::value_type>(std::tolower(s[i])); |
189 | 0 | } |
190 | 0 | } |
191 | | |
192 | | inline bool imatch(const char_t c1, const char_t c2) |
193 | 710 | { |
194 | 710 | return std::tolower(c1) == std::tolower(c2); |
195 | 710 | } |
196 | | |
197 | | inline bool imatch(const std::string& s1, const std::string& s2) |
198 | 400M | { |
199 | 400M | if (s1.size() == s2.size()) |
200 | 36.2M | { |
201 | 128M | for (std::size_t i = 0; i < s1.size(); ++i) |
202 | 115M | { |
203 | 115M | if (std::tolower(s1[i]) != std::tolower(s2[i])) |
204 | 22.6M | { |
205 | 22.6M | return false; |
206 | 22.6M | } |
207 | 115M | } |
208 | | |
209 | 13.6M | return true; |
210 | 36.2M | } |
211 | | |
212 | 364M | return false; |
213 | 400M | } |
214 | | |
215 | | struct ilesscompare |
216 | | { |
217 | | inline bool operator() (const std::string& s1, const std::string& s2) const |
218 | 461M | { |
219 | 461M | const std::size_t length = std::min(s1.size(),s2.size()); |
220 | | |
221 | 591M | for (std::size_t i = 0; i < length; ++i) |
222 | 497M | { |
223 | 497M | const char_t c1 = static_cast<char_t>(std::tolower(s1[i])); |
224 | 497M | const char_t c2 = static_cast<char_t>(std::tolower(s2[i])); |
225 | | |
226 | 497M | if (c1 > c2) |
227 | 72.8M | return false; |
228 | 424M | else if (c1 < c2) |
229 | 294M | return true; |
230 | 497M | } |
231 | | |
232 | 94.9M | return s1.size() < s2.size(); |
233 | 461M | } |
234 | | }; |
235 | | |
236 | | #else |
237 | | inline void case_normalise(std::string&) |
238 | | {} |
239 | | |
240 | | inline bool imatch(const char_t c1, const char_t c2) |
241 | | { |
242 | | return c1 == c2; |
243 | | } |
244 | | |
245 | | inline bool imatch(const std::string& s1, const std::string& s2) |
246 | | { |
247 | | return s1 == s2; |
248 | | } |
249 | | |
250 | | struct ilesscompare |
251 | | { |
252 | | inline bool operator() (const std::string& s1, const std::string& s2) const |
253 | | { |
254 | | return s1 < s2; |
255 | | } |
256 | | }; |
257 | | #endif |
258 | | |
259 | | inline bool is_valid_sf_symbol(const std::string& symbol) |
260 | 15.1M | { |
261 | | // Special function: $f12 or $F34 |
262 | 15.1M | return (4 == symbol.size()) && |
263 | 15.1M | ('$' == symbol[0]) && |
264 | 15.1M | imatch('f',symbol[1]) && |
265 | 15.1M | is_digit(symbol[2]) && |
266 | 15.1M | is_digit(symbol[3]); |
267 | 15.1M | } |
268 | | |
269 | | inline const char_t& front(const std::string& s) |
270 | 0 | { |
271 | 0 | return s[0]; |
272 | 0 | } |
273 | | |
274 | | inline const char_t& back(const std::string& s) |
275 | 0 | { |
276 | 0 | return s[s.size() - 1]; |
277 | 0 | } |
278 | | |
279 | | inline std::string to_str(int i) |
280 | 184k | { |
281 | 184k | if (0 == i) |
282 | 63 | return std::string("0"); |
283 | | |
284 | 183k | std::string result; |
285 | | |
286 | 183k | const int sign = (i < 0) ? -1 : 1; |
287 | | |
288 | 1.10M | for ( ; i; i /= 10) |
289 | 919k | { |
290 | 919k | result += '0' + static_cast<char_t>(sign * (i % 10)); |
291 | 919k | } |
292 | | |
293 | 183k | if (sign < 0) |
294 | 23 | { |
295 | 23 | result += '-'; |
296 | 23 | } |
297 | | |
298 | 183k | std::reverse(result.begin(), result.end()); |
299 | | |
300 | 183k | return result; |
301 | 184k | } |
302 | | |
303 | | inline std::string to_str(std::size_t i) |
304 | 40 | { |
305 | 40 | return to_str(static_cast<int>(i)); |
306 | 40 | } |
307 | | |
308 | | inline bool is_hex_digit(const uchar_t digit) |
309 | 52 | { |
310 | 52 | return (('0' <= digit) && (digit <= '9')) || |
311 | 52 | (('A' <= digit) && (digit <= 'F')) || |
312 | 52 | (('a' <= digit) && (digit <= 'f')) ; |
313 | 52 | } |
314 | | |
315 | | inline uchar_t hex_to_bin(uchar_t h) |
316 | 0 | { |
317 | 0 | if (('0' <= h) && (h <= '9')) |
318 | 0 | return (h - '0'); |
319 | 0 | else |
320 | 0 | return static_cast<uchar_t>(std::toupper(h) - 'A'); |
321 | 0 | } |
322 | | |
323 | | template <typename Iterator> |
324 | | inline bool parse_hex(Iterator& itr, Iterator end, |
325 | | char_t& result) |
326 | 1.09k | { |
327 | 1.09k | if ( |
328 | 1.09k | (end == (itr )) || |
329 | 1.09k | (end == (itr + 1)) || |
330 | 1.09k | (end == (itr + 2)) || |
331 | 1.09k | (end == (itr + 3)) || |
332 | 1.09k | ('0' != *(itr )) || |
333 | 1.09k | ('X' != std::toupper(*(itr + 1))) || |
334 | 1.09k | (!is_hex_digit(*(itr + 2))) || |
335 | 1.09k | (!is_hex_digit(*(itr + 3))) |
336 | 1.09k | ) |
337 | 1.09k | { |
338 | 1.09k | return false; |
339 | 1.09k | } |
340 | | |
341 | 0 | result = hex_to_bin(static_cast<uchar_t>(*(itr + 2))) << 4 | |
342 | 0 | hex_to_bin(static_cast<uchar_t>(*(itr + 3))) ; |
343 | |
|
344 | 0 | return true; |
345 | 1.09k | } |
346 | | |
347 | | inline bool cleanup_escapes(std::string& s) |
348 | 848 | { |
349 | 848 | typedef std::string::iterator str_itr_t; |
350 | | |
351 | 848 | str_itr_t itr1 = s.begin(); |
352 | 848 | str_itr_t itr2 = s.begin(); |
353 | 848 | str_itr_t end = s.end (); |
354 | | |
355 | 848 | std::size_t removal_count = 0; |
356 | | |
357 | 35.0k | while (end != itr1) |
358 | 34.2k | { |
359 | 34.2k | if ('\\' == (*itr1)) |
360 | 1.09k | { |
361 | 1.09k | if (end == ++itr1) |
362 | 0 | { |
363 | 0 | return false; |
364 | 0 | } |
365 | 1.09k | else if (parse_hex(itr1, end, *itr2)) |
366 | 0 | { |
367 | 0 | itr1+= 4; |
368 | 0 | itr2+= 1; |
369 | 0 | removal_count +=4; |
370 | 0 | } |
371 | 1.09k | else if ('a' == (*itr1)) { (*itr2++) = '\a'; ++itr1; ++removal_count; } |
372 | 1.03k | else if ('b' == (*itr1)) { (*itr2++) = '\b'; ++itr1; ++removal_count; } |
373 | 1.01k | else if ('f' == (*itr1)) { (*itr2++) = '\f'; ++itr1; ++removal_count; } |
374 | 1.00k | else if ('n' == (*itr1)) { (*itr2++) = '\n'; ++itr1; ++removal_count; } |
375 | 988 | else if ('r' == (*itr1)) { (*itr2++) = '\r'; ++itr1; ++removal_count; } |
376 | 964 | else if ('t' == (*itr1)) { (*itr2++) = '\t'; ++itr1; ++removal_count; } |
377 | 944 | else if ('v' == (*itr1)) { (*itr2++) = '\v'; ++itr1; ++removal_count; } |
378 | 942 | else if ('0' == (*itr1)) { (*itr2++) = '\0'; ++itr1; ++removal_count; } |
379 | 934 | else |
380 | 934 | { |
381 | 934 | (*itr2++) = (*itr1++); |
382 | 934 | ++removal_count; |
383 | 934 | } |
384 | 1.09k | continue; |
385 | 1.09k | } |
386 | 33.1k | else |
387 | 33.1k | (*itr2++) = (*itr1++); |
388 | 34.2k | } |
389 | | |
390 | 848 | if ((removal_count > s.size()) || (0 == removal_count)) |
391 | 0 | return false; |
392 | | |
393 | 848 | s.resize(s.size() - removal_count); |
394 | | |
395 | 848 | return true; |
396 | 848 | } |
397 | | |
398 | | class build_string |
399 | | { |
400 | | public: |
401 | | |
402 | | explicit build_string(const std::size_t& initial_size = 64) |
403 | 3.82M | { |
404 | 3.82M | data_.reserve(initial_size); |
405 | 3.82M | } |
406 | | |
407 | | inline build_string& operator << (const std::string& s) |
408 | 8.95M | { |
409 | 8.95M | data_ += s; |
410 | 8.95M | return (*this); |
411 | 8.95M | } |
412 | | |
413 | | inline build_string& operator << (char_cptr s) |
414 | 12.7M | { |
415 | 12.7M | data_ += std::string(s); |
416 | 12.7M | return (*this); |
417 | 12.7M | } |
418 | | |
419 | | inline operator std::string () const |
420 | 3.82M | { |
421 | 3.82M | return data_; |
422 | 3.82M | } |
423 | | |
424 | | inline std::string as_string() const |
425 | 0 | { |
426 | 0 | return data_; |
427 | 0 | } |
428 | | |
429 | | private: |
430 | | |
431 | | std::string data_; |
432 | | }; |
433 | | |
434 | | static const std::string reserved_words[] = |
435 | | { |
436 | | "break", "case", "continue", "default", "false", "for", |
437 | | "if", "else", "ilike", "in", "like", "and", "nand", "nor", |
438 | | "not", "null", "or", "repeat", "return", "shl", "shr", |
439 | | "swap", "switch", "true", "until", "var", "while", "xnor", |
440 | | "xor", "&", "|" |
441 | | }; |
442 | | |
443 | | static const std::size_t reserved_words_size = sizeof(reserved_words) / sizeof(std::string); |
444 | | |
445 | | static const std::string reserved_symbols[] = |
446 | | { |
447 | | "abs", "acos", "acosh", "and", "asin", "asinh", "atan", |
448 | | "atanh", "atan2", "avg", "break", "case", "ceil", "clamp", |
449 | | "continue", "cos", "cosh", "cot", "csc", "default", |
450 | | "deg2grad", "deg2rad", "equal", "erf", "erfc", "exp", |
451 | | "expm1", "false", "floor", "for", "frac", "grad2deg", |
452 | | "hypot", "iclamp", "if", "else", "ilike", "in", "inrange", |
453 | | "like", "log", "log10", "log2", "logn", "log1p", "mand", |
454 | | "max", "min", "mod", "mor", "mul", "ncdf", "nand", "nor", |
455 | | "not", "not_equal", "null", "or", "pow", "rad2deg", |
456 | | "repeat", "return", "root", "round", "roundn", "sec", "sgn", |
457 | | "shl", "shr", "sin", "sinc", "sinh", "sqrt", "sum", "swap", |
458 | | "switch", "tan", "tanh", "true", "trunc", "until", "var", |
459 | | "while", "xnor", "xor", "&", "|" |
460 | | }; |
461 | | |
462 | | static const std::size_t reserved_symbols_size = sizeof(reserved_symbols) / sizeof(std::string); |
463 | | |
464 | | static const std::string base_function_list[] = |
465 | | { |
466 | | "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", |
467 | | "atan2", "avg", "ceil", "clamp", "cos", "cosh", "cot", |
468 | | "csc", "equal", "erf", "erfc", "exp", "expm1", "floor", |
469 | | "frac", "hypot", "iclamp", "like", "log", "log10", "log2", |
470 | | "logn", "log1p", "mand", "max", "min", "mod", "mor", "mul", |
471 | | "ncdf", "pow", "root", "round", "roundn", "sec", "sgn", |
472 | | "sin", "sinc", "sinh", "sqrt", "sum", "swap", "tan", "tanh", |
473 | | "trunc", "not_equal", "inrange", "deg2grad", "deg2rad", |
474 | | "rad2deg", "grad2deg" |
475 | | }; |
476 | | |
477 | | static const std::size_t base_function_list_size = sizeof(base_function_list) / sizeof(std::string); |
478 | | |
479 | | static const std::string logic_ops_list[] = |
480 | | { |
481 | | "and", "nand", "nor", "not", "or", "xnor", "xor", "&", "|" |
482 | | }; |
483 | | |
484 | | static const std::size_t logic_ops_list_size = sizeof(logic_ops_list) / sizeof(std::string); |
485 | | |
486 | | static const std::string cntrl_struct_list[] = |
487 | | { |
488 | | "if", "switch", "for", "while", "repeat", "return" |
489 | | }; |
490 | | |
491 | | static const std::size_t cntrl_struct_list_size = sizeof(cntrl_struct_list) / sizeof(std::string); |
492 | | |
493 | | static const std::string arithmetic_ops_list[] = |
494 | | { |
495 | | "+", "-", "*", "/", "%", "^" |
496 | | }; |
497 | | |
498 | | static const std::size_t arithmetic_ops_list_size = sizeof(arithmetic_ops_list) / sizeof(std::string); |
499 | | |
500 | | static const std::string assignment_ops_list[] = |
501 | | { |
502 | | ":=", "+=", "-=", |
503 | | "*=", "/=", "%=" |
504 | | }; |
505 | | |
506 | | static const std::size_t assignment_ops_list_size = sizeof(assignment_ops_list) / sizeof(std::string); |
507 | | |
508 | | static const std::string inequality_ops_list[] = |
509 | | { |
510 | | "<", "<=", "==", |
511 | | "=", "!=", "<>", |
512 | | ">=", ">" |
513 | | }; |
514 | | |
515 | | static const std::size_t inequality_ops_list_size = sizeof(inequality_ops_list) / sizeof(std::string); |
516 | | |
517 | | inline bool is_reserved_word(const std::string& symbol) |
518 | 0 | { |
519 | 0 | for (std::size_t i = 0; i < reserved_words_size; ++i) |
520 | 0 | { |
521 | 0 | if (imatch(symbol, reserved_words[i])) |
522 | 0 | { |
523 | 0 | return true; |
524 | 0 | } |
525 | 0 | } |
526 | 0 |
|
527 | 0 | return false; |
528 | 0 | } |
529 | | |
530 | | inline bool is_reserved_symbol(const std::string& symbol) |
531 | 234k | { |
532 | 20.6M | for (std::size_t i = 0; i < reserved_symbols_size; ++i) |
533 | 20.3M | { |
534 | 20.3M | if (imatch(symbol, reserved_symbols[i])) |
535 | 1.01k | { |
536 | 1.01k | return true; |
537 | 1.01k | } |
538 | 20.3M | } |
539 | | |
540 | 233k | return false; |
541 | 234k | } |
542 | | |
543 | | inline bool is_base_function(const std::string& function_name) |
544 | 0 | { |
545 | 0 | for (std::size_t i = 0; i < base_function_list_size; ++i) |
546 | 0 | { |
547 | 0 | if (imatch(function_name, base_function_list[i])) |
548 | 0 | { |
549 | 0 | return true; |
550 | 0 | } |
551 | 0 | } |
552 | | |
553 | 0 | return false; |
554 | 0 | } |
555 | | |
556 | | inline bool is_control_struct(const std::string& cntrl_strct) |
557 | 0 | { |
558 | 0 | for (std::size_t i = 0; i < cntrl_struct_list_size; ++i) |
559 | 0 | { |
560 | 0 | if (imatch(cntrl_strct, cntrl_struct_list[i])) |
561 | 0 | { |
562 | 0 | return true; |
563 | 0 | } |
564 | 0 | } |
565 | 0 |
|
566 | 0 | return false; |
567 | 0 | } |
568 | | |
569 | | inline bool is_logic_opr(const std::string& lgc_opr) |
570 | 0 | { |
571 | 0 | for (std::size_t i = 0; i < logic_ops_list_size; ++i) |
572 | 0 | { |
573 | 0 | if (imatch(lgc_opr, logic_ops_list[i])) |
574 | 0 | { |
575 | 0 | return true; |
576 | 0 | } |
577 | 0 | } |
578 | 0 |
|
579 | 0 | return false; |
580 | 0 | } |
581 | | |
582 | | struct cs_match |
583 | | { |
584 | | static inline bool cmp(const char_t c0, const char_t c1) |
585 | 0 | { |
586 | 0 | return (c0 == c1); |
587 | 0 | } |
588 | | }; |
589 | | |
590 | | struct cis_match |
591 | | { |
592 | | static inline bool cmp(const char_t c0, const char_t c1) |
593 | 0 | { |
594 | 0 | return (std::tolower(c0) == std::tolower(c1)); |
595 | 0 | } |
596 | | }; |
597 | | |
598 | | template <typename Iterator, typename Compare> |
599 | | inline bool match_impl(const Iterator pattern_begin, |
600 | | const Iterator pattern_end , |
601 | | const Iterator data_begin , |
602 | | const Iterator data_end , |
603 | | const typename std::iterator_traits<Iterator>::value_type& zero_or_more, |
604 | | const typename std::iterator_traits<Iterator>::value_type& exactly_one ) |
605 | 0 | { |
606 | 0 | typedef typename std::iterator_traits<Iterator>::value_type type; |
607 | |
|
608 | 0 | const Iterator null_itr(0); |
609 | |
|
610 | 0 | Iterator p_itr = pattern_begin; |
611 | 0 | Iterator d_itr = data_begin; |
612 | 0 | Iterator np_itr = null_itr; |
613 | 0 | Iterator nd_itr = null_itr; |
614 | |
|
615 | 0 | for ( ; ; ) |
616 | 0 | { |
617 | 0 | if (p_itr != pattern_end) |
618 | 0 | { |
619 | 0 | const type c = *(p_itr); |
620 | |
|
621 | 0 | if ((data_end != d_itr) && (Compare::cmp(c,*(d_itr)) || (exactly_one == c))) |
622 | 0 | { |
623 | 0 | ++d_itr; |
624 | 0 | ++p_itr; |
625 | 0 | continue; |
626 | 0 | } |
627 | 0 | else if (zero_or_more == c) |
628 | 0 | { |
629 | 0 | while ((pattern_end != p_itr) && (zero_or_more == *(p_itr))) |
630 | 0 | { |
631 | 0 | ++p_itr; |
632 | 0 | } |
633 | |
|
634 | 0 | const type d = *(p_itr); |
635 | |
|
636 | 0 | while ((data_end != d_itr) && !(Compare::cmp(d,*(d_itr)) || (exactly_one == d))) |
637 | 0 | { |
638 | 0 | ++d_itr; |
639 | 0 | } |
640 | | |
641 | | // set backtrack iterators |
642 | 0 | np_itr = p_itr - 1; |
643 | 0 | nd_itr = d_itr + 1; |
644 | |
|
645 | 0 | continue; |
646 | 0 | } |
647 | 0 | } |
648 | 0 | else if (data_end == d_itr) |
649 | 0 | return true; |
650 | | |
651 | 0 | if ((data_end == d_itr) || (null_itr == nd_itr)) |
652 | 0 | return false; |
653 | | |
654 | 0 | p_itr = np_itr; |
655 | 0 | d_itr = nd_itr; |
656 | 0 | } |
657 | | |
658 | 0 | return true; |
659 | 0 | } Unexecuted instantiation: bool exprtk::details::match_impl<char const*, exprtk::details::cs_match>(char const*, char const*, char const*, char const*, std::__1::iterator_traits<char const*>::value_type const&, std::__1::iterator_traits<char const*>::value_type const&) Unexecuted instantiation: bool exprtk::details::match_impl<char const*, exprtk::details::cis_match>(char const*, char const*, char const*, char const*, std::__1::iterator_traits<char const*>::value_type const&, std::__1::iterator_traits<char const*>::value_type const&) |
660 | | |
661 | | inline bool wc_match(const std::string& wild_card, |
662 | | const std::string& str) |
663 | 0 | { |
664 | 0 | return match_impl<char_cptr,cs_match>( |
665 | 0 | wild_card.data(), |
666 | 0 | wild_card.data() + wild_card.size(), |
667 | 0 | str.data(), |
668 | 0 | str.data() + str.size(), |
669 | 0 | '*', '?'); |
670 | 0 | } |
671 | | |
672 | | inline bool wc_imatch(const std::string& wild_card, |
673 | | const std::string& str) |
674 | 0 | { |
675 | 0 | return match_impl<char_cptr,cis_match>( |
676 | 0 | wild_card.data(), |
677 | 0 | wild_card.data() + wild_card.size(), |
678 | 0 | str.data(), |
679 | 0 | str.data() + str.size(), |
680 | 0 | '*', '?'); |
681 | 0 | } |
682 | | |
683 | | inline bool sequence_match(const std::string& pattern, |
684 | | const std::string& str, |
685 | | std::size_t& diff_index, |
686 | | char_t& diff_value) |
687 | 0 | { |
688 | 0 | if (str.empty()) |
689 | 0 | { |
690 | 0 | return ("Z" == pattern); |
691 | 0 | } |
692 | 0 | else if ('*' == pattern[0]) |
693 | 0 | return false; |
694 | | |
695 | 0 | typedef std::string::const_iterator itr_t; |
696 | |
|
697 | 0 | itr_t p_itr = pattern.begin(); |
698 | 0 | itr_t s_itr = str .begin(); |
699 | |
|
700 | 0 | const itr_t p_end = pattern.end(); |
701 | 0 | const itr_t s_end = str .end(); |
702 | |
|
703 | 0 | while ((s_end != s_itr) && (p_end != p_itr)) |
704 | 0 | { |
705 | 0 | if ('*' == (*p_itr)) |
706 | 0 | { |
707 | 0 | const char_t target = static_cast<char_t>(std::toupper(*(p_itr - 1))); |
708 | |
|
709 | 0 | if ('*' == target) |
710 | 0 | { |
711 | 0 | diff_index = static_cast<std::size_t>(std::distance(str.begin(),s_itr)); |
712 | 0 | diff_value = static_cast<char_t>(std::toupper(*p_itr)); |
713 | |
|
714 | 0 | return false; |
715 | 0 | } |
716 | 0 | else |
717 | 0 | ++p_itr; |
718 | | |
719 | 0 | while (s_itr != s_end) |
720 | 0 | { |
721 | 0 | if (target != std::toupper(*s_itr)) |
722 | 0 | break; |
723 | 0 | else |
724 | 0 | ++s_itr; |
725 | 0 | } |
726 | |
|
727 | 0 | continue; |
728 | 0 | } |
729 | 0 | else if ( |
730 | 0 | ('?' != *p_itr) && |
731 | 0 | std::toupper(*p_itr) != std::toupper(*s_itr) |
732 | 0 | ) |
733 | 0 | { |
734 | 0 | diff_index = static_cast<std::size_t>(std::distance(str.begin(),s_itr)); |
735 | 0 | diff_value = static_cast<char_t>(std::toupper(*p_itr)); |
736 | |
|
737 | 0 | return false; |
738 | 0 | } |
739 | | |
740 | 0 | ++p_itr; |
741 | 0 | ++s_itr; |
742 | 0 | } |
743 | | |
744 | 0 | return ( |
745 | 0 | (s_end == s_itr) && |
746 | 0 | ( |
747 | 0 | (p_end == p_itr) || |
748 | 0 | ('*' == *p_itr) |
749 | 0 | ) |
750 | 0 | ); |
751 | 0 | } |
752 | | |
753 | | static const double pow10[] = { |
754 | | 1.0, |
755 | | 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, |
756 | | 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, |
757 | | 1.0E+009, 1.0E+010, 1.0E+011, 1.0E+012, |
758 | | 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016 |
759 | | }; |
760 | | |
761 | | static const std::size_t pow10_size = sizeof(pow10) / sizeof(double); |
762 | | |
763 | | namespace numeric |
764 | | { |
765 | | namespace constant |
766 | | { |
767 | | static const double e = 2.71828182845904523536028747135266249775724709369996; |
768 | | static const double pi = 3.14159265358979323846264338327950288419716939937510; |
769 | | static const double pi_2 = 1.57079632679489661923132169163975144209858469968755; |
770 | | static const double pi_4 = 0.78539816339744830961566084581987572104929234984378; |
771 | | static const double pi_180 = 0.01745329251994329576923690768488612713442871888542; |
772 | | static const double _1_pi = 0.31830988618379067153776752674502872406891929148091; |
773 | | static const double _2_pi = 0.63661977236758134307553505349005744813783858296183; |
774 | | static const double _180_pi = 57.29577951308232087679815481410517033240547246656443; |
775 | | static const double log2 = 0.69314718055994530941723212145817656807550013436026; |
776 | | static const double sqrt2 = 1.41421356237309504880168872420969807856967187537695; |
777 | | } |
778 | | |
779 | | namespace details |
780 | | { |
781 | 0 | struct unknown_type_tag { unknown_type_tag() {} }; |
782 | 2.73G | struct real_type_tag { real_type_tag () {} }; |
783 | 0 | struct int_type_tag { int_type_tag () {} }; |
784 | | |
785 | | template <typename T> |
786 | | struct number_type |
787 | | { |
788 | | typedef unknown_type_tag type; |
789 | | number_type() {} |
790 | | }; |
791 | | |
792 | | #define exprtk_register_real_type_tag(T) \ |
793 | | template <> struct number_type<T> \ |
794 | 0 | { typedef real_type_tag type; number_type() {} }; \ Unexecuted instantiation: exprtk::details::numeric::details::number_type<double>::number_type() Unexecuted instantiation: exprtk::details::numeric::details::number_type<long double>::number_type() Unexecuted instantiation: exprtk::details::numeric::details::number_type<float>::number_type() |
795 | | |
796 | | #define exprtk_register_int_type_tag(T) \ |
797 | | template <> struct number_type<T> \ |
798 | 0 | { typedef int_type_tag type; number_type() {} }; \ Unexecuted instantiation: exprtk::details::numeric::details::number_type<short>::number_type() Unexecuted instantiation: exprtk::details::numeric::details::number_type<int>::number_type() Unexecuted instantiation: exprtk::details::numeric::details::number_type<long long>::number_type() Unexecuted instantiation: exprtk::details::numeric::details::number_type<unsigned short>::number_type() Unexecuted instantiation: exprtk::details::numeric::details::number_type<unsigned int>::number_type() Unexecuted instantiation: exprtk::details::numeric::details::number_type<unsigned long long>::number_type() |
799 | | |
800 | | exprtk_register_real_type_tag(double ) |
801 | | exprtk_register_real_type_tag(long double) |
802 | | exprtk_register_real_type_tag(float ) |
803 | | |
804 | | exprtk_register_int_type_tag(short ) |
805 | | exprtk_register_int_type_tag(int ) |
806 | | exprtk_register_int_type_tag(_int64_t ) |
807 | | exprtk_register_int_type_tag(unsigned short) |
808 | | exprtk_register_int_type_tag(unsigned int ) |
809 | | exprtk_register_int_type_tag(_uint64_t ) |
810 | | |
811 | | #undef exprtk_register_real_type_tag |
812 | | #undef exprtk_register_int_type_tag |
813 | | |
814 | | template <typename T> |
815 | | struct epsilon_type {}; |
816 | | |
817 | | #define exprtk_define_epsilon_type(Type, Epsilon) \ |
818 | | template <> struct epsilon_type<Type> \ |
819 | | { \ |
820 | | static inline Type value() \ |
821 | 2 | { \ |
822 | 2 | const Type epsilon = static_cast<Type>(Epsilon); \ |
823 | 2 | return epsilon; \ |
824 | 2 | } \ exprtk::details::numeric::details::epsilon_type<double>::value() Line | Count | Source | 821 | 1 | { \ | 822 | 1 | const Type epsilon = static_cast<Type>(Epsilon); \ | 823 | 1 | return epsilon; \ | 824 | 1 | } \ |
exprtk::details::numeric::details::epsilon_type<float>::value() Line | Count | Source | 821 | 1 | { \ | 822 | 1 | const Type epsilon = static_cast<Type>(Epsilon); \ | 823 | 1 | return epsilon; \ | 824 | 1 | } \ |
Unexecuted instantiation: exprtk::details::numeric::details::epsilon_type<long double>::value() |
825 | | }; \ |
826 | | |
827 | | exprtk_define_epsilon_type(float , 0.00000100000f) |
828 | | exprtk_define_epsilon_type(double , 0.000000000100) |
829 | | exprtk_define_epsilon_type(long double, 0.000000000001) |
830 | | |
831 | | #undef exprtk_define_epsilon_type |
832 | | |
833 | | template <typename T> |
834 | | inline bool is_nan_impl(const T v, real_type_tag) |
835 | 801k | { |
836 | 801k | return std::not_equal_to<T>()(v,v); |
837 | 801k | } bool exprtk::details::numeric::details::is_nan_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 835 | 400k | { | 836 | 400k | return std::not_equal_to<T>()(v,v); | 837 | 400k | } |
bool exprtk::details::numeric::details::is_nan_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 835 | 400k | { | 836 | 400k | return std::not_equal_to<T>()(v,v); | 837 | 400k | } |
|
838 | | |
839 | | template <typename T> |
840 | | inline int to_int32_impl(const T v, real_type_tag) |
841 | 874k | { |
842 | 874k | return static_cast<int>(v); |
843 | 874k | } int exprtk::details::numeric::details::to_int32_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 841 | 449k | { | 842 | 449k | return static_cast<int>(v); | 843 | 449k | } |
int exprtk::details::numeric::details::to_int32_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 841 | 424k | { | 842 | 424k | return static_cast<int>(v); | 843 | 424k | } |
|
844 | | |
845 | | template <typename T> |
846 | | inline _int64_t to_int64_impl(const T v, real_type_tag) |
847 | 755 | { |
848 | 755 | return static_cast<_int64_t>(v); |
849 | 755 | } long long exprtk::details::numeric::details::to_int64_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 847 | 380 | { | 848 | 380 | return static_cast<_int64_t>(v); | 849 | 380 | } |
long long exprtk::details::numeric::details::to_int64_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 847 | 375 | { | 848 | 375 | return static_cast<_int64_t>(v); | 849 | 375 | } |
|
850 | | |
851 | | template <typename T> |
852 | | inline bool is_true_impl(const T v) |
853 | 501M | { |
854 | 501M | return std::not_equal_to<T>()(T(0),v); |
855 | 501M | } bool exprtk::details::numeric::details::is_true_impl<double>(double) Line | Count | Source | 853 | 254M | { | 854 | 254M | return std::not_equal_to<T>()(T(0),v); | 855 | 254M | } |
bool exprtk::details::numeric::details::is_true_impl<float>(float) Line | Count | Source | 853 | 247M | { | 854 | 247M | return std::not_equal_to<T>()(T(0),v); | 855 | 247M | } |
|
856 | | |
857 | | template <typename T> |
858 | | inline bool is_false_impl(const T v) |
859 | 502M | { |
860 | 502M | return std::equal_to<T>()(T(0),v); |
861 | 502M | } bool exprtk::details::numeric::details::is_false_impl<double>(double) Line | Count | Source | 859 | 254M | { | 860 | 254M | return std::equal_to<T>()(T(0),v); | 861 | 254M | } |
bool exprtk::details::numeric::details::is_false_impl<float>(float) Line | Count | Source | 859 | 247M | { | 860 | 247M | return std::equal_to<T>()(T(0),v); | 861 | 247M | } |
|
862 | | |
863 | | template <typename T> |
864 | | inline T abs_impl(const T v, real_type_tag) |
865 | 30.9M | { |
866 | 30.9M | return ((v < T(0)) ? -v : v); |
867 | 30.9M | } double exprtk::details::numeric::details::abs_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 865 | 16.1M | { | 866 | 16.1M | return ((v < T(0)) ? -v : v); | 867 | 16.1M | } |
float exprtk::details::numeric::details::abs_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 865 | 14.8M | { | 866 | 14.8M | return ((v < T(0)) ? -v : v); | 867 | 14.8M | } |
|
868 | | |
869 | | template <typename T> |
870 | | inline T min_impl(const T v0, const T v1, real_type_tag) |
871 | | { |
872 | | return std::min<T>(v0,v1); |
873 | | } |
874 | | |
875 | | template <typename T> |
876 | | inline T max_impl(const T v0, const T v1, real_type_tag) |
877 | | { |
878 | | return std::max<T>(v0,v1); |
879 | | } |
880 | | |
881 | | template <typename T> |
882 | | inline T equal_impl(const T v0, const T v1, real_type_tag) |
883 | 0 | { |
884 | 0 | const T epsilon = epsilon_type<T>::value(); |
885 | 0 | return (abs_impl(v0 - v1,real_type_tag()) <= (std::max(T(1),std::max(abs_impl(v0,real_type_tag()),abs_impl(v1,real_type_tag()))) * epsilon)) ? T(1) : T(0); |
886 | 0 | } |
887 | | |
888 | | inline float equal_impl(const float v0, const float v1, real_type_tag) |
889 | 0 | { |
890 | 0 | const float epsilon = epsilon_type<float>::value(); |
891 | 0 | return (abs_impl(v0 - v1,real_type_tag()) <= (std::max(1.0f,std::max(abs_impl(v0,real_type_tag()),abs_impl(v1,real_type_tag()))) * epsilon)) ? 1.0f : 0.0f; |
892 | 0 | } |
893 | | |
894 | | template <typename T> |
895 | | inline T equal_impl(const T v0, const T v1, int_type_tag) |
896 | | { |
897 | | return (v0 == v1) ? 1 : 0; |
898 | | } |
899 | | |
900 | | template <typename T> |
901 | | inline T expm1_impl(const T v, real_type_tag) |
902 | 0 | { |
903 | | // return std::expm1<T>(v); |
904 | 0 | if (abs_impl(v,real_type_tag()) < T(0.00001)) |
905 | 0 | return v + (T(0.5) * v * v); |
906 | 0 | else |
907 | 0 | return std::exp(v) - T(1); |
908 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::expm1_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::expm1_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
909 | | |
910 | | template <typename T> |
911 | | inline T expm1_impl(const T v, int_type_tag) |
912 | | { |
913 | | return T(std::exp<double>(v)) - T(1); |
914 | | } |
915 | | |
916 | | template <typename T> |
917 | | inline T nequal_impl(const T v0, const T v1, real_type_tag) |
918 | 0 | { |
919 | 0 | typedef real_type_tag rtg; |
920 | 0 | const T epsilon = epsilon_type<T>::value(); |
921 | 0 | return (abs_impl(v0 - v1,rtg()) > (std::max(T(1),std::max(abs_impl(v0,rtg()),abs_impl(v1,rtg()))) * epsilon)) ? T(1) : T(0); |
922 | 0 | } |
923 | | |
924 | | inline float nequal_impl(const float v0, const float v1, real_type_tag) |
925 | 0 | { |
926 | 0 | typedef real_type_tag rtg; |
927 | 0 | const float epsilon = epsilon_type<float>::value(); |
928 | 0 | return (abs_impl(v0 - v1,rtg()) > (std::max(1.0f,std::max(abs_impl(v0,rtg()),abs_impl(v1,rtg()))) * epsilon)) ? 1.0f : 0.0f; |
929 | 0 | } |
930 | | |
931 | | template <typename T> |
932 | | inline T nequal_impl(const T v0, const T v1, int_type_tag) |
933 | | { |
934 | | return (v0 != v1) ? 1 : 0; |
935 | | } |
936 | | |
937 | | template <typename T> |
938 | | inline T modulus_impl(const T v0, const T v1, real_type_tag) |
939 | 842M | { |
940 | 842M | return std::fmod(v0,v1); |
941 | 842M | } double exprtk::details::numeric::details::modulus_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 939 | 437M | { | 940 | 437M | return std::fmod(v0,v1); | 941 | 437M | } |
float exprtk::details::numeric::details::modulus_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 939 | 404M | { | 940 | 404M | return std::fmod(v0,v1); | 941 | 404M | } |
|
942 | | |
943 | | template <typename T> |
944 | | inline T modulus_impl(const T v0, const T v1, int_type_tag) |
945 | | { |
946 | | return v0 % v1; |
947 | | } |
948 | | |
949 | | template <typename T> |
950 | | inline T pow_impl(const T v0, const T v1, real_type_tag) |
951 | 651M | { |
952 | 651M | return std::pow(v0,v1); |
953 | 651M | } double exprtk::details::numeric::details::pow_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 951 | 326M | { | 952 | 326M | return std::pow(v0,v1); | 953 | 326M | } |
float exprtk::details::numeric::details::pow_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 951 | 325M | { | 952 | 325M | return std::pow(v0,v1); | 953 | 325M | } |
|
954 | | |
955 | | template <typename T> |
956 | | inline T pow_impl(const T v0, const T v1, int_type_tag) |
957 | | { |
958 | | return std::pow(static_cast<double>(v0),static_cast<double>(v1)); |
959 | | } |
960 | | |
961 | | template <typename T> |
962 | | inline T logn_impl(const T v0, const T v1, real_type_tag) |
963 | 0 | { |
964 | 0 | return std::log(v0) / std::log(v1); |
965 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::logn_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::logn_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) |
966 | | |
967 | | template <typename T> |
968 | | inline T logn_impl(const T v0, const T v1, int_type_tag) |
969 | | { |
970 | | return static_cast<T>(logn_impl<double>(static_cast<double>(v0),static_cast<double>(v1),real_type_tag())); |
971 | | } |
972 | | |
973 | | template <typename T> |
974 | | inline T log1p_impl(const T v, real_type_tag) |
975 | 12.9M | { |
976 | 12.9M | if (v > T(-1)) |
977 | 11.9M | { |
978 | 11.9M | if (abs_impl(v,real_type_tag()) > T(0.0001)) |
979 | 3.10M | { |
980 | 3.10M | return std::log(T(1) + v); |
981 | 3.10M | } |
982 | 8.81M | else |
983 | 8.81M | return (T(-0.5) * v + T(1)) * v; |
984 | 11.9M | } |
985 | 1.00M | else |
986 | 1.00M | return std::numeric_limits<T>::quiet_NaN(); |
987 | 12.9M | } double exprtk::details::numeric::details::log1p_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 975 | 6.71M | { | 976 | 6.71M | if (v > T(-1)) | 977 | 6.21M | { | 978 | 6.21M | if (abs_impl(v,real_type_tag()) > T(0.0001)) | 979 | 1.60M | { | 980 | 1.60M | return std::log(T(1) + v); | 981 | 1.60M | } | 982 | 4.60M | else | 983 | 4.60M | return (T(-0.5) * v + T(1)) * v; | 984 | 6.21M | } | 985 | 503k | else | 986 | 503k | return std::numeric_limits<T>::quiet_NaN(); | 987 | 6.71M | } |
float exprtk::details::numeric::details::log1p_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 975 | 6.20M | { | 976 | 6.20M | if (v > T(-1)) | 977 | 5.70M | { | 978 | 5.70M | if (abs_impl(v,real_type_tag()) > T(0.0001)) | 979 | 1.50M | { | 980 | 1.50M | return std::log(T(1) + v); | 981 | 1.50M | } | 982 | 4.20M | else | 983 | 4.20M | return (T(-0.5) * v + T(1)) * v; | 984 | 5.70M | } | 985 | 500k | else | 986 | 500k | return std::numeric_limits<T>::quiet_NaN(); | 987 | 6.20M | } |
|
988 | | |
989 | | template <typename T> |
990 | | inline T log1p_impl(const T v, int_type_tag) |
991 | | { |
992 | | if (v > T(-1)) |
993 | | { |
994 | | return std::log(T(1) + v); |
995 | | } |
996 | | else |
997 | | return std::numeric_limits<T>::quiet_NaN(); |
998 | | } |
999 | | |
1000 | | template <typename T> |
1001 | | inline T root_impl(const T v0, const T v1, real_type_tag) |
1002 | 0 | { |
1003 | 0 | if (v1 < T(0)) |
1004 | 0 | return std::numeric_limits<T>::quiet_NaN(); |
1005 | | |
1006 | 0 | const std::size_t n = static_cast<std::size_t>(v1); |
1007 | |
|
1008 | 0 | if ((v0 < T(0)) && (0 == (n % 2))) |
1009 | 0 | return std::numeric_limits<T>::quiet_NaN(); |
1010 | | |
1011 | 0 | return std::pow(v0, T(1) / n); |
1012 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::root_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::root_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) |
1013 | | |
1014 | | template <typename T> |
1015 | | inline T root_impl(const T v0, const T v1, int_type_tag) |
1016 | | { |
1017 | | return root_impl<double>(static_cast<double>(v0),static_cast<double>(v1),real_type_tag()); |
1018 | | } |
1019 | | |
1020 | | template <typename T> |
1021 | | inline T round_impl(const T v, real_type_tag) |
1022 | 0 | { |
1023 | 0 | return ((v < T(0)) ? std::ceil(v - T(0.5)) : std::floor(v + T(0.5))); |
1024 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::round_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::round_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1025 | | |
1026 | | template <typename T> |
1027 | | inline T roundn_impl(const T v0, const T v1, real_type_tag) |
1028 | 0 | { |
1029 | 0 | const int index = std::max<int>(0, std::min<int>(pow10_size - 1, static_cast<int>(std::floor(v1)))); |
1030 | 0 | const T p10 = T(pow10[index]); |
1031 | |
|
1032 | 0 | if (v0 < T(0)) |
1033 | 0 | return T(std::ceil ((v0 * p10) - T(0.5)) / p10); |
1034 | 0 | else |
1035 | 0 | return T(std::floor((v0 * p10) + T(0.5)) / p10); |
1036 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::roundn_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::roundn_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) |
1037 | | |
1038 | | template <typename T> |
1039 | | inline T roundn_impl(const T v0, const T, int_type_tag) |
1040 | | { |
1041 | | return v0; |
1042 | | } |
1043 | | |
1044 | | template <typename T> |
1045 | | inline T hypot_impl(const T v0, const T v1, real_type_tag) |
1046 | 0 | { |
1047 | 0 | return std::sqrt((v0 * v0) + (v1 * v1)); |
1048 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::hypot_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::hypot_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) |
1049 | | |
1050 | | template <typename T> |
1051 | | inline T hypot_impl(const T v0, const T v1, int_type_tag) |
1052 | | { |
1053 | | return static_cast<T>(std::sqrt(static_cast<double>((v0 * v0) + (v1 * v1)))); |
1054 | | } |
1055 | | |
1056 | | template <typename T> |
1057 | | inline T atan2_impl(const T v0, const T v1, real_type_tag) |
1058 | 0 | { |
1059 | 0 | return std::atan2(v0,v1); |
1060 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::atan2_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::atan2_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) |
1061 | | |
1062 | | template <typename T> |
1063 | | inline T atan2_impl(const T, const T, int_type_tag) |
1064 | | { |
1065 | | return 0; |
1066 | | } |
1067 | | |
1068 | | template <typename T> |
1069 | | inline T shr_impl(const T v0, const T v1, real_type_tag) |
1070 | 0 | { |
1071 | 0 | return v0 * (T(1) / std::pow(T(2),static_cast<T>(static_cast<int>(v1)))); |
1072 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::shr_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::shr_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) |
1073 | | |
1074 | | template <typename T> |
1075 | | inline T shr_impl(const T v0, const T v1, int_type_tag) |
1076 | | { |
1077 | | return v0 >> v1; |
1078 | | } |
1079 | | |
1080 | | template <typename T> |
1081 | | inline T shl_impl(const T v0, const T v1, real_type_tag) |
1082 | 0 | { |
1083 | 0 | return v0 * std::pow(T(2),static_cast<T>(static_cast<int>(v1))); |
1084 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::shl_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::shl_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) |
1085 | | |
1086 | | template <typename T> |
1087 | | inline T shl_impl(const T v0, const T v1, int_type_tag) |
1088 | | { |
1089 | | return v0 << v1; |
1090 | | } |
1091 | | |
1092 | | template <typename T> |
1093 | | inline T sgn_impl(const T v, real_type_tag) |
1094 | 8.83M | { |
1095 | 8.83M | if (v > T(0)) return T(+1); |
1096 | 4.19M | else if (v < T(0)) return T(-1); |
1097 | 3.99M | else return T( 0); |
1098 | 8.83M | } double exprtk::details::numeric::details::sgn_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1094 | 4.70M | { | 1095 | 4.70M | if (v > T(0)) return T(+1); | 1096 | 2.19M | else if (v < T(0)) return T(-1); | 1097 | 1.99M | else return T( 0); | 1098 | 4.70M | } |
float exprtk::details::numeric::details::sgn_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1094 | 4.12M | { | 1095 | 4.12M | if (v > T(0)) return T(+1); | 1096 | 1.99M | else if (v < T(0)) return T(-1); | 1097 | 1.99M | else return T( 0); | 1098 | 4.12M | } |
|
1099 | | |
1100 | | template <typename T> |
1101 | | inline T sgn_impl(const T v, int_type_tag) |
1102 | | { |
1103 | | if (v > T(0)) return T(+1); |
1104 | | else if (v < T(0)) return T(-1); |
1105 | | else return T( 0); |
1106 | | } |
1107 | | |
1108 | | template <typename T> |
1109 | | inline T and_impl(const T v0, const T v1, real_type_tag) |
1110 | 12.0k | { |
1111 | 12.0k | return (is_true_impl(v0) && is_true_impl(v1)) ? T(1) : T(0); |
1112 | 12.0k | } double exprtk::details::numeric::details::and_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1110 | 6.04k | { | 1111 | 6.04k | return (is_true_impl(v0) && is_true_impl(v1)) ? T(1) : T(0); | 1112 | 6.04k | } |
float exprtk::details::numeric::details::and_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1110 | 6.02k | { | 1111 | 6.02k | return (is_true_impl(v0) && is_true_impl(v1)) ? T(1) : T(0); | 1112 | 6.02k | } |
|
1113 | | |
1114 | | template <typename T> |
1115 | | inline T and_impl(const T v0, const T v1, int_type_tag) |
1116 | | { |
1117 | | return v0 && v1; |
1118 | | } |
1119 | | |
1120 | | template <typename T> |
1121 | | inline T nand_impl(const T v0, const T v1, real_type_tag) |
1122 | 4.64k | { |
1123 | 4.64k | return (is_false_impl(v0) || is_false_impl(v1)) ? T(1) : T(0); |
1124 | 4.64k | } double exprtk::details::numeric::details::nand_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1122 | 2.32k | { | 1123 | 2.32k | return (is_false_impl(v0) || is_false_impl(v1)) ? T(1) : T(0); | 1124 | 2.32k | } |
float exprtk::details::numeric::details::nand_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1122 | 2.32k | { | 1123 | 2.32k | return (is_false_impl(v0) || is_false_impl(v1)) ? T(1) : T(0); | 1124 | 2.32k | } |
|
1125 | | |
1126 | | template <typename T> |
1127 | | inline T nand_impl(const T v0, const T v1, int_type_tag) |
1128 | | { |
1129 | | return !(v0 && v1); |
1130 | | } |
1131 | | |
1132 | | template <typename T> |
1133 | | inline T or_impl(const T v0, const T v1, real_type_tag) |
1134 | 222 | { |
1135 | 222 | return (is_true_impl(v0) || is_true_impl(v1)) ? T(1) : T(0); |
1136 | 222 | } double exprtk::details::numeric::details::or_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1134 | 111 | { | 1135 | 111 | return (is_true_impl(v0) || is_true_impl(v1)) ? T(1) : T(0); | 1136 | 111 | } |
float exprtk::details::numeric::details::or_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1134 | 111 | { | 1135 | 111 | return (is_true_impl(v0) || is_true_impl(v1)) ? T(1) : T(0); | 1136 | 111 | } |
|
1137 | | |
1138 | | template <typename T> |
1139 | | inline T or_impl(const T v0, const T v1, int_type_tag) |
1140 | | { |
1141 | | return (v0 || v1); |
1142 | | } |
1143 | | |
1144 | | template <typename T> |
1145 | | inline T nor_impl(const T v0, const T v1, real_type_tag) |
1146 | 1.95k | { |
1147 | 1.95k | return (is_false_impl(v0) && is_false_impl(v1)) ? T(1) : T(0); |
1148 | 1.95k | } double exprtk::details::numeric::details::nor_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1146 | 985 | { | 1147 | 985 | return (is_false_impl(v0) && is_false_impl(v1)) ? T(1) : T(0); | 1148 | 985 | } |
float exprtk::details::numeric::details::nor_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1146 | 971 | { | 1147 | 971 | return (is_false_impl(v0) && is_false_impl(v1)) ? T(1) : T(0); | 1148 | 971 | } |
|
1149 | | |
1150 | | template <typename T> |
1151 | | inline T nor_impl(const T v0, const T v1, int_type_tag) |
1152 | | { |
1153 | | return !(v0 || v1); |
1154 | | } |
1155 | | |
1156 | | template <typename T> |
1157 | | inline T xor_impl(const T v0, const T v1, real_type_tag) |
1158 | 251M | { |
1159 | 251M | return (is_false_impl(v0) != is_false_impl(v1)) ? T(1) : T(0); |
1160 | 251M | } double exprtk::details::numeric::details::xor_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1158 | 127M | { | 1159 | 127M | return (is_false_impl(v0) != is_false_impl(v1)) ? T(1) : T(0); | 1160 | 127M | } |
float exprtk::details::numeric::details::xor_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1158 | 123M | { | 1159 | 123M | return (is_false_impl(v0) != is_false_impl(v1)) ? T(1) : T(0); | 1160 | 123M | } |
|
1161 | | |
1162 | | template <typename T> |
1163 | | inline T xor_impl(const T v0, const T v1, int_type_tag) |
1164 | | { |
1165 | | return v0 ^ v1; |
1166 | | } |
1167 | | |
1168 | | template <typename T> |
1169 | | inline T xnor_impl(const T v0, const T v1, real_type_tag) |
1170 | 250M | { |
1171 | 250M | const bool v0_true = is_true_impl(v0); |
1172 | 250M | const bool v1_true = is_true_impl(v1); |
1173 | | |
1174 | 250M | if ((v0_true && v1_true) || (!v0_true && !v1_true)) |
1175 | 153M | return T(1); |
1176 | 97.8M | else |
1177 | 97.8M | return T(0); |
1178 | 250M | } double exprtk::details::numeric::details::xnor_impl<double>(double, double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1170 | 127M | { | 1171 | 127M | const bool v0_true = is_true_impl(v0); | 1172 | 127M | const bool v1_true = is_true_impl(v1); | 1173 | | | 1174 | 127M | if ((v0_true && v1_true) || (!v0_true && !v1_true)) | 1175 | 77.4M | return T(1); | 1176 | 49.6M | else | 1177 | 49.6M | return T(0); | 1178 | 127M | } |
float exprtk::details::numeric::details::xnor_impl<float>(float, float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1170 | 123M | { | 1171 | 123M | const bool v0_true = is_true_impl(v0); | 1172 | 123M | const bool v1_true = is_true_impl(v1); | 1173 | | | 1174 | 123M | if ((v0_true && v1_true) || (!v0_true && !v1_true)) | 1175 | 75.5M | return T(1); | 1176 | 48.2M | else | 1177 | 48.2M | return T(0); | 1178 | 123M | } |
|
1179 | | |
1180 | | template <typename T> |
1181 | | inline T xnor_impl(const T v0, const T v1, int_type_tag) |
1182 | | { |
1183 | | const bool v0_true = is_true_impl(v0); |
1184 | | const bool v1_true = is_true_impl(v1); |
1185 | | |
1186 | | if ((v0_true && v1_true) || (!v0_true && !v1_true)) |
1187 | | return T(1); |
1188 | | else |
1189 | | return T(0); |
1190 | | } |
1191 | | |
1192 | | #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) |
1193 | | #define exprtk_define_erf(TT, impl) \ |
1194 | 1.25M | inline TT erf_impl(const TT v) { return impl(v); } \ exprtk::details::numeric::details::erf_impl(double) Line | Count | Source | 1194 | 702k | inline TT erf_impl(const TT v) { return impl(v); } \ |
exprtk::details::numeric::details::erf_impl(float) Line | Count | Source | 1194 | 554k | inline TT erf_impl(const TT v) { return impl(v); } \ |
Unexecuted instantiation: exprtk::details::numeric::details::erf_impl(long double) |
1195 | | |
1196 | | exprtk_define_erf( float,::erff) |
1197 | | exprtk_define_erf( double,::erf ) |
1198 | | exprtk_define_erf(long double,::erfl) |
1199 | | #undef exprtk_define_erf |
1200 | | #endif |
1201 | | |
1202 | | template <typename T> |
1203 | | inline T erf_impl(const T v, real_type_tag) |
1204 | 1.25M | { |
1205 | | #if defined(_MSC_VER) && (_MSC_VER < 1900) |
1206 | | // Credits: Abramowitz & Stegun Equations 7.1.25-28 |
1207 | | static const T c[] = { |
1208 | | T( 1.26551223), T(1.00002368), |
1209 | | T( 0.37409196), T(0.09678418), |
1210 | | T(-0.18628806), T(0.27886807), |
1211 | | T(-1.13520398), T(1.48851587), |
1212 | | T(-0.82215223), T(0.17087277) |
1213 | | }; |
1214 | | |
1215 | | const T t = T(1) / (T(1) + T(0.5) * abs_impl(v,real_type_tag())); |
1216 | | |
1217 | | const T result = T(1) - t * std::exp((-v * v) - |
1218 | | c[0] + t * (c[1] + t * |
1219 | | (c[2] + t * (c[3] + t * |
1220 | | (c[4] + t * (c[5] + t * |
1221 | | (c[6] + t * (c[7] + t * |
1222 | | (c[8] + t * (c[9])))))))))); |
1223 | | |
1224 | | return (v >= T(0)) ? result : -result; |
1225 | | #else |
1226 | 1.25M | return erf_impl(v); |
1227 | 1.25M | #endif |
1228 | 1.25M | } double exprtk::details::numeric::details::erf_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1204 | 702k | { | 1205 | | #if defined(_MSC_VER) && (_MSC_VER < 1900) | 1206 | | // Credits: Abramowitz & Stegun Equations 7.1.25-28 | 1207 | | static const T c[] = { | 1208 | | T( 1.26551223), T(1.00002368), | 1209 | | T( 0.37409196), T(0.09678418), | 1210 | | T(-0.18628806), T(0.27886807), | 1211 | | T(-1.13520398), T(1.48851587), | 1212 | | T(-0.82215223), T(0.17087277) | 1213 | | }; | 1214 | | | 1215 | | const T t = T(1) / (T(1) + T(0.5) * abs_impl(v,real_type_tag())); | 1216 | | | 1217 | | const T result = T(1) - t * std::exp((-v * v) - | 1218 | | c[0] + t * (c[1] + t * | 1219 | | (c[2] + t * (c[3] + t * | 1220 | | (c[4] + t * (c[5] + t * | 1221 | | (c[6] + t * (c[7] + t * | 1222 | | (c[8] + t * (c[9])))))))))); | 1223 | | | 1224 | | return (v >= T(0)) ? result : -result; | 1225 | | #else | 1226 | 702k | return erf_impl(v); | 1227 | 702k | #endif | 1228 | 702k | } |
float exprtk::details::numeric::details::erf_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1204 | 554k | { | 1205 | | #if defined(_MSC_VER) && (_MSC_VER < 1900) | 1206 | | // Credits: Abramowitz & Stegun Equations 7.1.25-28 | 1207 | | static const T c[] = { | 1208 | | T( 1.26551223), T(1.00002368), | 1209 | | T( 0.37409196), T(0.09678418), | 1210 | | T(-0.18628806), T(0.27886807), | 1211 | | T(-1.13520398), T(1.48851587), | 1212 | | T(-0.82215223), T(0.17087277) | 1213 | | }; | 1214 | | | 1215 | | const T t = T(1) / (T(1) + T(0.5) * abs_impl(v,real_type_tag())); | 1216 | | | 1217 | | const T result = T(1) - t * std::exp((-v * v) - | 1218 | | c[0] + t * (c[1] + t * | 1219 | | (c[2] + t * (c[3] + t * | 1220 | | (c[4] + t * (c[5] + t * | 1221 | | (c[6] + t * (c[7] + t * | 1222 | | (c[8] + t * (c[9])))))))))); | 1223 | | | 1224 | | return (v >= T(0)) ? result : -result; | 1225 | | #else | 1226 | 554k | return erf_impl(v); | 1227 | 554k | #endif | 1228 | 554k | } |
|
1229 | | |
1230 | | template <typename T> |
1231 | | inline T erf_impl(const T v, int_type_tag) |
1232 | | { |
1233 | | return erf_impl(static_cast<double>(v),real_type_tag()); |
1234 | | } |
1235 | | |
1236 | | #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) |
1237 | | #define exprtk_define_erfc(TT, impl) \ |
1238 | 0 | inline TT erfc_impl(const TT v) { return impl(v); } \ Unexecuted instantiation: exprtk::details::numeric::details::erfc_impl(double) Unexecuted instantiation: exprtk::details::numeric::details::erfc_impl(float) Unexecuted instantiation: exprtk::details::numeric::details::erfc_impl(long double) |
1239 | | |
1240 | | exprtk_define_erfc(float ,::erfcf) |
1241 | | exprtk_define_erfc(double ,::erfc ) |
1242 | | exprtk_define_erfc(long double,::erfcl) |
1243 | | #undef exprtk_define_erfc |
1244 | | #endif |
1245 | | |
1246 | | template <typename T> |
1247 | | inline T erfc_impl(const T v, real_type_tag) |
1248 | 0 | { |
1249 | | #if defined(_MSC_VER) && (_MSC_VER < 1900) |
1250 | | return T(1) - erf_impl(v,real_type_tag()); |
1251 | | #else |
1252 | 0 | return erfc_impl(v); |
1253 | 0 | #endif |
1254 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::erfc_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::erfc_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1255 | | |
1256 | | template <typename T> |
1257 | | inline T erfc_impl(const T v, int_type_tag) |
1258 | | { |
1259 | | return erfc_impl(static_cast<double>(v),real_type_tag()); |
1260 | | } |
1261 | | |
1262 | | template <typename T> |
1263 | | inline T ncdf_impl(const T v, real_type_tag) |
1264 | 0 | { |
1265 | 0 | const T cnd = T(0.5) * (T(1) + |
1266 | 0 | erf_impl(abs_impl(v,real_type_tag()) / |
1267 | 0 | T(numeric::constant::sqrt2),real_type_tag())); |
1268 | 0 | return (v < T(0)) ? (T(1) - cnd) : cnd; |
1269 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::details::ncdf_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::ncdf_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1270 | | |
1271 | | template <typename T> |
1272 | | inline T ncdf_impl(const T v, int_type_tag) |
1273 | | { |
1274 | | return ncdf_impl(static_cast<double>(v),real_type_tag()); |
1275 | | } |
1276 | | |
1277 | | template <typename T> |
1278 | | inline T sinc_impl(const T v, real_type_tag) |
1279 | 11.2M | { |
1280 | 11.2M | if (std::abs(v) >= std::numeric_limits<T>::epsilon()) |
1281 | 4.81M | return(std::sin(v) / v); |
1282 | 6.38M | else |
1283 | 6.38M | return T(1); |
1284 | 11.2M | } double exprtk::details::numeric::details::sinc_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1279 | 5.60M | { | 1280 | 5.60M | if (std::abs(v) >= std::numeric_limits<T>::epsilon()) | 1281 | 2.41M | return(std::sin(v) / v); | 1282 | 3.19M | else | 1283 | 3.19M | return T(1); | 1284 | 5.60M | } |
float exprtk::details::numeric::details::sinc_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1279 | 5.60M | { | 1280 | 5.60M | if (std::abs(v) >= std::numeric_limits<T>::epsilon()) | 1281 | 2.40M | return(std::sin(v) / v); | 1282 | 3.19M | else | 1283 | 3.19M | return T(1); | 1284 | 5.60M | } |
|
1285 | | |
1286 | | template <typename T> |
1287 | | inline T sinc_impl(const T v, int_type_tag) |
1288 | | { |
1289 | | return sinc_impl(static_cast<double>(v),real_type_tag()); |
1290 | | } |
1291 | | |
1292 | 2.30M | template <typename T> inline T acos_impl(const T v, real_type_tag) { return std::acos (v); } double exprtk::details::numeric::details::acos_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1292 | 1.10M | template <typename T> inline T acos_impl(const T v, real_type_tag) { return std::acos (v); } |
float exprtk::details::numeric::details::acos_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1292 | 1.20M | template <typename T> inline T acos_impl(const T v, real_type_tag) { return std::acos (v); } |
|
1293 | 18.8M | template <typename T> inline T acosh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) - T(1))); } double exprtk::details::numeric::details::acosh_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1293 | 9.45M | template <typename T> inline T acosh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) - T(1))); } |
float exprtk::details::numeric::details::acosh_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1293 | 9.40M | template <typename T> inline T acosh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) - T(1))); } |
|
1294 | 2 | template <typename T> inline T asin_impl(const T v, real_type_tag) { return std::asin (v); } double exprtk::details::numeric::details::asin_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1294 | 1 | template <typename T> inline T asin_impl(const T v, real_type_tag) { return std::asin (v); } |
float exprtk::details::numeric::details::asin_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1294 | 1 | template <typename T> inline T asin_impl(const T v, real_type_tag) { return std::asin (v); } |
|
1295 | 2.00M | template <typename T> inline T asinh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) + T(1))); } double exprtk::details::numeric::details::asinh_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1295 | 1.00M | template <typename T> inline T asinh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) + T(1))); } |
float exprtk::details::numeric::details::asinh_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1295 | 1.00M | template <typename T> inline T asinh_impl(const T v, real_type_tag) { return std::log(v + std::sqrt((v * v) + T(1))); } |
|
1296 | 200k | template <typename T> inline T atan_impl(const T v, real_type_tag) { return std::atan (v); } double exprtk::details::numeric::details::atan_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1296 | 100k | template <typename T> inline T atan_impl(const T v, real_type_tag) { return std::atan (v); } |
float exprtk::details::numeric::details::atan_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1296 | 100k | template <typename T> inline T atan_impl(const T v, real_type_tag) { return std::atan (v); } |
|
1297 | 4.80M | template <typename T> inline T atanh_impl(const T v, real_type_tag) { return (std::log(T(1) + v) - std::log(T(1) - v)) / T(2); } double exprtk::details::numeric::details::atanh_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1297 | 2.40M | template <typename T> inline T atanh_impl(const T v, real_type_tag) { return (std::log(T(1) + v) - std::log(T(1) - v)) / T(2); } |
float exprtk::details::numeric::details::atanh_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1297 | 2.40M | template <typename T> inline T atanh_impl(const T v, real_type_tag) { return (std::log(T(1) + v) - std::log(T(1) - v)) / T(2); } |
|
1298 | 0 | template <typename T> inline T ceil_impl(const T v, real_type_tag) { return std::ceil (v); } Unexecuted instantiation: double exprtk::details::numeric::details::ceil_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::ceil_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1299 | 23.5M | template <typename T> inline T cos_impl(const T v, real_type_tag) { return std::cos (v); } double exprtk::details::numeric::details::cos_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1299 | 11.3M | template <typename T> inline T cos_impl(const T v, real_type_tag) { return std::cos (v); } |
float exprtk::details::numeric::details::cos_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1299 | 12.2M | template <typename T> inline T cos_impl(const T v, real_type_tag) { return std::cos (v); } |
|
1300 | 25.4M | template <typename T> inline T cosh_impl(const T v, real_type_tag) { return std::cosh (v); } double exprtk::details::numeric::details::cosh_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1300 | 15.2M | template <typename T> inline T cosh_impl(const T v, real_type_tag) { return std::cosh (v); } |
float exprtk::details::numeric::details::cosh_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1300 | 10.2M | template <typename T> inline T cosh_impl(const T v, real_type_tag) { return std::cosh (v); } |
|
1301 | 200k | template <typename T> inline T exp_impl(const T v, real_type_tag) { return std::exp (v); } double exprtk::details::numeric::details::exp_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1301 | 100k | template <typename T> inline T exp_impl(const T v, real_type_tag) { return std::exp (v); } |
float exprtk::details::numeric::details::exp_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1301 | 100k | template <typename T> inline T exp_impl(const T v, real_type_tag) { return std::exp (v); } |
|
1302 | 0 | template <typename T> inline T floor_impl(const T v, real_type_tag) { return std::floor(v); } Unexecuted instantiation: double exprtk::details::numeric::details::floor_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::floor_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1303 | 70.1M | template <typename T> inline T log_impl(const T v, real_type_tag) { return std::log (v); } double exprtk::details::numeric::details::log_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1303 | 38.6M | template <typename T> inline T log_impl(const T v, real_type_tag) { return std::log (v); } |
float exprtk::details::numeric::details::log_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1303 | 31.5M | template <typename T> inline T log_impl(const T v, real_type_tag) { return std::log (v); } |
|
1304 | 14.2M | template <typename T> inline T log10_impl(const T v, real_type_tag) { return std::log10(v); } double exprtk::details::numeric::details::log10_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1304 | 7.10M | template <typename T> inline T log10_impl(const T v, real_type_tag) { return std::log10(v); } |
float exprtk::details::numeric::details::log10_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1304 | 7.10M | template <typename T> inline T log10_impl(const T v, real_type_tag) { return std::log10(v); } |
|
1305 | 200k | template <typename T> inline T log2_impl(const T v, real_type_tag) { return std::log(v)/T(numeric::constant::log2); } double exprtk::details::numeric::details::log2_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1305 | 100k | template <typename T> inline T log2_impl(const T v, real_type_tag) { return std::log(v)/T(numeric::constant::log2); } |
float exprtk::details::numeric::details::log2_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1305 | 100k | template <typename T> inline T log2_impl(const T v, real_type_tag) { return std::log(v)/T(numeric::constant::log2); } |
|
1306 | 428M | template <typename T> inline T neg_impl(const T v, real_type_tag) { return -v; } double exprtk::details::numeric::details::neg_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1306 | 226M | template <typename T> inline T neg_impl(const T v, real_type_tag) { return -v; } |
float exprtk::details::numeric::details::neg_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1306 | 202M | template <typename T> inline T neg_impl(const T v, real_type_tag) { return -v; } |
|
1307 | 0 | template <typename T> inline T pos_impl(const T v, real_type_tag) { return +v; } Unexecuted instantiation: double exprtk::details::numeric::details::pos_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::pos_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1308 | 102k | template <typename T> inline T sin_impl(const T v, real_type_tag) { return std::sin (v); } double exprtk::details::numeric::details::sin_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1308 | 102k | template <typename T> inline T sin_impl(const T v, real_type_tag) { return std::sin (v); } |
float exprtk::details::numeric::details::sin_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1308 | 429 | template <typename T> inline T sin_impl(const T v, real_type_tag) { return std::sin (v); } |
|
1309 | 6.80M | template <typename T> inline T sinh_impl(const T v, real_type_tag) { return std::sinh (v); } double exprtk::details::numeric::details::sinh_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1309 | 3.40M | template <typename T> inline T sinh_impl(const T v, real_type_tag) { return std::sinh (v); } |
float exprtk::details::numeric::details::sinh_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1309 | 3.40M | template <typename T> inline T sinh_impl(const T v, real_type_tag) { return std::sinh (v); } |
|
1310 | 0 | template <typename T> inline T sqrt_impl(const T v, real_type_tag) { return std::sqrt (v); } Unexecuted instantiation: double exprtk::details::numeric::details::sqrt_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::sqrt_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1311 | 2.40M | template <typename T> inline T tan_impl(const T v, real_type_tag) { return std::tan (v); } double exprtk::details::numeric::details::tan_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1311 | 1.20M | template <typename T> inline T tan_impl(const T v, real_type_tag) { return std::tan (v); } |
float exprtk::details::numeric::details::tan_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1311 | 1.20M | template <typename T> inline T tan_impl(const T v, real_type_tag) { return std::tan (v); } |
|
1312 | 6.11M | template <typename T> inline T tanh_impl(const T v, real_type_tag) { return std::tanh (v); } double exprtk::details::numeric::details::tanh_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1312 | 3.20M | template <typename T> inline T tanh_impl(const T v, real_type_tag) { return std::tanh (v); } |
float exprtk::details::numeric::details::tanh_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1312 | 2.90M | template <typename T> inline T tanh_impl(const T v, real_type_tag) { return std::tanh (v); } |
|
1313 | 12.4M | template <typename T> inline T cot_impl(const T v, real_type_tag) { return T(1) / std::tan(v); } double exprtk::details::numeric::details::cot_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1313 | 6.20M | template <typename T> inline T cot_impl(const T v, real_type_tag) { return T(1) / std::tan(v); } |
float exprtk::details::numeric::details::cot_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1313 | 6.20M | template <typename T> inline T cot_impl(const T v, real_type_tag) { return T(1) / std::tan(v); } |
|
1314 | 0 | template <typename T> inline T sec_impl(const T v, real_type_tag) { return T(1) / std::cos(v); } Unexecuted instantiation: double exprtk::details::numeric::details::sec_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::sec_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1315 | 1.80M | template <typename T> inline T csc_impl(const T v, real_type_tag) { return T(1) / std::sin(v); } double exprtk::details::numeric::details::csc_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1315 | 901k | template <typename T> inline T csc_impl(const T v, real_type_tag) { return T(1) / std::sin(v); } |
float exprtk::details::numeric::details::csc_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1315 | 900k | template <typename T> inline T csc_impl(const T v, real_type_tag) { return T(1) / std::sin(v); } |
|
1316 | 0 | template <typename T> inline T r2d_impl(const T v, real_type_tag) { return (v * T(numeric::constant::_180_pi)); } Unexecuted instantiation: double exprtk::details::numeric::details::r2d_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::r2d_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1317 | 0 | template <typename T> inline T d2r_impl(const T v, real_type_tag) { return (v * T(numeric::constant::pi_180)); } Unexecuted instantiation: double exprtk::details::numeric::details::d2r_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::d2r_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1318 | 0 | template <typename T> inline T d2g_impl(const T v, real_type_tag) { return (v * T(10.0/9.0)); } Unexecuted instantiation: double exprtk::details::numeric::details::d2g_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::d2g_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1319 | 0 | template <typename T> inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/10.0)); } Unexecuted instantiation: double exprtk::details::numeric::details::g2d_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::g2d_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1320 | 3.20M | template <typename T> inline T notl_impl(const T v, real_type_tag) { return (std::not_equal_to<T>()(T(0),v) ? T(0) : T(1)); } double exprtk::details::numeric::details::notl_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1320 | 1.60M | template <typename T> inline T notl_impl(const T v, real_type_tag) { return (std::not_equal_to<T>()(T(0),v) ? T(0) : T(1)); } |
float exprtk::details::numeric::details::notl_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1320 | 1.60M | template <typename T> inline T notl_impl(const T v, real_type_tag) { return (std::not_equal_to<T>()(T(0),v) ? T(0) : T(1)); } |
|
1321 | 0 | template <typename T> inline T frac_impl(const T v, real_type_tag) { return (v - static_cast<long long>(v)); } Unexecuted instantiation: double exprtk::details::numeric::details::frac_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Unexecuted instantiation: float exprtk::details::numeric::details::frac_impl<float>(float, exprtk::details::numeric::details::real_type_tag) |
1322 | 76 | template <typename T> inline T trunc_impl(const T v, real_type_tag) { return T(static_cast<long long>(v)); } double exprtk::details::numeric::details::trunc_impl<double>(double, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1322 | 38 | template <typename T> inline T trunc_impl(const T v, real_type_tag) { return T(static_cast<long long>(v)); } |
float exprtk::details::numeric::details::trunc_impl<float>(float, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1322 | 38 | template <typename T> inline T trunc_impl(const T v, real_type_tag) { return T(static_cast<long long>(v)); } |
|
1323 | | |
1324 | 2 | template <typename T> inline T const_pi_impl(real_type_tag) { return T(numeric::constant::pi); } double exprtk::details::numeric::details::const_pi_impl<double>(exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1324 | 1 | template <typename T> inline T const_pi_impl(real_type_tag) { return T(numeric::constant::pi); } |
float exprtk::details::numeric::details::const_pi_impl<float>(exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1324 | 1 | template <typename T> inline T const_pi_impl(real_type_tag) { return T(numeric::constant::pi); } |
|
1325 | | template <typename T> inline T const_e_impl(real_type_tag) { return T(numeric::constant::e); } |
1326 | | template <typename T> inline T const_qnan_impl(real_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1327 | | |
1328 | | template <typename T> inline T abs_impl(const T v, int_type_tag) { return ((v >= T(0)) ? v : -v); } |
1329 | | template <typename T> inline T exp_impl(const T v, int_type_tag) { return std::exp (v); } |
1330 | | template <typename T> inline T log_impl(const T v, int_type_tag) { return std::log (v); } |
1331 | | template <typename T> inline T log10_impl(const T v, int_type_tag) { return std::log10(v); } |
1332 | | template <typename T> inline T log2_impl(const T v, int_type_tag) { return std::log(v)/T(numeric::constant::log2); } |
1333 | | template <typename T> inline T neg_impl(const T v, int_type_tag) { return -v; } |
1334 | | template <typename T> inline T pos_impl(const T v, int_type_tag) { return +v; } |
1335 | | template <typename T> inline T ceil_impl(const T v, int_type_tag) { return v; } |
1336 | | template <typename T> inline T floor_impl(const T v, int_type_tag) { return v; } |
1337 | | template <typename T> inline T round_impl(const T v, int_type_tag) { return v; } |
1338 | | template <typename T> inline T notl_impl(const T v, int_type_tag) { return !v; } |
1339 | | template <typename T> inline T sqrt_impl(const T v, int_type_tag) { return std::sqrt (v); } |
1340 | | template <typename T> inline T frac_impl(const T , int_type_tag) { return T(0); } |
1341 | | template <typename T> inline T trunc_impl(const T v, int_type_tag) { return v; } |
1342 | | template <typename T> inline T acos_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1343 | | template <typename T> inline T acosh_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1344 | | template <typename T> inline T asin_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1345 | | template <typename T> inline T asinh_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1346 | | template <typename T> inline T atan_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1347 | | template <typename T> inline T atanh_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1348 | | template <typename T> inline T cos_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1349 | | template <typename T> inline T cosh_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1350 | | template <typename T> inline T sin_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1351 | | template <typename T> inline T sinh_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1352 | | template <typename T> inline T tan_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1353 | | template <typename T> inline T tanh_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1354 | | template <typename T> inline T cot_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1355 | | template <typename T> inline T sec_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1356 | | template <typename T> inline T csc_impl(const T , int_type_tag) { return std::numeric_limits<T>::quiet_NaN(); } |
1357 | | |
1358 | | template <typename T> |
1359 | | inline bool is_integer_impl(const T& v, real_type_tag) |
1360 | 904k | { |
1361 | 904k | return std::equal_to<T>()(T(0),std::fmod(v,T(1))); |
1362 | 904k | } bool exprtk::details::numeric::details::is_integer_impl<double>(double const&, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1360 | 465k | { | 1361 | 465k | return std::equal_to<T>()(T(0),std::fmod(v,T(1))); | 1362 | 465k | } |
bool exprtk::details::numeric::details::is_integer_impl<float>(float const&, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1360 | 439k | { | 1361 | 439k | return std::equal_to<T>()(T(0),std::fmod(v,T(1))); | 1362 | 439k | } |
|
1363 | | |
1364 | | template <typename T> |
1365 | | inline bool is_integer_impl(const T&, int_type_tag) |
1366 | | { |
1367 | | return true; |
1368 | | } |
1369 | | } |
1370 | | |
1371 | | template <typename Type> |
1372 | | struct numeric_info { enum { length = 0, size = 32, bound_length = 0, min_exp = 0, max_exp = 0 }; }; |
1373 | | |
1374 | | template <> struct numeric_info<int > { enum { length = 10, size = 16, bound_length = 9 }; }; |
1375 | | template <> struct numeric_info<float > { enum { min_exp = -38, max_exp = +38 }; }; |
1376 | | template <> struct numeric_info<double > { enum { min_exp = -308, max_exp = +308 }; }; |
1377 | | template <> struct numeric_info<long double> { enum { min_exp = -308, max_exp = +308 }; }; |
1378 | | |
1379 | | template <typename T> |
1380 | | inline int to_int32(const T v) |
1381 | 874k | { |
1382 | 874k | const typename details::number_type<T>::type num_type; |
1383 | 874k | return to_int32_impl(v, num_type); |
1384 | 874k | } int exprtk::details::numeric::to_int32<double>(double) Line | Count | Source | 1381 | 449k | { | 1382 | 449k | const typename details::number_type<T>::type num_type; | 1383 | 449k | return to_int32_impl(v, num_type); | 1384 | 449k | } |
int exprtk::details::numeric::to_int32<float>(float) Line | Count | Source | 1381 | 424k | { | 1382 | 424k | const typename details::number_type<T>::type num_type; | 1383 | 424k | return to_int32_impl(v, num_type); | 1384 | 424k | } |
|
1385 | | |
1386 | | template <typename T> |
1387 | | inline _int64_t to_int64(const T v) |
1388 | 755 | { |
1389 | 755 | const typename details::number_type<T>::type num_type; |
1390 | 755 | return to_int64_impl(v, num_type); |
1391 | 755 | } long long exprtk::details::numeric::to_int64<double>(double) Line | Count | Source | 1388 | 380 | { | 1389 | 380 | const typename details::number_type<T>::type num_type; | 1390 | 380 | return to_int64_impl(v, num_type); | 1391 | 380 | } |
long long exprtk::details::numeric::to_int64<float>(float) Line | Count | Source | 1388 | 375 | { | 1389 | 375 | const typename details::number_type<T>::type num_type; | 1390 | 375 | return to_int64_impl(v, num_type); | 1391 | 375 | } |
|
1392 | | |
1393 | | template <typename T> |
1394 | | inline bool is_nan(const T v) |
1395 | 801k | { |
1396 | 801k | const typename details::number_type<T>::type num_type; |
1397 | 801k | return is_nan_impl(v, num_type); |
1398 | 801k | } bool exprtk::details::numeric::is_nan<double>(double) Line | Count | Source | 1395 | 400k | { | 1396 | 400k | const typename details::number_type<T>::type num_type; | 1397 | 400k | return is_nan_impl(v, num_type); | 1398 | 400k | } |
bool exprtk::details::numeric::is_nan<float>(float) Line | Count | Source | 1395 | 400k | { | 1396 | 400k | const typename details::number_type<T>::type num_type; | 1397 | 400k | return is_nan_impl(v, num_type); | 1398 | 400k | } |
|
1399 | | |
1400 | | template <typename T> |
1401 | | inline T min(const T v0, const T v1) |
1402 | | { |
1403 | | const typename details::number_type<T>::type num_type; |
1404 | | return min_impl(v0, v1, num_type); |
1405 | | } |
1406 | | |
1407 | | template <typename T> |
1408 | | inline T max(const T v0, const T v1) |
1409 | | { |
1410 | | const typename details::number_type<T>::type num_type; |
1411 | | return max_impl(v0, v1, num_type); |
1412 | | } |
1413 | | |
1414 | | template <typename T> |
1415 | | inline T equal(const T v0, const T v1) |
1416 | 0 | { |
1417 | 0 | const typename details::number_type<T>::type num_type; |
1418 | 0 | return equal_impl(v0, v1, num_type); |
1419 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::equal<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::equal<float>(float, float) |
1420 | | |
1421 | | template <typename T> |
1422 | | inline T nequal(const T v0, const T v1) |
1423 | 0 | { |
1424 | 0 | const typename details::number_type<T>::type num_type; |
1425 | 0 | return nequal_impl(v0, v1, num_type); |
1426 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::nequal<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::nequal<float>(float, float) |
1427 | | |
1428 | | template <typename T> |
1429 | | inline T modulus(const T v0, const T v1) |
1430 | 842M | { |
1431 | 842M | const typename details::number_type<T>::type num_type; |
1432 | 842M | return modulus_impl(v0, v1, num_type); |
1433 | 842M | } double exprtk::details::numeric::modulus<double>(double, double) Line | Count | Source | 1430 | 437M | { | 1431 | 437M | const typename details::number_type<T>::type num_type; | 1432 | 437M | return modulus_impl(v0, v1, num_type); | 1433 | 437M | } |
float exprtk::details::numeric::modulus<float>(float, float) Line | Count | Source | 1430 | 404M | { | 1431 | 404M | const typename details::number_type<T>::type num_type; | 1432 | 404M | return modulus_impl(v0, v1, num_type); | 1433 | 404M | } |
|
1434 | | |
1435 | | template <typename T> |
1436 | | inline T pow(const T v0, const T v1) |
1437 | 651M | { |
1438 | 651M | const typename details::number_type<T>::type num_type; |
1439 | 651M | return pow_impl(v0, v1, num_type); |
1440 | 651M | } double exprtk::details::numeric::pow<double>(double, double) Line | Count | Source | 1437 | 326M | { | 1438 | 326M | const typename details::number_type<T>::type num_type; | 1439 | 326M | return pow_impl(v0, v1, num_type); | 1440 | 326M | } |
float exprtk::details::numeric::pow<float>(float, float) Line | Count | Source | 1437 | 325M | { | 1438 | 325M | const typename details::number_type<T>::type num_type; | 1439 | 325M | return pow_impl(v0, v1, num_type); | 1440 | 325M | } |
|
1441 | | |
1442 | | template <typename T> |
1443 | | inline T logn(const T v0, const T v1) |
1444 | 0 | { |
1445 | 0 | const typename details::number_type<T>::type num_type; |
1446 | 0 | return logn_impl(v0, v1, num_type); |
1447 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::logn<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::logn<float>(float, float) |
1448 | | |
1449 | | template <typename T> |
1450 | | inline T root(const T v0, const T v1) |
1451 | 0 | { |
1452 | 0 | const typename details::number_type<T>::type num_type; |
1453 | 0 | return root_impl(v0, v1, num_type); |
1454 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::root<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::root<float>(float, float) |
1455 | | |
1456 | | template <typename T> |
1457 | | inline T roundn(const T v0, const T v1) |
1458 | 0 | { |
1459 | 0 | const typename details::number_type<T>::type num_type; |
1460 | 0 | return roundn_impl(v0, v1, num_type); |
1461 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::roundn<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::roundn<float>(float, float) |
1462 | | |
1463 | | template <typename T> |
1464 | | inline T hypot(const T v0, const T v1) |
1465 | 0 | { |
1466 | 0 | const typename details::number_type<T>::type num_type; |
1467 | 0 | return hypot_impl(v0, v1, num_type); |
1468 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::hypot<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::hypot<float>(float, float) |
1469 | | |
1470 | | template <typename T> |
1471 | | inline T atan2(const T v0, const T v1) |
1472 | 0 | { |
1473 | 0 | const typename details::number_type<T>::type num_type; |
1474 | 0 | return atan2_impl(v0, v1, num_type); |
1475 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::atan2<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::atan2<float>(float, float) |
1476 | | |
1477 | | template <typename T> |
1478 | | inline T shr(const T v0, const T v1) |
1479 | 0 | { |
1480 | 0 | const typename details::number_type<T>::type num_type; |
1481 | 0 | return shr_impl(v0, v1, num_type); |
1482 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::shr<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::shr<float>(float, float) |
1483 | | |
1484 | | template <typename T> |
1485 | | inline T shl(const T v0, const T v1) |
1486 | 0 | { |
1487 | 0 | const typename details::number_type<T>::type num_type; |
1488 | 0 | return shl_impl(v0, v1, num_type); |
1489 | 0 | } Unexecuted instantiation: double exprtk::details::numeric::shl<double>(double, double) Unexecuted instantiation: float exprtk::details::numeric::shl<float>(float, float) |
1490 | | |
1491 | | template <typename T> |
1492 | | inline T and_opr(const T v0, const T v1) |
1493 | 12.0k | { |
1494 | 12.0k | const typename details::number_type<T>::type num_type; |
1495 | 12.0k | return and_impl(v0, v1, num_type); |
1496 | 12.0k | } double exprtk::details::numeric::and_opr<double>(double, double) Line | Count | Source | 1493 | 6.04k | { | 1494 | 6.04k | const typename details::number_type<T>::type num_type; | 1495 | 6.04k | return and_impl(v0, v1, num_type); | 1496 | 6.04k | } |
float exprtk::details::numeric::and_opr<float>(float, float) Line | Count | Source | 1493 | 6.02k | { | 1494 | 6.02k | const typename details::number_type<T>::type num_type; | 1495 | 6.02k | return and_impl(v0, v1, num_type); | 1496 | 6.02k | } |
|
1497 | | |
1498 | | template <typename T> |
1499 | | inline T nand_opr(const T v0, const T v1) |
1500 | 4.64k | { |
1501 | 4.64k | const typename details::number_type<T>::type num_type; |
1502 | 4.64k | return nand_impl(v0, v1, num_type); |
1503 | 4.64k | } double exprtk::details::numeric::nand_opr<double>(double, double) Line | Count | Source | 1500 | 2.32k | { | 1501 | 2.32k | const typename details::number_type<T>::type num_type; | 1502 | 2.32k | return nand_impl(v0, v1, num_type); | 1503 | 2.32k | } |
float exprtk::details::numeric::nand_opr<float>(float, float) Line | Count | Source | 1500 | 2.32k | { | 1501 | 2.32k | const typename details::number_type<T>::type num_type; | 1502 | 2.32k | return nand_impl(v0, v1, num_type); | 1503 | 2.32k | } |
|
1504 | | |
1505 | | template <typename T> |
1506 | | inline T or_opr(const T v0, const T v1) |
1507 | 222 | { |
1508 | 222 | const typename details::number_type<T>::type num_type; |
1509 | 222 | return or_impl(v0, v1, num_type); |
1510 | 222 | } double exprtk::details::numeric::or_opr<double>(double, double) Line | Count | Source | 1507 | 111 | { | 1508 | 111 | const typename details::number_type<T>::type num_type; | 1509 | 111 | return or_impl(v0, v1, num_type); | 1510 | 111 | } |
float exprtk::details::numeric::or_opr<float>(float, float) Line | Count | Source | 1507 | 111 | { | 1508 | 111 | const typename details::number_type<T>::type num_type; | 1509 | 111 | return or_impl(v0, v1, num_type); | 1510 | 111 | } |
|
1511 | | |
1512 | | template <typename T> |
1513 | | inline T nor_opr(const T v0, const T v1) |
1514 | 1.95k | { |
1515 | 1.95k | const typename details::number_type<T>::type num_type; |
1516 | 1.95k | return nor_impl(v0, v1, num_type); |
1517 | 1.95k | } double exprtk::details::numeric::nor_opr<double>(double, double) Line | Count | Source | 1514 | 985 | { | 1515 | 985 | const typename details::number_type<T>::type num_type; | 1516 | 985 | return nor_impl(v0, v1, num_type); | 1517 | 985 | } |
float exprtk::details::numeric::nor_opr<float>(float, float) Line | Count | Source | 1514 | 971 | { | 1515 | 971 | const typename details::number_type<T>::type num_type; | 1516 | 971 | return nor_impl(v0, v1, num_type); | 1517 | 971 | } |
|
1518 | | |
1519 | | template <typename T> |
1520 | | inline T xor_opr(const T v0, const T v1) |
1521 | 251M | { |
1522 | 251M | const typename details::number_type<T>::type num_type; |
1523 | 251M | return xor_impl(v0, v1, num_type); |
1524 | 251M | } double exprtk::details::numeric::xor_opr<double>(double, double) Line | Count | Source | 1521 | 127M | { | 1522 | 127M | const typename details::number_type<T>::type num_type; | 1523 | 127M | return xor_impl(v0, v1, num_type); | 1524 | 127M | } |
float exprtk::details::numeric::xor_opr<float>(float, float) Line | Count | Source | 1521 | 123M | { | 1522 | 123M | const typename details::number_type<T>::type num_type; | 1523 | 123M | return xor_impl(v0, v1, num_type); | 1524 | 123M | } |
|
1525 | | |
1526 | | template <typename T> |
1527 | | inline T xnor_opr(const T v0, const T v1) |
1528 | 250M | { |
1529 | 250M | const typename details::number_type<T>::type num_type; |
1530 | 250M | return xnor_impl(v0, v1, num_type); |
1531 | 250M | } double exprtk::details::numeric::xnor_opr<double>(double, double) Line | Count | Source | 1528 | 127M | { | 1529 | 127M | const typename details::number_type<T>::type num_type; | 1530 | 127M | return xnor_impl(v0, v1, num_type); | 1531 | 127M | } |
float exprtk::details::numeric::xnor_opr<float>(float, float) Line | Count | Source | 1528 | 123M | { | 1529 | 123M | const typename details::number_type<T>::type num_type; | 1530 | 123M | return xnor_impl(v0, v1, num_type); | 1531 | 123M | } |
|
1532 | | |
1533 | | template <typename T> |
1534 | | inline bool is_integer(const T v) |
1535 | 904k | { |
1536 | 904k | const typename details::number_type<T>::type num_type; |
1537 | 904k | return is_integer_impl(v, num_type); |
1538 | 904k | } bool exprtk::details::numeric::is_integer<double>(double) Line | Count | Source | 1535 | 465k | { | 1536 | 465k | const typename details::number_type<T>::type num_type; | 1537 | 465k | return is_integer_impl(v, num_type); | 1538 | 465k | } |
bool exprtk::details::numeric::is_integer<float>(float) Line | Count | Source | 1535 | 439k | { | 1536 | 439k | const typename details::number_type<T>::type num_type; | 1537 | 439k | return is_integer_impl(v, num_type); | 1538 | 439k | } |
|
1539 | | |
1540 | | template <typename T, unsigned int N> |
1541 | | struct fast_exp |
1542 | | { |
1543 | | static inline T result(T v) |
1544 | 962M | { |
1545 | 962M | unsigned int k = N; |
1546 | 962M | T l = T(1); |
1547 | | |
1548 | 6.33G | while (k) |
1549 | 5.37G | { |
1550 | 5.37G | if (1 == (k % 2)) |
1551 | 3.06G | { |
1552 | 3.06G | l *= v; |
1553 | 3.06G | --k; |
1554 | 3.06G | } |
1555 | | |
1556 | 5.37G | v *= v; |
1557 | 5.37G | k /= 2; |
1558 | 5.37G | } |
1559 | | |
1560 | 962M | return l; |
1561 | 962M | } |
1562 | | }; |
1563 | | |
1564 | 43.8M | template <typename T> struct fast_exp<T,10> { static inline T result(const T v) { T v_5 = fast_exp<T,5>::result(v); return v_5 * v_5; } }; exprtk::details::numeric::fast_exp<double, 10u>::result(double) Line | Count | Source | 1564 | 22.9M | template <typename T> struct fast_exp<T,10> { static inline T result(const T v) { T v_5 = fast_exp<T,5>::result(v); return v_5 * v_5; } }; |
exprtk::details::numeric::fast_exp<float, 10u>::result(float) Line | Count | Source | 1564 | 20.9M | template <typename T> struct fast_exp<T,10> { static inline T result(const T v) { T v_5 = fast_exp<T,5>::result(v); return v_5 * v_5; } }; |
|
1565 | 14.0M | template <typename T> struct fast_exp<T, 9> { static inline T result(const T v) { return fast_exp<T,8>::result(v) * v; } }; exprtk::details::numeric::fast_exp<double, 9u>::result(double) Line | Count | Source | 1565 | 7.22M | template <typename T> struct fast_exp<T, 9> { static inline T result(const T v) { return fast_exp<T,8>::result(v) * v; } }; |
exprtk::details::numeric::fast_exp<float, 9u>::result(float) Line | Count | Source | 1565 | 6.82M | template <typename T> struct fast_exp<T, 9> { static inline T result(const T v) { return fast_exp<T,8>::result(v) * v; } }; |
|
1566 | 34.4M | template <typename T> struct fast_exp<T, 8> { static inline T result(const T v) { T v_4 = fast_exp<T,4>::result(v); return v_4 * v_4; } }; exprtk::details::numeric::fast_exp<double, 8u>::result(double) Line | Count | Source | 1566 | 18.3M | template <typename T> struct fast_exp<T, 8> { static inline T result(const T v) { T v_4 = fast_exp<T,4>::result(v); return v_4 * v_4; } }; |
exprtk::details::numeric::fast_exp<float, 8u>::result(float) Line | Count | Source | 1566 | 16.0M | template <typename T> struct fast_exp<T, 8> { static inline T result(const T v) { T v_4 = fast_exp<T,4>::result(v); return v_4 * v_4; } }; |
|
1567 | 151M | template <typename T> struct fast_exp<T, 7> { static inline T result(const T v) { return fast_exp<T,6>::result(v) * v; } }; exprtk::details::numeric::fast_exp<double, 7u>::result(double) Line | Count | Source | 1567 | 73.6M | template <typename T> struct fast_exp<T, 7> { static inline T result(const T v) { return fast_exp<T,6>::result(v) * v; } }; |
exprtk::details::numeric::fast_exp<float, 7u>::result(float) Line | Count | Source | 1567 | 77.3M | template <typename T> struct fast_exp<T, 7> { static inline T result(const T v) { return fast_exp<T,6>::result(v) * v; } }; |
|
1568 | 178M | template <typename T> struct fast_exp<T, 6> { static inline T result(const T v) { T v_3 = fast_exp<T,3>::result(v); return v_3 * v_3; } }; exprtk::details::numeric::fast_exp<double, 6u>::result(double) Line | Count | Source | 1568 | 86.4M | template <typename T> struct fast_exp<T, 6> { static inline T result(const T v) { T v_3 = fast_exp<T,3>::result(v); return v_3 * v_3; } }; |
exprtk::details::numeric::fast_exp<float, 6u>::result(float) Line | Count | Source | 1568 | 91.7M | template <typename T> struct fast_exp<T, 6> { static inline T result(const T v) { T v_3 = fast_exp<T,3>::result(v); return v_3 * v_3; } }; |
|
1569 | 93.7M | template <typename T> struct fast_exp<T, 5> { static inline T result(const T v) { return fast_exp<T,4>::result(v) * v; } }; exprtk::details::numeric::fast_exp<double, 5u>::result(double) Line | Count | Source | 1569 | 50.3M | template <typename T> struct fast_exp<T, 5> { static inline T result(const T v) { return fast_exp<T,4>::result(v) * v; } }; |
exprtk::details::numeric::fast_exp<float, 5u>::result(float) Line | Count | Source | 1569 | 43.3M | template <typename T> struct fast_exp<T, 5> { static inline T result(const T v) { return fast_exp<T,4>::result(v) * v; } }; |
|
1570 | 153M | template <typename T> struct fast_exp<T, 4> { static inline T result(const T v) { T v_2 = v * v; return v_2 * v_2; } }; exprtk::details::numeric::fast_exp<double, 4u>::result(double) Line | Count | Source | 1570 | 81.9M | template <typename T> struct fast_exp<T, 4> { static inline T result(const T v) { T v_2 = v * v; return v_2 * v_2; } }; |
exprtk::details::numeric::fast_exp<float, 4u>::result(float) Line | Count | Source | 1570 | 71.0M | template <typename T> struct fast_exp<T, 4> { static inline T result(const T v) { T v_2 = v * v; return v_2 * v_2; } }; |
|
1571 | 224M | template <typename T> struct fast_exp<T, 3> { static inline T result(const T v) { return v * v * v; } }; exprtk::details::numeric::fast_exp<double, 3u>::result(double) Line | Count | Source | 1571 | 109M | template <typename T> struct fast_exp<T, 3> { static inline T result(const T v) { return v * v * v; } }; |
exprtk::details::numeric::fast_exp<float, 3u>::result(float) Line | Count | Source | 1571 | 115M | template <typename T> struct fast_exp<T, 3> { static inline T result(const T v) { return v * v * v; } }; |
|
1572 | 20.5M | template <typename T> struct fast_exp<T, 2> { static inline T result(const T v) { return v * v; } }; exprtk::details::numeric::fast_exp<double, 2u>::result(double) Line | Count | Source | 1572 | 10.9M | template <typename T> struct fast_exp<T, 2> { static inline T result(const T v) { return v * v; } }; |
exprtk::details::numeric::fast_exp<float, 2u>::result(float) Line | Count | Source | 1572 | 9.61M | template <typename T> struct fast_exp<T, 2> { static inline T result(const T v) { return v * v; } }; |
|
1573 | 18.0M | template <typename T> struct fast_exp<T, 1> { static inline T result(const T v) { return v; } }; exprtk::details::numeric::fast_exp<double, 1u>::result(double) Line | Count | Source | 1573 | 8.71M | template <typename T> struct fast_exp<T, 1> { static inline T result(const T v) { return v; } }; |
exprtk::details::numeric::fast_exp<float, 1u>::result(float) Line | Count | Source | 1573 | 9.30M | template <typename T> struct fast_exp<T, 1> { static inline T result(const T v) { return v; } }; |
|
1574 | | template <typename T> struct fast_exp<T, 0> { static inline T result(const T ) { return T(1); } }; |
1575 | | |
1576 | | #define exprtk_define_unary_function(FunctionName) \ |
1577 | | template <typename T> \ |
1578 | | inline T FunctionName (const T v) \ |
1579 | 676M | { \ |
1580 | 676M | const typename details::number_type<T>::type num_type; \ |
1581 | 676M | return FunctionName##_impl(v,num_type); \ |
1582 | 676M | } \ double exprtk::details::numeric::abs<double>(double) Line | Count | Source | 1579 | 9.89M | { \ | 1580 | 9.89M | const typename details::number_type<T>::type num_type; \ | 1581 | 9.89M | return FunctionName##_impl(v,num_type); \ | 1582 | 9.89M | } \ |
double exprtk::details::numeric::acos<double>(double) Line | Count | Source | 1579 | 1.10M | { \ | 1580 | 1.10M | const typename details::number_type<T>::type num_type; \ | 1581 | 1.10M | return FunctionName##_impl(v,num_type); \ | 1582 | 1.10M | } \ |
double exprtk::details::numeric::acosh<double>(double) Line | Count | Source | 1579 | 9.45M | { \ | 1580 | 9.45M | const typename details::number_type<T>::type num_type; \ | 1581 | 9.45M | return FunctionName##_impl(v,num_type); \ | 1582 | 9.45M | } \ |
double exprtk::details::numeric::asin<double>(double) Line | Count | Source | 1579 | 1 | { \ | 1580 | 1 | const typename details::number_type<T>::type num_type; \ | 1581 | 1 | return FunctionName##_impl(v,num_type); \ | 1582 | 1 | } \ |
double exprtk::details::numeric::asinh<double>(double) Line | Count | Source | 1579 | 1.00M | { \ | 1580 | 1.00M | const typename details::number_type<T>::type num_type; \ | 1581 | 1.00M | return FunctionName##_impl(v,num_type); \ | 1582 | 1.00M | } \ |
double exprtk::details::numeric::atanh<double>(double) Line | Count | Source | 1579 | 2.40M | { \ | 1580 | 2.40M | const typename details::number_type<T>::type num_type; \ | 1581 | 2.40M | return FunctionName##_impl(v,num_type); \ | 1582 | 2.40M | } \ |
Unexecuted instantiation: double exprtk::details::numeric::ceil<double>(double) double exprtk::details::numeric::cos<double>(double) Line | Count | Source | 1579 | 11.3M | { \ | 1580 | 11.3M | const typename details::number_type<T>::type num_type; \ | 1581 | 11.3M | return FunctionName##_impl(v,num_type); \ | 1582 | 11.3M | } \ |
double exprtk::details::numeric::cosh<double>(double) Line | Count | Source | 1579 | 15.2M | { \ | 1580 | 15.2M | const typename details::number_type<T>::type num_type; \ | 1581 | 15.2M | return FunctionName##_impl(v,num_type); \ | 1582 | 15.2M | } \ |
double exprtk::details::numeric::exp<double>(double) Line | Count | Source | 1579 | 100k | { \ | 1580 | 100k | const typename details::number_type<T>::type num_type; \ | 1581 | 100k | return FunctionName##_impl(v,num_type); \ | 1582 | 100k | } \ |
Unexecuted instantiation: double exprtk::details::numeric::expm1<double>(double) Unexecuted instantiation: double exprtk::details::numeric::floor<double>(double) double exprtk::details::numeric::log<double>(double) Line | Count | Source | 1579 | 38.6M | { \ | 1580 | 38.6M | const typename details::number_type<T>::type num_type; \ | 1581 | 38.6M | return FunctionName##_impl(v,num_type); \ | 1582 | 38.6M | } \ |
double exprtk::details::numeric::log10<double>(double) Line | Count | Source | 1579 | 7.10M | { \ | 1580 | 7.10M | const typename details::number_type<T>::type num_type; \ | 1581 | 7.10M | return FunctionName##_impl(v,num_type); \ | 1582 | 7.10M | } \ |
double exprtk::details::numeric::log2<double>(double) Line | Count | Source | 1579 | 100k | { \ | 1580 | 100k | const typename details::number_type<T>::type num_type; \ | 1581 | 100k | return FunctionName##_impl(v,num_type); \ | 1582 | 100k | } \ |
double exprtk::details::numeric::log1p<double>(double) Line | Count | Source | 1579 | 6.71M | { \ | 1580 | 6.71M | const typename details::number_type<T>::type num_type; \ | 1581 | 6.71M | return FunctionName##_impl(v,num_type); \ | 1582 | 6.71M | } \ |
double exprtk::details::numeric::neg<double>(double) Line | Count | Source | 1579 | 226M | { \ | 1580 | 226M | const typename details::number_type<T>::type num_type; \ | 1581 | 226M | return FunctionName##_impl(v,num_type); \ | 1582 | 226M | } \ |
Unexecuted instantiation: double exprtk::details::numeric::pos<double>(double) Unexecuted instantiation: double exprtk::details::numeric::round<double>(double) double exprtk::details::numeric::sin<double>(double) Line | Count | Source | 1579 | 102k | { \ | 1580 | 102k | const typename details::number_type<T>::type num_type; \ | 1581 | 102k | return FunctionName##_impl(v,num_type); \ | 1582 | 102k | } \ |
double exprtk::details::numeric::sinc<double>(double) Line | Count | Source | 1579 | 5.60M | { \ | 1580 | 5.60M | const typename details::number_type<T>::type num_type; \ | 1581 | 5.60M | return FunctionName##_impl(v,num_type); \ | 1582 | 5.60M | } \ |
double exprtk::details::numeric::sinh<double>(double) Line | Count | Source | 1579 | 3.40M | { \ | 1580 | 3.40M | const typename details::number_type<T>::type num_type; \ | 1581 | 3.40M | return FunctionName##_impl(v,num_type); \ | 1582 | 3.40M | } \ |
Unexecuted instantiation: double exprtk::details::numeric::sqrt<double>(double) double exprtk::details::numeric::tan<double>(double) Line | Count | Source | 1579 | 1.20M | { \ | 1580 | 1.20M | const typename details::number_type<T>::type num_type; \ | 1581 | 1.20M | return FunctionName##_impl(v,num_type); \ | 1582 | 1.20M | } \ |
double exprtk::details::numeric::tanh<double>(double) Line | Count | Source | 1579 | 3.20M | { \ | 1580 | 3.20M | const typename details::number_type<T>::type num_type; \ | 1581 | 3.20M | return FunctionName##_impl(v,num_type); \ | 1582 | 3.20M | } \ |
double exprtk::details::numeric::cot<double>(double) Line | Count | Source | 1579 | 6.20M | { \ | 1580 | 6.20M | const typename details::number_type<T>::type num_type; \ | 1581 | 6.20M | return FunctionName##_impl(v,num_type); \ | 1582 | 6.20M | } \ |
Unexecuted instantiation: double exprtk::details::numeric::sec<double>(double) double exprtk::details::numeric::csc<double>(double) Line | Count | Source | 1579 | 901k | { \ | 1580 | 901k | const typename details::number_type<T>::type num_type; \ | 1581 | 901k | return FunctionName##_impl(v,num_type); \ | 1582 | 901k | } \ |
Unexecuted instantiation: double exprtk::details::numeric::r2d<double>(double) Unexecuted instantiation: double exprtk::details::numeric::d2r<double>(double) Unexecuted instantiation: double exprtk::details::numeric::d2g<double>(double) Unexecuted instantiation: double exprtk::details::numeric::g2d<double>(double) double exprtk::details::numeric::notl<double>(double) Line | Count | Source | 1579 | 1.60M | { \ | 1580 | 1.60M | const typename details::number_type<T>::type num_type; \ | 1581 | 1.60M | return FunctionName##_impl(v,num_type); \ | 1582 | 1.60M | } \ |
double exprtk::details::numeric::sgn<double>(double) Line | Count | Source | 1579 | 4.70M | { \ | 1580 | 4.70M | const typename details::number_type<T>::type num_type; \ | 1581 | 4.70M | return FunctionName##_impl(v,num_type); \ | 1582 | 4.70M | } \ |
double exprtk::details::numeric::erf<double>(double) Line | Count | Source | 1579 | 702k | { \ | 1580 | 702k | const typename details::number_type<T>::type num_type; \ | 1581 | 702k | return FunctionName##_impl(v,num_type); \ | 1582 | 702k | } \ |
Unexecuted instantiation: double exprtk::details::numeric::erfc<double>(double) Unexecuted instantiation: double exprtk::details::numeric::ncdf<double>(double) Unexecuted instantiation: double exprtk::details::numeric::frac<double>(double) double exprtk::details::numeric::trunc<double>(double) Line | Count | Source | 1579 | 38 | { \ | 1580 | 38 | const typename details::number_type<T>::type num_type; \ | 1581 | 38 | return FunctionName##_impl(v,num_type); \ | 1582 | 38 | } \ |
double exprtk::details::numeric::atan<double>(double) Line | Count | Source | 1579 | 100k | { \ | 1580 | 100k | const typename details::number_type<T>::type num_type; \ | 1581 | 100k | return FunctionName##_impl(v,num_type); \ | 1582 | 100k | } \ |
float exprtk::details::numeric::abs<float>(float) Line | Count | Source | 1579 | 9.13M | { \ | 1580 | 9.13M | const typename details::number_type<T>::type num_type; \ | 1581 | 9.13M | return FunctionName##_impl(v,num_type); \ | 1582 | 9.13M | } \ |
float exprtk::details::numeric::acos<float>(float) Line | Count | Source | 1579 | 1.20M | { \ | 1580 | 1.20M | const typename details::number_type<T>::type num_type; \ | 1581 | 1.20M | return FunctionName##_impl(v,num_type); \ | 1582 | 1.20M | } \ |
float exprtk::details::numeric::acosh<float>(float) Line | Count | Source | 1579 | 9.40M | { \ | 1580 | 9.40M | const typename details::number_type<T>::type num_type; \ | 1581 | 9.40M | return FunctionName##_impl(v,num_type); \ | 1582 | 9.40M | } \ |
float exprtk::details::numeric::asin<float>(float) Line | Count | Source | 1579 | 1 | { \ | 1580 | 1 | const typename details::number_type<T>::type num_type; \ | 1581 | 1 | return FunctionName##_impl(v,num_type); \ | 1582 | 1 | } \ |
float exprtk::details::numeric::asinh<float>(float) Line | Count | Source | 1579 | 1.00M | { \ | 1580 | 1.00M | const typename details::number_type<T>::type num_type; \ | 1581 | 1.00M | return FunctionName##_impl(v,num_type); \ | 1582 | 1.00M | } \ |
float exprtk::details::numeric::atanh<float>(float) Line | Count | Source | 1579 | 2.40M | { \ | 1580 | 2.40M | const typename details::number_type<T>::type num_type; \ | 1581 | 2.40M | return FunctionName##_impl(v,num_type); \ | 1582 | 2.40M | } \ |
Unexecuted instantiation: float exprtk::details::numeric::ceil<float>(float) float exprtk::details::numeric::cos<float>(float) Line | Count | Source | 1579 | 12.2M | { \ | 1580 | 12.2M | const typename details::number_type<T>::type num_type; \ | 1581 | 12.2M | return FunctionName##_impl(v,num_type); \ | 1582 | 12.2M | } \ |
float exprtk::details::numeric::cosh<float>(float) Line | Count | Source | 1579 | 10.2M | { \ | 1580 | 10.2M | const typename details::number_type<T>::type num_type; \ | 1581 | 10.2M | return FunctionName##_impl(v,num_type); \ | 1582 | 10.2M | } \ |
float exprtk::details::numeric::exp<float>(float) Line | Count | Source | 1579 | 100k | { \ | 1580 | 100k | const typename details::number_type<T>::type num_type; \ | 1581 | 100k | return FunctionName##_impl(v,num_type); \ | 1582 | 100k | } \ |
Unexecuted instantiation: float exprtk::details::numeric::expm1<float>(float) Unexecuted instantiation: float exprtk::details::numeric::floor<float>(float) float exprtk::details::numeric::log<float>(float) Line | Count | Source | 1579 | 31.5M | { \ | 1580 | 31.5M | const typename details::number_type<T>::type num_type; \ | 1581 | 31.5M | return FunctionName##_impl(v,num_type); \ | 1582 | 31.5M | } \ |
float exprtk::details::numeric::log10<float>(float) Line | Count | Source | 1579 | 7.10M | { \ | 1580 | 7.10M | const typename details::number_type<T>::type num_type; \ | 1581 | 7.10M | return FunctionName##_impl(v,num_type); \ | 1582 | 7.10M | } \ |
float exprtk::details::numeric::log2<float>(float) Line | Count | Source | 1579 | 100k | { \ | 1580 | 100k | const typename details::number_type<T>::type num_type; \ | 1581 | 100k | return FunctionName##_impl(v,num_type); \ | 1582 | 100k | } \ |
float exprtk::details::numeric::log1p<float>(float) Line | Count | Source | 1579 | 6.20M | { \ | 1580 | 6.20M | const typename details::number_type<T>::type num_type; \ | 1581 | 6.20M | return FunctionName##_impl(v,num_type); \ | 1582 | 6.20M | } \ |
float exprtk::details::numeric::neg<float>(float) Line | Count | Source | 1579 | 202M | { \ | 1580 | 202M | const typename details::number_type<T>::type num_type; \ | 1581 | 202M | return FunctionName##_impl(v,num_type); \ | 1582 | 202M | } \ |
Unexecuted instantiation: float exprtk::details::numeric::pos<float>(float) Unexecuted instantiation: float exprtk::details::numeric::round<float>(float) float exprtk::details::numeric::sin<float>(float) Line | Count | Source | 1579 | 429 | { \ | 1580 | 429 | const typename details::number_type<T>::type num_type; \ | 1581 | 429 | return FunctionName##_impl(v,num_type); \ | 1582 | 429 | } \ |
float exprtk::details::numeric::sinc<float>(float) Line | Count | Source | 1579 | 5.60M | { \ | 1580 | 5.60M | const typename details::number_type<T>::type num_type; \ | 1581 | 5.60M | return FunctionName##_impl(v,num_type); \ | 1582 | 5.60M | } \ |
float exprtk::details::numeric::sinh<float>(float) Line | Count | Source | 1579 | 3.40M | { \ | 1580 | 3.40M | const typename details::number_type<T>::type num_type; \ | 1581 | 3.40M | return FunctionName##_impl(v,num_type); \ | 1582 | 3.40M | } \ |
Unexecuted instantiation: float exprtk::details::numeric::sqrt<float>(float) float exprtk::details::numeric::tan<float>(float) Line | Count | Source | 1579 | 1.20M | { \ | 1580 | 1.20M | const typename details::number_type<T>::type num_type; \ | 1581 | 1.20M | return FunctionName##_impl(v,num_type); \ | 1582 | 1.20M | } \ |
float exprtk::details::numeric::tanh<float>(float) Line | Count | Source | 1579 | 2.90M | { \ | 1580 | 2.90M | const typename details::number_type<T>::type num_type; \ | 1581 | 2.90M | return FunctionName##_impl(v,num_type); \ | 1582 | 2.90M | } \ |
float exprtk::details::numeric::cot<float>(float) Line | Count | Source | 1579 | 6.20M | { \ | 1580 | 6.20M | const typename details::number_type<T>::type num_type; \ | 1581 | 6.20M | return FunctionName##_impl(v,num_type); \ | 1582 | 6.20M | } \ |
Unexecuted instantiation: float exprtk::details::numeric::sec<float>(float) float exprtk::details::numeric::csc<float>(float) Line | Count | Source | 1579 | 900k | { \ | 1580 | 900k | const typename details::number_type<T>::type num_type; \ | 1581 | 900k | return FunctionName##_impl(v,num_type); \ | 1582 | 900k | } \ |
Unexecuted instantiation: float exprtk::details::numeric::r2d<float>(float) Unexecuted instantiation: float exprtk::details::numeric::d2r<float>(float) Unexecuted instantiation: float exprtk::details::numeric::d2g<float>(float) Unexecuted instantiation: float exprtk::details::numeric::g2d<float>(float) float exprtk::details::numeric::notl<float>(float) Line | Count | Source | 1579 | 1.60M | { \ | 1580 | 1.60M | const typename details::number_type<T>::type num_type; \ | 1581 | 1.60M | return FunctionName##_impl(v,num_type); \ | 1582 | 1.60M | } \ |
float exprtk::details::numeric::sgn<float>(float) Line | Count | Source | 1579 | 4.12M | { \ | 1580 | 4.12M | const typename details::number_type<T>::type num_type; \ | 1581 | 4.12M | return FunctionName##_impl(v,num_type); \ | 1582 | 4.12M | } \ |
float exprtk::details::numeric::erf<float>(float) Line | Count | Source | 1579 | 554k | { \ | 1580 | 554k | const typename details::number_type<T>::type num_type; \ | 1581 | 554k | return FunctionName##_impl(v,num_type); \ | 1582 | 554k | } \ |
Unexecuted instantiation: float exprtk::details::numeric::erfc<float>(float) Unexecuted instantiation: float exprtk::details::numeric::ncdf<float>(float) Unexecuted instantiation: float exprtk::details::numeric::frac<float>(float) float exprtk::details::numeric::trunc<float>(float) Line | Count | Source | 1579 | 38 | { \ | 1580 | 38 | const typename details::number_type<T>::type num_type; \ | 1581 | 38 | return FunctionName##_impl(v,num_type); \ | 1582 | 38 | } \ |
float exprtk::details::numeric::atan<float>(float) Line | Count | Source | 1579 | 100k | { \ | 1580 | 100k | const typename details::number_type<T>::type num_type; \ | 1581 | 100k | return FunctionName##_impl(v,num_type); \ | 1582 | 100k | } \ |
|
1583 | | |
1584 | | exprtk_define_unary_function(abs ) |
1585 | | exprtk_define_unary_function(acos ) |
1586 | | exprtk_define_unary_function(acosh) |
1587 | | exprtk_define_unary_function(asin ) |
1588 | | exprtk_define_unary_function(asinh) |
1589 | | exprtk_define_unary_function(atan ) |
1590 | | exprtk_define_unary_function(atanh) |
1591 | | exprtk_define_unary_function(ceil ) |
1592 | | exprtk_define_unary_function(cos ) |
1593 | | exprtk_define_unary_function(cosh ) |
1594 | | exprtk_define_unary_function(exp ) |
1595 | | exprtk_define_unary_function(expm1) |
1596 | | exprtk_define_unary_function(floor) |
1597 | | exprtk_define_unary_function(log ) |
1598 | | exprtk_define_unary_function(log10) |
1599 | | exprtk_define_unary_function(log2 ) |
1600 | | exprtk_define_unary_function(log1p) |
1601 | | exprtk_define_unary_function(neg ) |
1602 | | exprtk_define_unary_function(pos ) |
1603 | | exprtk_define_unary_function(round) |
1604 | | exprtk_define_unary_function(sin ) |
1605 | | exprtk_define_unary_function(sinc ) |
1606 | | exprtk_define_unary_function(sinh ) |
1607 | | exprtk_define_unary_function(sqrt ) |
1608 | | exprtk_define_unary_function(tan ) |
1609 | | exprtk_define_unary_function(tanh ) |
1610 | | exprtk_define_unary_function(cot ) |
1611 | | exprtk_define_unary_function(sec ) |
1612 | | exprtk_define_unary_function(csc ) |
1613 | | exprtk_define_unary_function(r2d ) |
1614 | | exprtk_define_unary_function(d2r ) |
1615 | | exprtk_define_unary_function(d2g ) |
1616 | | exprtk_define_unary_function(g2d ) |
1617 | | exprtk_define_unary_function(notl ) |
1618 | | exprtk_define_unary_function(sgn ) |
1619 | | exprtk_define_unary_function(erf ) |
1620 | | exprtk_define_unary_function(erfc ) |
1621 | | exprtk_define_unary_function(ncdf ) |
1622 | | exprtk_define_unary_function(frac ) |
1623 | | exprtk_define_unary_function(trunc) |
1624 | | #undef exprtk_define_unary_function |
1625 | | } |
1626 | | |
1627 | | template <typename T> |
1628 | | inline T compute_pow10(T d, const int exponent) |
1629 | 194k | { |
1630 | 194k | static const double fract10[] = |
1631 | 194k | { |
1632 | 194k | 0.0, |
1633 | 194k | 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, 1.0E+009, 1.0E+010, |
1634 | 194k | 1.0E+011, 1.0E+012, 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016, 1.0E+017, 1.0E+018, 1.0E+019, 1.0E+020, |
1635 | 194k | 1.0E+021, 1.0E+022, 1.0E+023, 1.0E+024, 1.0E+025, 1.0E+026, 1.0E+027, 1.0E+028, 1.0E+029, 1.0E+030, |
1636 | 194k | 1.0E+031, 1.0E+032, 1.0E+033, 1.0E+034, 1.0E+035, 1.0E+036, 1.0E+037, 1.0E+038, 1.0E+039, 1.0E+040, |
1637 | 194k | 1.0E+041, 1.0E+042, 1.0E+043, 1.0E+044, 1.0E+045, 1.0E+046, 1.0E+047, 1.0E+048, 1.0E+049, 1.0E+050, |
1638 | 194k | 1.0E+051, 1.0E+052, 1.0E+053, 1.0E+054, 1.0E+055, 1.0E+056, 1.0E+057, 1.0E+058, 1.0E+059, 1.0E+060, |
1639 | 194k | 1.0E+061, 1.0E+062, 1.0E+063, 1.0E+064, 1.0E+065, 1.0E+066, 1.0E+067, 1.0E+068, 1.0E+069, 1.0E+070, |
1640 | 194k | 1.0E+071, 1.0E+072, 1.0E+073, 1.0E+074, 1.0E+075, 1.0E+076, 1.0E+077, 1.0E+078, 1.0E+079, 1.0E+080, |
1641 | 194k | 1.0E+081, 1.0E+082, 1.0E+083, 1.0E+084, 1.0E+085, 1.0E+086, 1.0E+087, 1.0E+088, 1.0E+089, 1.0E+090, |
1642 | 194k | 1.0E+091, 1.0E+092, 1.0E+093, 1.0E+094, 1.0E+095, 1.0E+096, 1.0E+097, 1.0E+098, 1.0E+099, 1.0E+100, |
1643 | 194k | 1.0E+101, 1.0E+102, 1.0E+103, 1.0E+104, 1.0E+105, 1.0E+106, 1.0E+107, 1.0E+108, 1.0E+109, 1.0E+110, |
1644 | 194k | 1.0E+111, 1.0E+112, 1.0E+113, 1.0E+114, 1.0E+115, 1.0E+116, 1.0E+117, 1.0E+118, 1.0E+119, 1.0E+120, |
1645 | 194k | 1.0E+121, 1.0E+122, 1.0E+123, 1.0E+124, 1.0E+125, 1.0E+126, 1.0E+127, 1.0E+128, 1.0E+129, 1.0E+130, |
1646 | 194k | 1.0E+131, 1.0E+132, 1.0E+133, 1.0E+134, 1.0E+135, 1.0E+136, 1.0E+137, 1.0E+138, 1.0E+139, 1.0E+140, |
1647 | 194k | 1.0E+141, 1.0E+142, 1.0E+143, 1.0E+144, 1.0E+145, 1.0E+146, 1.0E+147, 1.0E+148, 1.0E+149, 1.0E+150, |
1648 | 194k | 1.0E+151, 1.0E+152, 1.0E+153, 1.0E+154, 1.0E+155, 1.0E+156, 1.0E+157, 1.0E+158, 1.0E+159, 1.0E+160, |
1649 | 194k | 1.0E+161, 1.0E+162, 1.0E+163, 1.0E+164, 1.0E+165, 1.0E+166, 1.0E+167, 1.0E+168, 1.0E+169, 1.0E+170, |
1650 | 194k | 1.0E+171, 1.0E+172, 1.0E+173, 1.0E+174, 1.0E+175, 1.0E+176, 1.0E+177, 1.0E+178, 1.0E+179, 1.0E+180, |
1651 | 194k | 1.0E+181, 1.0E+182, 1.0E+183, 1.0E+184, 1.0E+185, 1.0E+186, 1.0E+187, 1.0E+188, 1.0E+189, 1.0E+190, |
1652 | 194k | 1.0E+191, 1.0E+192, 1.0E+193, 1.0E+194, 1.0E+195, 1.0E+196, 1.0E+197, 1.0E+198, 1.0E+199, 1.0E+200, |
1653 | 194k | 1.0E+201, 1.0E+202, 1.0E+203, 1.0E+204, 1.0E+205, 1.0E+206, 1.0E+207, 1.0E+208, 1.0E+209, 1.0E+210, |
1654 | 194k | 1.0E+211, 1.0E+212, 1.0E+213, 1.0E+214, 1.0E+215, 1.0E+216, 1.0E+217, 1.0E+218, 1.0E+219, 1.0E+220, |
1655 | 194k | 1.0E+221, 1.0E+222, 1.0E+223, 1.0E+224, 1.0E+225, 1.0E+226, 1.0E+227, 1.0E+228, 1.0E+229, 1.0E+230, |
1656 | 194k | 1.0E+231, 1.0E+232, 1.0E+233, 1.0E+234, 1.0E+235, 1.0E+236, 1.0E+237, 1.0E+238, 1.0E+239, 1.0E+240, |
1657 | 194k | 1.0E+241, 1.0E+242, 1.0E+243, 1.0E+244, 1.0E+245, 1.0E+246, 1.0E+247, 1.0E+248, 1.0E+249, 1.0E+250, |
1658 | 194k | 1.0E+251, 1.0E+252, 1.0E+253, 1.0E+254, 1.0E+255, 1.0E+256, 1.0E+257, 1.0E+258, 1.0E+259, 1.0E+260, |
1659 | 194k | 1.0E+261, 1.0E+262, 1.0E+263, 1.0E+264, 1.0E+265, 1.0E+266, 1.0E+267, 1.0E+268, 1.0E+269, 1.0E+270, |
1660 | 194k | 1.0E+271, 1.0E+272, 1.0E+273, 1.0E+274, 1.0E+275, 1.0E+276, 1.0E+277, 1.0E+278, 1.0E+279, 1.0E+280, |
1661 | 194k | 1.0E+281, 1.0E+282, 1.0E+283, 1.0E+284, 1.0E+285, 1.0E+286, 1.0E+287, 1.0E+288, 1.0E+289, 1.0E+290, |
1662 | 194k | 1.0E+291, 1.0E+292, 1.0E+293, 1.0E+294, 1.0E+295, 1.0E+296, 1.0E+297, 1.0E+298, 1.0E+299, 1.0E+300, |
1663 | 194k | 1.0E+301, 1.0E+302, 1.0E+303, 1.0E+304, 1.0E+305, 1.0E+306, 1.0E+307, 1.0E+308 |
1664 | 194k | }; |
1665 | | |
1666 | 194k | static const int fract10_size = static_cast<int>(sizeof(fract10) / sizeof(double)); |
1667 | | |
1668 | 194k | const int e = std::abs(exponent); |
1669 | | |
1670 | 194k | if (exponent >= std::numeric_limits<T>::min_exponent10) |
1671 | 188k | { |
1672 | 188k | if (e < fract10_size) |
1673 | 188k | { |
1674 | 188k | if (exponent > 0) |
1675 | 52.8k | return T(d * fract10[e]); |
1676 | 135k | else |
1677 | 135k | return T(d / fract10[e]); |
1678 | 188k | } |
1679 | 0 | else |
1680 | 0 | return T(d * std::pow(10.0, 10.0 * exponent)); |
1681 | 188k | } |
1682 | 6.27k | else |
1683 | 6.27k | { |
1684 | 6.27k | d /= T(fract10[ -std::numeric_limits<T>::min_exponent10]); |
1685 | 6.27k | return T(d / fract10[-exponent + std::numeric_limits<T>::min_exponent10]); |
1686 | 6.27k | } |
1687 | 194k | } double exprtk::details::compute_pow10<double>(double, int) Line | Count | Source | 1629 | 103k | { | 1630 | 103k | static const double fract10[] = | 1631 | 103k | { | 1632 | 103k | 0.0, | 1633 | 103k | 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, 1.0E+009, 1.0E+010, | 1634 | 103k | 1.0E+011, 1.0E+012, 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016, 1.0E+017, 1.0E+018, 1.0E+019, 1.0E+020, | 1635 | 103k | 1.0E+021, 1.0E+022, 1.0E+023, 1.0E+024, 1.0E+025, 1.0E+026, 1.0E+027, 1.0E+028, 1.0E+029, 1.0E+030, | 1636 | 103k | 1.0E+031, 1.0E+032, 1.0E+033, 1.0E+034, 1.0E+035, 1.0E+036, 1.0E+037, 1.0E+038, 1.0E+039, 1.0E+040, | 1637 | 103k | 1.0E+041, 1.0E+042, 1.0E+043, 1.0E+044, 1.0E+045, 1.0E+046, 1.0E+047, 1.0E+048, 1.0E+049, 1.0E+050, | 1638 | 103k | 1.0E+051, 1.0E+052, 1.0E+053, 1.0E+054, 1.0E+055, 1.0E+056, 1.0E+057, 1.0E+058, 1.0E+059, 1.0E+060, | 1639 | 103k | 1.0E+061, 1.0E+062, 1.0E+063, 1.0E+064, 1.0E+065, 1.0E+066, 1.0E+067, 1.0E+068, 1.0E+069, 1.0E+070, | 1640 | 103k | 1.0E+071, 1.0E+072, 1.0E+073, 1.0E+074, 1.0E+075, 1.0E+076, 1.0E+077, 1.0E+078, 1.0E+079, 1.0E+080, | 1641 | 103k | 1.0E+081, 1.0E+082, 1.0E+083, 1.0E+084, 1.0E+085, 1.0E+086, 1.0E+087, 1.0E+088, 1.0E+089, 1.0E+090, | 1642 | 103k | 1.0E+091, 1.0E+092, 1.0E+093, 1.0E+094, 1.0E+095, 1.0E+096, 1.0E+097, 1.0E+098, 1.0E+099, 1.0E+100, | 1643 | 103k | 1.0E+101, 1.0E+102, 1.0E+103, 1.0E+104, 1.0E+105, 1.0E+106, 1.0E+107, 1.0E+108, 1.0E+109, 1.0E+110, | 1644 | 103k | 1.0E+111, 1.0E+112, 1.0E+113, 1.0E+114, 1.0E+115, 1.0E+116, 1.0E+117, 1.0E+118, 1.0E+119, 1.0E+120, | 1645 | 103k | 1.0E+121, 1.0E+122, 1.0E+123, 1.0E+124, 1.0E+125, 1.0E+126, 1.0E+127, 1.0E+128, 1.0E+129, 1.0E+130, | 1646 | 103k | 1.0E+131, 1.0E+132, 1.0E+133, 1.0E+134, 1.0E+135, 1.0E+136, 1.0E+137, 1.0E+138, 1.0E+139, 1.0E+140, | 1647 | 103k | 1.0E+141, 1.0E+142, 1.0E+143, 1.0E+144, 1.0E+145, 1.0E+146, 1.0E+147, 1.0E+148, 1.0E+149, 1.0E+150, | 1648 | 103k | 1.0E+151, 1.0E+152, 1.0E+153, 1.0E+154, 1.0E+155, 1.0E+156, 1.0E+157, 1.0E+158, 1.0E+159, 1.0E+160, | 1649 | 103k | 1.0E+161, 1.0E+162, 1.0E+163, 1.0E+164, 1.0E+165, 1.0E+166, 1.0E+167, 1.0E+168, 1.0E+169, 1.0E+170, | 1650 | 103k | 1.0E+171, 1.0E+172, 1.0E+173, 1.0E+174, 1.0E+175, 1.0E+176, 1.0E+177, 1.0E+178, 1.0E+179, 1.0E+180, | 1651 | 103k | 1.0E+181, 1.0E+182, 1.0E+183, 1.0E+184, 1.0E+185, 1.0E+186, 1.0E+187, 1.0E+188, 1.0E+189, 1.0E+190, | 1652 | 103k | 1.0E+191, 1.0E+192, 1.0E+193, 1.0E+194, 1.0E+195, 1.0E+196, 1.0E+197, 1.0E+198, 1.0E+199, 1.0E+200, | 1653 | 103k | 1.0E+201, 1.0E+202, 1.0E+203, 1.0E+204, 1.0E+205, 1.0E+206, 1.0E+207, 1.0E+208, 1.0E+209, 1.0E+210, | 1654 | 103k | 1.0E+211, 1.0E+212, 1.0E+213, 1.0E+214, 1.0E+215, 1.0E+216, 1.0E+217, 1.0E+218, 1.0E+219, 1.0E+220, | 1655 | 103k | 1.0E+221, 1.0E+222, 1.0E+223, 1.0E+224, 1.0E+225, 1.0E+226, 1.0E+227, 1.0E+228, 1.0E+229, 1.0E+230, | 1656 | 103k | 1.0E+231, 1.0E+232, 1.0E+233, 1.0E+234, 1.0E+235, 1.0E+236, 1.0E+237, 1.0E+238, 1.0E+239, 1.0E+240, | 1657 | 103k | 1.0E+241, 1.0E+242, 1.0E+243, 1.0E+244, 1.0E+245, 1.0E+246, 1.0E+247, 1.0E+248, 1.0E+249, 1.0E+250, | 1658 | 103k | 1.0E+251, 1.0E+252, 1.0E+253, 1.0E+254, 1.0E+255, 1.0E+256, 1.0E+257, 1.0E+258, 1.0E+259, 1.0E+260, | 1659 | 103k | 1.0E+261, 1.0E+262, 1.0E+263, 1.0E+264, 1.0E+265, 1.0E+266, 1.0E+267, 1.0E+268, 1.0E+269, 1.0E+270, | 1660 | 103k | 1.0E+271, 1.0E+272, 1.0E+273, 1.0E+274, 1.0E+275, 1.0E+276, 1.0E+277, 1.0E+278, 1.0E+279, 1.0E+280, | 1661 | 103k | 1.0E+281, 1.0E+282, 1.0E+283, 1.0E+284, 1.0E+285, 1.0E+286, 1.0E+287, 1.0E+288, 1.0E+289, 1.0E+290, | 1662 | 103k | 1.0E+291, 1.0E+292, 1.0E+293, 1.0E+294, 1.0E+295, 1.0E+296, 1.0E+297, 1.0E+298, 1.0E+299, 1.0E+300, | 1663 | 103k | 1.0E+301, 1.0E+302, 1.0E+303, 1.0E+304, 1.0E+305, 1.0E+306, 1.0E+307, 1.0E+308 | 1664 | 103k | }; | 1665 | | | 1666 | 103k | static const int fract10_size = static_cast<int>(sizeof(fract10) / sizeof(double)); | 1667 | | | 1668 | 103k | const int e = std::abs(exponent); | 1669 | | | 1670 | 103k | if (exponent >= std::numeric_limits<T>::min_exponent10) | 1671 | 103k | { | 1672 | 103k | if (e < fract10_size) | 1673 | 103k | { | 1674 | 103k | if (exponent > 0) | 1675 | 31.3k | return T(d * fract10[e]); | 1676 | 72.6k | else | 1677 | 72.6k | return T(d / fract10[e]); | 1678 | 103k | } | 1679 | 0 | else | 1680 | 0 | return T(d * std::pow(10.0, 10.0 * exponent)); | 1681 | 103k | } | 1682 | 17 | else | 1683 | 17 | { | 1684 | 17 | d /= T(fract10[ -std::numeric_limits<T>::min_exponent10]); | 1685 | 17 | return T(d / fract10[-exponent + std::numeric_limits<T>::min_exponent10]); | 1686 | 17 | } | 1687 | 103k | } |
float exprtk::details::compute_pow10<float>(float, int) Line | Count | Source | 1629 | 90.8k | { | 1630 | 90.8k | static const double fract10[] = | 1631 | 90.8k | { | 1632 | 90.8k | 0.0, | 1633 | 90.8k | 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, 1.0E+009, 1.0E+010, | 1634 | 90.8k | 1.0E+011, 1.0E+012, 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016, 1.0E+017, 1.0E+018, 1.0E+019, 1.0E+020, | 1635 | 90.8k | 1.0E+021, 1.0E+022, 1.0E+023, 1.0E+024, 1.0E+025, 1.0E+026, 1.0E+027, 1.0E+028, 1.0E+029, 1.0E+030, | 1636 | 90.8k | 1.0E+031, 1.0E+032, 1.0E+033, 1.0E+034, 1.0E+035, 1.0E+036, 1.0E+037, 1.0E+038, 1.0E+039, 1.0E+040, | 1637 | 90.8k | 1.0E+041, 1.0E+042, 1.0E+043, 1.0E+044, 1.0E+045, 1.0E+046, 1.0E+047, 1.0E+048, 1.0E+049, 1.0E+050, | 1638 | 90.8k | 1.0E+051, 1.0E+052, 1.0E+053, 1.0E+054, 1.0E+055, 1.0E+056, 1.0E+057, 1.0E+058, 1.0E+059, 1.0E+060, | 1639 | 90.8k | 1.0E+061, 1.0E+062, 1.0E+063, 1.0E+064, 1.0E+065, 1.0E+066, 1.0E+067, 1.0E+068, 1.0E+069, 1.0E+070, | 1640 | 90.8k | 1.0E+071, 1.0E+072, 1.0E+073, 1.0E+074, 1.0E+075, 1.0E+076, 1.0E+077, 1.0E+078, 1.0E+079, 1.0E+080, | 1641 | 90.8k | 1.0E+081, 1.0E+082, 1.0E+083, 1.0E+084, 1.0E+085, 1.0E+086, 1.0E+087, 1.0E+088, 1.0E+089, 1.0E+090, | 1642 | 90.8k | 1.0E+091, 1.0E+092, 1.0E+093, 1.0E+094, 1.0E+095, 1.0E+096, 1.0E+097, 1.0E+098, 1.0E+099, 1.0E+100, | 1643 | 90.8k | 1.0E+101, 1.0E+102, 1.0E+103, 1.0E+104, 1.0E+105, 1.0E+106, 1.0E+107, 1.0E+108, 1.0E+109, 1.0E+110, | 1644 | 90.8k | 1.0E+111, 1.0E+112, 1.0E+113, 1.0E+114, 1.0E+115, 1.0E+116, 1.0E+117, 1.0E+118, 1.0E+119, 1.0E+120, | 1645 | 90.8k | 1.0E+121, 1.0E+122, 1.0E+123, 1.0E+124, 1.0E+125, 1.0E+126, 1.0E+127, 1.0E+128, 1.0E+129, 1.0E+130, | 1646 | 90.8k | 1.0E+131, 1.0E+132, 1.0E+133, 1.0E+134, 1.0E+135, 1.0E+136, 1.0E+137, 1.0E+138, 1.0E+139, 1.0E+140, | 1647 | 90.8k | 1.0E+141, 1.0E+142, 1.0E+143, 1.0E+144, 1.0E+145, 1.0E+146, 1.0E+147, 1.0E+148, 1.0E+149, 1.0E+150, | 1648 | 90.8k | 1.0E+151, 1.0E+152, 1.0E+153, 1.0E+154, 1.0E+155, 1.0E+156, 1.0E+157, 1.0E+158, 1.0E+159, 1.0E+160, | 1649 | 90.8k | 1.0E+161, 1.0E+162, 1.0E+163, 1.0E+164, 1.0E+165, 1.0E+166, 1.0E+167, 1.0E+168, 1.0E+169, 1.0E+170, | 1650 | 90.8k | 1.0E+171, 1.0E+172, 1.0E+173, 1.0E+174, 1.0E+175, 1.0E+176, 1.0E+177, 1.0E+178, 1.0E+179, 1.0E+180, | 1651 | 90.8k | 1.0E+181, 1.0E+182, 1.0E+183, 1.0E+184, 1.0E+185, 1.0E+186, 1.0E+187, 1.0E+188, 1.0E+189, 1.0E+190, | 1652 | 90.8k | 1.0E+191, 1.0E+192, 1.0E+193, 1.0E+194, 1.0E+195, 1.0E+196, 1.0E+197, 1.0E+198, 1.0E+199, 1.0E+200, | 1653 | 90.8k | 1.0E+201, 1.0E+202, 1.0E+203, 1.0E+204, 1.0E+205, 1.0E+206, 1.0E+207, 1.0E+208, 1.0E+209, 1.0E+210, | 1654 | 90.8k | 1.0E+211, 1.0E+212, 1.0E+213, 1.0E+214, 1.0E+215, 1.0E+216, 1.0E+217, 1.0E+218, 1.0E+219, 1.0E+220, | 1655 | 90.8k | 1.0E+221, 1.0E+222, 1.0E+223, 1.0E+224, 1.0E+225, 1.0E+226, 1.0E+227, 1.0E+228, 1.0E+229, 1.0E+230, | 1656 | 90.8k | 1.0E+231, 1.0E+232, 1.0E+233, 1.0E+234, 1.0E+235, 1.0E+236, 1.0E+237, 1.0E+238, 1.0E+239, 1.0E+240, | 1657 | 90.8k | 1.0E+241, 1.0E+242, 1.0E+243, 1.0E+244, 1.0E+245, 1.0E+246, 1.0E+247, 1.0E+248, 1.0E+249, 1.0E+250, | 1658 | 90.8k | 1.0E+251, 1.0E+252, 1.0E+253, 1.0E+254, 1.0E+255, 1.0E+256, 1.0E+257, 1.0E+258, 1.0E+259, 1.0E+260, | 1659 | 90.8k | 1.0E+261, 1.0E+262, 1.0E+263, 1.0E+264, 1.0E+265, 1.0E+266, 1.0E+267, 1.0E+268, 1.0E+269, 1.0E+270, | 1660 | 90.8k | 1.0E+271, 1.0E+272, 1.0E+273, 1.0E+274, 1.0E+275, 1.0E+276, 1.0E+277, 1.0E+278, 1.0E+279, 1.0E+280, | 1661 | 90.8k | 1.0E+281, 1.0E+282, 1.0E+283, 1.0E+284, 1.0E+285, 1.0E+286, 1.0E+287, 1.0E+288, 1.0E+289, 1.0E+290, | 1662 | 90.8k | 1.0E+291, 1.0E+292, 1.0E+293, 1.0E+294, 1.0E+295, 1.0E+296, 1.0E+297, 1.0E+298, 1.0E+299, 1.0E+300, | 1663 | 90.8k | 1.0E+301, 1.0E+302, 1.0E+303, 1.0E+304, 1.0E+305, 1.0E+306, 1.0E+307, 1.0E+308 | 1664 | 90.8k | }; | 1665 | | | 1666 | 90.8k | static const int fract10_size = static_cast<int>(sizeof(fract10) / sizeof(double)); | 1667 | | | 1668 | 90.8k | const int e = std::abs(exponent); | 1669 | | | 1670 | 90.8k | if (exponent >= std::numeric_limits<T>::min_exponent10) | 1671 | 84.5k | { | 1672 | 84.5k | if (e < fract10_size) | 1673 | 84.5k | { | 1674 | 84.5k | if (exponent > 0) | 1675 | 21.5k | return T(d * fract10[e]); | 1676 | 63.0k | else | 1677 | 63.0k | return T(d / fract10[e]); | 1678 | 84.5k | } | 1679 | 0 | else | 1680 | 0 | return T(d * std::pow(10.0, 10.0 * exponent)); | 1681 | 84.5k | } | 1682 | 6.25k | else | 1683 | 6.25k | { | 1684 | 6.25k | d /= T(fract10[ -std::numeric_limits<T>::min_exponent10]); | 1685 | 6.25k | return T(d / fract10[-exponent + std::numeric_limits<T>::min_exponent10]); | 1686 | 6.25k | } | 1687 | 90.8k | } |
|
1688 | | |
1689 | | template <typename Iterator, typename T> |
1690 | | inline bool string_to_type_converter_impl_ref(Iterator& itr, const Iterator end, T& result) |
1691 | 120k | { |
1692 | 120k | if (itr == end) |
1693 | 0 | return false; |
1694 | | |
1695 | 120k | const bool negative = ('-' == (*itr)); |
1696 | | |
1697 | 120k | if (negative || ('+' == (*itr))) |
1698 | 26.8k | { |
1699 | 26.8k | if (end == ++itr) |
1700 | 120 | return false; |
1701 | 26.8k | } |
1702 | | |
1703 | 120k | static const uchar_t zero = static_cast<uchar_t>('0'); |
1704 | | |
1705 | 244k | while ((end != itr) && (zero == (*itr))) ++itr; |
1706 | | |
1707 | 120k | bool return_result = true; |
1708 | 120k | unsigned int digit = 0; |
1709 | 120k | const std::size_t length = static_cast<std::size_t>(std::distance(itr,end)); |
1710 | | |
1711 | 120k | if (length <= 4) |
1712 | 120k | { |
1713 | 120k | exprtk_disable_fallthrough_begin |
1714 | 120k | switch (length) |
1715 | 120k | { |
1716 | | #ifdef exprtk_use_lut |
1717 | | |
1718 | | #define exprtk_process_digit \ |
1719 | | if ((digit = details::digit_table[(int)*itr++]) < 10) \ |
1720 | | result = result * 10 + (digit); \ |
1721 | | else \ |
1722 | | { \ |
1723 | | return_result = false; \ |
1724 | | break; \ |
1725 | | } \ |
1726 | | |
1727 | | #else |
1728 | | |
1729 | 0 | #define exprtk_process_digit \ |
1730 | 59.8k | if ((digit = (*itr++ - zero)) < 10) \ |
1731 | 59.8k | result = result * T(10) + digit; \ |
1732 | 59.8k | else \ |
1733 | 59.8k | { \ |
1734 | 38 | return_result = false; \ |
1735 | 38 | break; \ |
1736 | 38 | } \ |
1737 | 0 | |
1738 | 0 | #endif |
1739 | | |
1740 | 60 | case 4 : exprtk_process_digit |
1741 | 1.84k | case 3 : exprtk_process_digit |
1742 | 57.9k | case 2 : exprtk_process_digit |
1743 | 84.0k | case 1 : if ((digit = (*itr - zero))>= 10) |
1744 | 224 | { |
1745 | 224 | digit = 0; |
1746 | 224 | return_result = false; |
1747 | 224 | } |
1748 | | |
1749 | 120k | #undef exprtk_process_digit |
1750 | 120k | } |
1751 | 120k | exprtk_disable_fallthrough_end |
1752 | 120k | } |
1753 | 86 | else |
1754 | 86 | return_result = false; |
1755 | | |
1756 | 120k | if (length && return_result) |
1757 | 83.8k | { |
1758 | 83.8k | result = result * 10 + static_cast<T>(digit); |
1759 | 83.8k | ++itr; |
1760 | 83.8k | } |
1761 | | |
1762 | 120k | result = negative ? -result : result; |
1763 | 120k | return return_result; |
1764 | 120k | } |
1765 | | |
1766 | | template <typename Iterator, typename T> |
1767 | | static inline bool parse_nan(Iterator& itr, const Iterator end, T& t) |
1768 | 0 | { |
1769 | 0 | typedef typename std::iterator_traits<Iterator>::value_type type; |
1770 | |
|
1771 | 0 | static const std::size_t nan_length = 3; |
1772 | |
|
1773 | 0 | if (std::distance(itr,end) != static_cast<int>(nan_length)) |
1774 | 0 | return false; |
1775 | | |
1776 | 0 | if (static_cast<type>('n') == (*itr)) |
1777 | 0 | { |
1778 | 0 | if ( |
1779 | 0 | (static_cast<type>('a') != *(itr + 1)) || |
1780 | 0 | (static_cast<type>('n') != *(itr + 2)) |
1781 | 0 | ) |
1782 | 0 | { |
1783 | 0 | return false; |
1784 | 0 | } |
1785 | 0 | } |
1786 | 0 | else if ( |
1787 | 0 | (static_cast<type>('A') != *(itr + 1)) || |
1788 | 0 | (static_cast<type>('N') != *(itr + 2)) |
1789 | 0 | ) |
1790 | 0 | { |
1791 | 0 | return false; |
1792 | 0 | } |
1793 | | |
1794 | 0 | t = std::numeric_limits<T>::quiet_NaN(); |
1795 | |
|
1796 | 0 | return true; |
1797 | 0 | } Unexecuted instantiation: exprtk_fuzzer.cpp:bool exprtk::details::parse_nan<char const*, double>(char const*&, char const*, double&) Unexecuted instantiation: exprtk_fuzzer.cpp:bool exprtk::details::parse_nan<char const*, float>(char const*&, char const*, float&) |
1798 | | |
1799 | | template <typename Iterator, typename T> |
1800 | | static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, const bool negative) |
1801 | 0 | { |
1802 | 0 | static const char_t inf_uc[] = "INFINITY"; |
1803 | 0 | static const char_t inf_lc[] = "infinity"; |
1804 | 0 | static const std::size_t inf_length = 8; |
1805 | |
|
1806 | 0 | const std::size_t length = static_cast<std::size_t>(std::distance(itr,end)); |
1807 | |
|
1808 | 0 | if ((3 != length) && (inf_length != length)) |
1809 | 0 | return false; |
1810 | | |
1811 | 0 | char_cptr inf_itr = ('i' == (*itr)) ? inf_lc : inf_uc; |
1812 | |
|
1813 | 0 | while (end != itr) |
1814 | 0 | { |
1815 | 0 | if (*inf_itr == static_cast<char_t>(*itr)) |
1816 | 0 | { |
1817 | 0 | ++itr; |
1818 | 0 | ++inf_itr; |
1819 | 0 | continue; |
1820 | 0 | } |
1821 | 0 | else |
1822 | 0 | return false; |
1823 | 0 | } |
1824 | | |
1825 | 0 | if (negative) |
1826 | 0 | t = -std::numeric_limits<T>::infinity(); |
1827 | 0 | else |
1828 | 0 | t = std::numeric_limits<T>::infinity(); |
1829 | |
|
1830 | 0 | return true; |
1831 | 0 | } Unexecuted instantiation: exprtk_fuzzer.cpp:bool exprtk::details::parse_inf<char const*, double>(char const*&, char const*, double&, bool) Unexecuted instantiation: exprtk_fuzzer.cpp:bool exprtk::details::parse_inf<char const*, float>(char const*&, char const*, float&, bool) |
1832 | | |
1833 | | template <typename T> |
1834 | | inline bool valid_exponent(const int exponent, numeric::details::real_type_tag) |
1835 | 23.4M | { |
1836 | 23.4M | using namespace details::numeric; |
1837 | 23.4M | return (numeric_info<T>::min_exp <= exponent) && (exponent <= numeric_info<T>::max_exp); |
1838 | 23.4M | } bool exprtk::details::valid_exponent<double>(int, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1835 | 11.8M | { | 1836 | 11.8M | using namespace details::numeric; | 1837 | 11.8M | return (numeric_info<T>::min_exp <= exponent) && (exponent <= numeric_info<T>::max_exp); | 1838 | 11.8M | } |
bool exprtk::details::valid_exponent<float>(int, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1835 | 11.6M | { | 1836 | 11.6M | using namespace details::numeric; | 1837 | 11.6M | return (numeric_info<T>::min_exp <= exponent) && (exponent <= numeric_info<T>::max_exp); | 1838 | 11.6M | } |
|
1839 | | |
1840 | | template <typename Iterator, typename T> |
1841 | | inline bool string_to_real(Iterator& itr_external, const Iterator end, T& t, numeric::details::real_type_tag) |
1842 | 23.3M | { |
1843 | 23.3M | if (end == itr_external) return false; |
1844 | | |
1845 | 23.3M | Iterator itr = itr_external; |
1846 | | |
1847 | 23.3M | T d = T(0); |
1848 | | |
1849 | 23.3M | const bool negative = ('-' == (*itr)); |
1850 | | |
1851 | 23.3M | if (negative || '+' == (*itr)) |
1852 | 0 | { |
1853 | 0 | if (end == ++itr) |
1854 | 0 | return false; |
1855 | 0 | } |
1856 | | |
1857 | 23.3M | bool instate = false; |
1858 | | |
1859 | 23.3M | static const char_t zero = static_cast<uchar_t>('0'); |
1860 | | |
1861 | 23.3M | #define parse_digit_1(d) \ |
1862 | 30.6M | if ((digit = (*itr - zero)) < 10) \ |
1863 | 30.6M | { d = d * T(10) + digit; } \ |
1864 | 30.6M | else \ |
1865 | 30.6M | { break; } \ |
1866 | 30.6M | if (end == ++itr) break; \ |
1867 | 23.3M | |
1868 | 23.3M | #define parse_digit_2(d) \ |
1869 | 23.3M | if ((digit = (*itr - zero)) < 10) \ |
1870 | 4.47M | { d = d * T(10) + digit; } \ |
1871 | 4.47M | else \ |
1872 | 4.47M | { break; } \ |
1873 | 4.47M | ++itr; \ |
1874 | 23.3M | |
1875 | 23.3M | if ('.' != (*itr)) |
1876 | 23.3M | { |
1877 | 23.3M | const Iterator curr = itr; |
1878 | | |
1879 | 30.2M | while ((end != itr) && (zero == (*itr))) ++itr; |
1880 | | |
1881 | 27.5M | while (end != itr) |
1882 | 22.1M | { |
1883 | 22.1M | unsigned int digit; |
1884 | 22.1M | parse_digit_1(d) |
1885 | 16.3M | parse_digit_1(d) |
1886 | 8.65M | parse_digit_2(d) |
1887 | 8.65M | } |
1888 | | |
1889 | 23.3M | if (curr != itr) instate = true; |
1890 | 23.3M | } |
1891 | | |
1892 | 23.3M | int exponent = 0; |
1893 | | |
1894 | 23.3M | if (end != itr) |
1895 | 410k | { |
1896 | 410k | if ('.' == (*itr)) |
1897 | 293k | { |
1898 | 293k | const Iterator curr = ++itr; |
1899 | 293k | T tmp_d = T(0); |
1900 | | |
1901 | 401k | while (end != itr) |
1902 | 175k | { |
1903 | 175k | unsigned int digit; |
1904 | 175k | parse_digit_1(tmp_d) |
1905 | 245k | parse_digit_1(tmp_d) |
1906 | 215k | parse_digit_2(tmp_d) |
1907 | 215k | } |
1908 | | |
1909 | 293k | if (curr != itr) |
1910 | 117k | { |
1911 | 117k | instate = true; |
1912 | | |
1913 | 117k | const int frac_exponent = static_cast<int>(-std::distance(curr, itr)); |
1914 | | |
1915 | 117k | if (!valid_exponent<T>(frac_exponent, numeric::details::real_type_tag())) |
1916 | 46 | return false; |
1917 | | |
1918 | 116k | d += compute_pow10(tmp_d, frac_exponent); |
1919 | 116k | } |
1920 | | |
1921 | 293k | #undef parse_digit_1 |
1922 | 293k | #undef parse_digit_2 |
1923 | 293k | } |
1924 | | |
1925 | 410k | if (end != itr) |
1926 | 120k | { |
1927 | 120k | typename std::iterator_traits<Iterator>::value_type c = (*itr); |
1928 | | |
1929 | 120k | if (('e' == c) || ('E' == c)) |
1930 | 120k | { |
1931 | 120k | int exp = 0; |
1932 | | |
1933 | 120k | if (!details::string_to_type_converter_impl_ref(++itr, end, exp)) |
1934 | 468 | { |
1935 | 468 | if (end == itr) |
1936 | 120 | return false; |
1937 | 348 | else |
1938 | 348 | c = (*itr); |
1939 | 468 | } |
1940 | | |
1941 | 120k | exponent += exp; |
1942 | 120k | } |
1943 | | |
1944 | 120k | if (end != itr) |
1945 | 348 | { |
1946 | 348 | if (('f' == c) || ('F' == c) || ('l' == c) || ('L' == c)) |
1947 | 0 | ++itr; |
1948 | 348 | else if ('#' == c) |
1949 | 0 | { |
1950 | 0 | if (end == ++itr) |
1951 | 0 | return false; |
1952 | 0 | else if (('I' <= (*itr)) && ((*itr) <= 'n')) |
1953 | 0 | { |
1954 | 0 | if (('i' == (*itr)) || ('I' == (*itr))) |
1955 | 0 | { |
1956 | 0 | return parse_inf(itr, end, t, negative); |
1957 | 0 | } |
1958 | 0 | else if (('n' == (*itr)) || ('N' == (*itr))) |
1959 | 0 | { |
1960 | 0 | return parse_nan(itr, end, t); |
1961 | 0 | } |
1962 | 0 | else |
1963 | 0 | return false; |
1964 | 0 | } |
1965 | 0 | else |
1966 | 0 | return false; |
1967 | 0 | } |
1968 | 348 | else if (('I' <= (*itr)) && ((*itr) <= 'n')) |
1969 | 220 | { |
1970 | 220 | if (('i' == (*itr)) || ('I' == (*itr))) |
1971 | 0 | { |
1972 | 0 | return parse_inf(itr, end, t, negative); |
1973 | 0 | } |
1974 | 220 | else if (('n' == (*itr)) || ('N' == (*itr))) |
1975 | 0 | { |
1976 | 0 | return parse_nan(itr, end, t); |
1977 | 0 | } |
1978 | 220 | else |
1979 | 220 | return false; |
1980 | 220 | } |
1981 | 128 | else |
1982 | 128 | return false; |
1983 | 348 | } |
1984 | 120k | } |
1985 | 410k | } |
1986 | | |
1987 | 23.3M | if ((end != itr) || (!instate)) |
1988 | 1.48k | return false; |
1989 | 23.3M | else if (!valid_exponent<T>(exponent, numeric::details::real_type_tag())) |
1990 | 6.02k | return false; |
1991 | 23.3M | else if (exponent) |
1992 | 77.7k | d = compute_pow10(d,exponent); |
1993 | | |
1994 | 23.3M | t = static_cast<T>((negative) ? -d : d); |
1995 | 23.3M | return true; |
1996 | 23.3M | } bool exprtk::details::string_to_real<char const*, double>(char const*&, char const*, double&, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1842 | 11.8M | { | 1843 | 11.8M | if (end == itr_external) return false; | 1844 | | | 1845 | 11.8M | Iterator itr = itr_external; | 1846 | | | 1847 | 11.8M | T d = T(0); | 1848 | | | 1849 | 11.8M | const bool negative = ('-' == (*itr)); | 1850 | | | 1851 | 11.8M | if (negative || '+' == (*itr)) | 1852 | 0 | { | 1853 | 0 | if (end == ++itr) | 1854 | 0 | return false; | 1855 | 0 | } | 1856 | | | 1857 | 11.8M | bool instate = false; | 1858 | | | 1859 | 11.8M | static const char_t zero = static_cast<uchar_t>('0'); | 1860 | | | 1861 | 11.8M | #define parse_digit_1(d) \ | 1862 | 11.8M | if ((digit = (*itr - zero)) < 10) \ | 1863 | 11.8M | { d = d * T(10) + digit; } \ | 1864 | 11.8M | else \ | 1865 | 11.8M | { break; } \ | 1866 | 11.8M | if (end == ++itr) break; \ | 1867 | 11.8M | | 1868 | 11.8M | #define parse_digit_2(d) \ | 1869 | 11.8M | if ((digit = (*itr - zero)) < 10) \ | 1870 | 11.8M | { d = d * T(10) + digit; } \ | 1871 | 11.8M | else \ | 1872 | 11.8M | { break; } \ | 1873 | 11.8M | ++itr; \ | 1874 | 11.8M | | 1875 | 11.8M | if ('.' != (*itr)) | 1876 | 11.7M | { | 1877 | 11.7M | const Iterator curr = itr; | 1878 | | | 1879 | 15.2M | while ((end != itr) && (zero == (*itr))) ++itr; | 1880 | | | 1881 | 13.9M | while (end != itr) | 1882 | 11.1M | { | 1883 | 11.1M | unsigned int digit; | 1884 | 11.1M | parse_digit_1(d) | 1885 | 8.25M | parse_digit_1(d) | 1886 | 4.37M | parse_digit_2(d) | 1887 | 4.37M | } | 1888 | | | 1889 | 11.7M | if (curr != itr) instate = true; | 1890 | 11.7M | } | 1891 | | | 1892 | 11.8M | int exponent = 0; | 1893 | | | 1894 | 11.8M | if (end != itr) | 1895 | 209k | { | 1896 | 209k | if ('.' == (*itr)) | 1897 | 147k | { | 1898 | 147k | const Iterator curr = ++itr; | 1899 | 147k | T tmp_d = T(0); | 1900 | | | 1901 | 202k | while (end != itr) | 1902 | 89.0k | { | 1903 | 89.0k | unsigned int digit; | 1904 | 89.0k | parse_digit_1(tmp_d) | 1905 | 125k | parse_digit_1(tmp_d) | 1906 | 109k | parse_digit_2(tmp_d) | 1907 | 109k | } | 1908 | | | 1909 | 147k | if (curr != itr) | 1910 | 59.2k | { | 1911 | 59.2k | instate = true; | 1912 | | | 1913 | 59.2k | const int frac_exponent = static_cast<int>(-std::distance(curr, itr)); | 1914 | | | 1915 | 59.2k | if (!valid_exponent<T>(frac_exponent, numeric::details::real_type_tag())) | 1916 | 2 | return false; | 1917 | | | 1918 | 59.2k | d += compute_pow10(tmp_d, frac_exponent); | 1919 | 59.2k | } | 1920 | | | 1921 | 147k | #undef parse_digit_1 | 1922 | 147k | #undef parse_digit_2 | 1923 | 147k | } | 1924 | | | 1925 | 209k | if (end != itr) | 1926 | 63.5k | { | 1927 | 63.5k | typename std::iterator_traits<Iterator>::value_type c = (*itr); | 1928 | | | 1929 | 63.5k | if (('e' == c) || ('E' == c)) | 1930 | 63.5k | { | 1931 | 63.5k | int exp = 0; | 1932 | | | 1933 | 63.5k | if (!details::string_to_type_converter_impl_ref(++itr, end, exp)) | 1934 | 234 | { | 1935 | 234 | if (end == itr) | 1936 | 60 | return false; | 1937 | 174 | else | 1938 | 174 | c = (*itr); | 1939 | 234 | } | 1940 | | | 1941 | 63.4k | exponent += exp; | 1942 | 63.4k | } | 1943 | | | 1944 | 63.4k | if (end != itr) | 1945 | 174 | { | 1946 | 174 | if (('f' == c) || ('F' == c) || ('l' == c) || ('L' == c)) | 1947 | 0 | ++itr; | 1948 | 174 | else if ('#' == c) | 1949 | 0 | { | 1950 | 0 | if (end == ++itr) | 1951 | 0 | return false; | 1952 | 0 | else if (('I' <= (*itr)) && ((*itr) <= 'n')) | 1953 | 0 | { | 1954 | 0 | if (('i' == (*itr)) || ('I' == (*itr))) | 1955 | 0 | { | 1956 | 0 | return parse_inf(itr, end, t, negative); | 1957 | 0 | } | 1958 | 0 | else if (('n' == (*itr)) || ('N' == (*itr))) | 1959 | 0 | { | 1960 | 0 | return parse_nan(itr, end, t); | 1961 | 0 | } | 1962 | 0 | else | 1963 | 0 | return false; | 1964 | 0 | } | 1965 | 0 | else | 1966 | 0 | return false; | 1967 | 0 | } | 1968 | 174 | else if (('I' <= (*itr)) && ((*itr) <= 'n')) | 1969 | 110 | { | 1970 | 110 | if (('i' == (*itr)) || ('I' == (*itr))) | 1971 | 0 | { | 1972 | 0 | return parse_inf(itr, end, t, negative); | 1973 | 0 | } | 1974 | 110 | else if (('n' == (*itr)) || ('N' == (*itr))) | 1975 | 0 | { | 1976 | 0 | return parse_nan(itr, end, t); | 1977 | 0 | } | 1978 | 110 | else | 1979 | 110 | return false; | 1980 | 110 | } | 1981 | 64 | else | 1982 | 64 | return false; | 1983 | 174 | } | 1984 | 63.4k | } | 1985 | 209k | } | 1986 | | | 1987 | 11.8M | if ((end != itr) || (!instate)) | 1988 | 742 | return false; | 1989 | 11.8M | else if (!valid_exponent<T>(exponent, numeric::details::real_type_tag())) | 1990 | 294 | return false; | 1991 | 11.8M | else if (exponent) | 1992 | 44.6k | d = compute_pow10(d,exponent); | 1993 | | | 1994 | 11.8M | t = static_cast<T>((negative) ? -d : d); | 1995 | 11.8M | return true; | 1996 | 11.8M | } |
bool exprtk::details::string_to_real<char const*, float>(char const*&, char const*, float&, exprtk::details::numeric::details::real_type_tag) Line | Count | Source | 1842 | 11.5M | { | 1843 | 11.5M | if (end == itr_external) return false; | 1844 | | | 1845 | 11.5M | Iterator itr = itr_external; | 1846 | | | 1847 | 11.5M | T d = T(0); | 1848 | | | 1849 | 11.5M | const bool negative = ('-' == (*itr)); | 1850 | | | 1851 | 11.5M | if (negative || '+' == (*itr)) | 1852 | 0 | { | 1853 | 0 | if (end == ++itr) | 1854 | 0 | return false; | 1855 | 0 | } | 1856 | | | 1857 | 11.5M | bool instate = false; | 1858 | | | 1859 | 11.5M | static const char_t zero = static_cast<uchar_t>('0'); | 1860 | | | 1861 | 11.5M | #define parse_digit_1(d) \ | 1862 | 11.5M | if ((digit = (*itr - zero)) < 10) \ | 1863 | 11.5M | { d = d * T(10) + digit; } \ | 1864 | 11.5M | else \ | 1865 | 11.5M | { break; } \ | 1866 | 11.5M | if (end == ++itr) break; \ | 1867 | 11.5M | | 1868 | 11.5M | #define parse_digit_2(d) \ | 1869 | 11.5M | if ((digit = (*itr - zero)) < 10) \ | 1870 | 11.5M | { d = d * T(10) + digit; } \ | 1871 | 11.5M | else \ | 1872 | 11.5M | { break; } \ | 1873 | 11.5M | ++itr; \ | 1874 | 11.5M | | 1875 | 11.5M | if ('.' != (*itr)) | 1876 | 11.5M | { | 1877 | 11.5M | const Iterator curr = itr; | 1878 | | | 1879 | 14.9M | while ((end != itr) && (zero == (*itr))) ++itr; | 1880 | | | 1881 | 13.6M | while (end != itr) | 1882 | 10.9M | { | 1883 | 10.9M | unsigned int digit; | 1884 | 10.9M | parse_digit_1(d) | 1885 | 8.06M | parse_digit_1(d) | 1886 | 4.27M | parse_digit_2(d) | 1887 | 4.27M | } | 1888 | | | 1889 | 11.5M | if (curr != itr) instate = true; | 1890 | 11.5M | } | 1891 | | | 1892 | 11.5M | int exponent = 0; | 1893 | | | 1894 | 11.5M | if (end != itr) | 1895 | 201k | { | 1896 | 201k | if ('.' == (*itr)) | 1897 | 145k | { | 1898 | 145k | const Iterator curr = ++itr; | 1899 | 145k | T tmp_d = T(0); | 1900 | | | 1901 | 198k | while (end != itr) | 1902 | 86.6k | { | 1903 | 86.6k | unsigned int digit; | 1904 | 86.6k | parse_digit_1(tmp_d) | 1905 | 120k | parse_digit_1(tmp_d) | 1906 | 105k | parse_digit_2(tmp_d) | 1907 | 105k | } | 1908 | | | 1909 | 145k | if (curr != itr) | 1910 | 57.7k | { | 1911 | 57.7k | instate = true; | 1912 | | | 1913 | 57.7k | const int frac_exponent = static_cast<int>(-std::distance(curr, itr)); | 1914 | | | 1915 | 57.7k | if (!valid_exponent<T>(frac_exponent, numeric::details::real_type_tag())) | 1916 | 44 | return false; | 1917 | | | 1918 | 57.7k | d += compute_pow10(tmp_d, frac_exponent); | 1919 | 57.7k | } | 1920 | | | 1921 | 145k | #undef parse_digit_1 | 1922 | 145k | #undef parse_digit_2 | 1923 | 145k | <
|