29 #ifndef MU_PARSER_TEMPLATE_MAGIC_H
30 #define MU_PARSER_TEMPLATE_MAGIC_H
52 static bool IsInteger() {
return false; }
58 static bool IsInteger() {
return true; }
64 static bool IsInteger() {
return true; }
70 static bool IsInteger() {
return true; }
76 static bool IsInteger() {
return true; }
82 static bool IsInteger() {
return true; }
88 static bool IsInteger() {
return true; }
94 static bool IsInteger() {
return true; }
100 static bool IsInteger() {
return true; }
118 static T Sin(T v) {
return sin(v); }
119 static T Cos(T v) {
return cos(v); }
120 static T Tan(T v) {
return tan(v); }
121 static T ASin(T v) {
return asin(v); }
122 static T ACos(T v) {
return acos(v); }
123 static T ATan(T v) {
return atan(v); }
124 static T ATan2(T v1, T v2) {
return atan2(v1, v2); }
125 static T Sinh(T v) {
return sinh(v); }
126 static T Cosh(T v) {
return cosh(v); }
127 static T Tanh(T v) {
return tanh(v); }
128 static T ASinh(T v) {
return log(v + sqrt(v * v + 1)); }
129 static T ACosh(T v) {
return log(v + sqrt(v * v - 1)); }
130 static T ATanh(T v) {
return ((T)0.5 * log((1 + v) / (1 - v))); }
131 static T Log(T v) {
return log(v); }
132 static T Log2(T v) {
return log(v) / log((T)2); }
133 static T Log10(T v) {
return log10(v); }
134 static T Exp(T v) {
return exp(v); }
135 static T Abs(T v) {
return (v >= 0) ? v : -v; }
136 static T Sqrt(T v) {
return sqrt(v); }
137 static T Rint(T v) {
return floor(v + (T)0.5); }
138 static T Sign(T v) {
return (T)((v < 0) ? -1 : (v > 0) ? 1 : 0); }
139 static T Pow(T v1, T v2) {
return std::pow(v1, v2); }
142 static std::random_device rd;
143 static std::mt19937 gen(rd());
144 static std::uniform_real_distribution<T> dis(0.0, 1.0);
149 static T UnaryMinus(T v) {
return -v; }
150 static T UnaryPlus(T v) {
return v; }
152 static T Sum(
const T *a_afArg,
int a_iArgc)
155 throw ParserError(
_T(
"too few arguments for function sum."));
158 for (
int i = 0; i < a_iArgc; ++i) fRes += a_afArg[i];
162 static T Avg(
const T *a_afArg,
int a_iArgc)
165 throw ParserError(
_T(
"too few arguments for function avg."));
168 for (
int i = 0; i < a_iArgc; ++i) fRes += a_afArg[i];
169 return fRes / (T)a_iArgc;
172 static T Min(
const T *a_afArg,
int a_iArgc)
175 throw ParserError(
_T(
"too few arguments for function min."));
178 for (
int i = 0; i < a_iArgc; ++i)
179 fRes = std::min(fRes, a_afArg[i]);
184 static T Max(
const T *a_afArg,
int a_iArgc)
187 throw ParserError(
_T(
"too few arguments for function max."));
190 for (
int i = 0; i < a_iArgc; ++i) fRes = std::max(fRes, a_afArg[i]);
196 #if defined (__GNUG__)
199 static constexpr T CONST_PI = (T)3.141592653589;
201 static constexpr T CONST_PI = (T)3.141592653589793238462643;
204 static constexpr T CONST_E = (T)2.718281828459045235360287;
#define _T(x)
Activate this option in order to compile with OpenMP support.
A class singling out integer types at compile time using template meta programming.
Error class of the parser.
A template class for providing wrappers for essential math functions.
Namespace for mathematical applications.
This file defines the error class used by the parser.