15# define M_PI 3.14159265358979323846
18# define M_E 2.7182818284590452354
21# define M_LN10 2.30258509299404568402
27#define INT(box) (box).Unbox<integer>()
28#define FLT(box) (box).Unbox<double >()
29#define FUNC( name,...) Box name( Scope& scope, \
32 { (void) scope; (void) args; (void) end; __VA_ARGS__ }
34namespace alib {
namespace expressions {
namespace plugins {
48FUNC( max_I ,
return (std::max) (INT(*args),INT(*(args+1))); )
49FUNC( max_F ,
return (::fmax) (FLT(*args),FLT(*(args+1))); )
50FUNC( min_I ,
return (std::min) (INT(*args),INT(*(args+1))); )
51FUNC( min_F ,
return (::fmin) (FLT(*args),FLT(*(args+1))); )
52FUNC( abs_I ,
return std::abs (INT(*args)); )
53FUNC( abs , return ::fabs (FLT(*args)); )
54FUNC( ceil , return ::ceil (FLT(*args)); )
55FUNC( floor , return ::floor (FLT(*args)); )
56FUNC( trunc , return ::round (FLT(*args)); )
57FUNC( round , return ::round (FLT(*args)); )
58FUNC( rint ,
return static_cast<integer>(::llrint(FLT(*args))); )
59FUNC( remainder, return ::remainder(FLT(*args),FLT(*(args+1))); )
61FUNC( rand ,
return static_cast<double>(std::rand()) /
static_cast<double>(RAND_MAX); )
63FUNC( sin , return ::sin (FLT(*args)); )
64FUNC( asin , return ::asin (FLT(*args)); )
65FUNC( cos , return ::cos (FLT(*args)); )
66FUNC( acos , return ::acos (FLT(*args)); )
67FUNC( tan , return ::tan (FLT(*args)); )
68FUNC( atan , return ::atan (FLT(*args)); )
70FUNC( sinh , return ::sinh (FLT(*args)); )
71FUNC( asinh , return ::asinh (FLT(*args)); )
72FUNC( cosh , return ::cosh (FLT(*args)); )
73FUNC( acosh , return ::acosh (FLT(*args)); )
74FUNC( tanh , return ::tanh (FLT(*args)); )
75FUNC( atanh , return ::atanh (FLT(*args)); )
77FUNC( exp , return ::exp (FLT(*args)); )
78FUNC( exp2 , return ::exp2 (FLT(*args)); )
79#
if defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID_NDK__)
80 FUNC(exp10 , return ::pow (10.0 ,FLT(*args)); )
82 FUNC(exp10 , return ::exp10 (FLT(*args)); )
86FUNC( log , return ::log (FLT(*args)); )
87FUNC( log2 , return ::log2 (FLT(*args)); )
89 FUNC( log10 , return ::log (FLT(*args)) / M_LN10; )
91 FUNC( log10 , return ::log10 (FLT(*args)); )
94FUNC( pow , return ::pow (FLT(*args++),FLT(*args)); )
95#
if defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID_NDK__)
96 FUNC(pow10 , return ::pow (10.0 ,FLT(*args)); )
98 FUNC(pow10 , return ::exp10 (FLT(*args)); )
100FUNC( sqrt , return ::sqrt (FLT(*args)); )
101FUNC( cbrt , return ::cbrt (FLT(*args)); )
118 constexpr int tableSize= 34;
119 Token functionNames[tableSize];
120 Token::LoadResourcedTokens( EXPRESSIONS,
"CPM", functionNames
124 Token* descriptor= functionNames;
129 { *descriptor++, constPI },
130 { *descriptor++, constE },
173 "Descriptor table size mismatch: Consumed {} descriptors, {} available.",
174 descriptor - functionNames, tableSize )
#define ALIB_WARNINGS_RESTORE
#define CALCULUS_CALLBACK(func)
#define CALCULUS_SIGNATURE(BoxPointerArray)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
@ Math
Collection of built-in unary and binary operators for boolean, integer and floating point values.
expressions::plugins::Calculus Calculus
Type alias in namespace alib.
strings::util::Token Token
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
expressions::Compiler Compiler
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
ALIB_API Math(Compiler &compiler)