192d648b2SVijay Khemka /* 292d648b2SVijay Khemka * This define will disable the ability for expressions to have comments. 392d648b2SVijay Khemka * Expressions that have comments when parsed with a build that has this 492d648b2SVijay Khemka * option, will result in a compilation failure. 592d648b2SVijay Khemka */ 692d648b2SVijay Khemka // #define exprtk_disable_comments 792d648b2SVijay Khemka /* 892d648b2SVijay Khemka * This define will disable the loop-wise 'break' and 'continue' 992d648b2SVijay Khemka * capabilities. Any expression that contains those keywords will result 1092d648b2SVijay Khemka * in a compilation failure. 1192d648b2SVijay Khemka */ 1292d648b2SVijay Khemka #define exprtk_disable_break_continue 1392d648b2SVijay Khemka /* 1492d648b2SVijay Khemka * This define will disable the short-circuit '&' (and) and '|' (or) 1592d648b2SVijay Khemka * operators 1692d648b2SVijay Khemka */ 1792d648b2SVijay Khemka #define exprtk_disable_sc_andor 1892d648b2SVijay Khemka /* 1992d648b2SVijay Khemka * This define will disable all enhanced features such as strength 2092d648b2SVijay Khemka * reduction and special function optimisations and expression specific 2192d648b2SVijay Khemka * type instantiations. This feature will reduce compilation times and 2292d648b2SVijay Khemka * binary sizes but will also result in massive performance degradation 2392d648b2SVijay Khemka * of expression evaluations. 2492d648b2SVijay Khemka */ 2592d648b2SVijay Khemka #define exprtk_disable_enhanced_features 2692d648b2SVijay Khemka /* 2792d648b2SVijay Khemka * This define will disable all string processing capabilities. Any 2892d648b2SVijay Khemka * expression that contains a string or string related syntax will result 2992d648b2SVijay Khemka * in a compilation failure. 3092d648b2SVijay Khemka */ 3192d648b2SVijay Khemka #define exprtk_disable_string_capabilities 3292d648b2SVijay Khemka 3392d648b2SVijay Khemka #define exprtk_disable_rtl_io_file 3492d648b2SVijay Khemka #define exprtk_disable_return_statement 3592d648b2SVijay Khemka #define exprtk_disable_rtl_io 3692d648b2SVijay Khemka #define exprtk_disable_superscalar_unroll 3792d648b2SVijay Khemka 3892d648b2SVijay Khemka /* include main exprtk header library */ 3992d648b2SVijay Khemka #include <exprtk.hpp> 40*0ab9d838SLei YU 41*0ab9d838SLei YU #include <cmath> 42*0ab9d838SLei YU #include <limits> 43*0ab9d838SLei YU #include <numeric> 44*0ab9d838SLei YU 45*0ab9d838SLei YU /* For floating types. (float, double, long double et al) */ 46*0ab9d838SLei YU template <typename T> 47*0ab9d838SLei YU struct FuncMaxIgnoreNaN : public exprtk::ivararg_function<T> 48*0ab9d838SLei YU { 49*0ab9d838SLei YU FuncMaxIgnoreNaN() 50*0ab9d838SLei YU { 51*0ab9d838SLei YU exprtk::set_min_num_args(*this, 2); 52*0ab9d838SLei YU exprtk::set_max_num_args(*this, 255); 53*0ab9d838SLei YU } 54*0ab9d838SLei YU 55*0ab9d838SLei YU inline T operator()(const std::vector<T>& argList) 56*0ab9d838SLei YU { 57*0ab9d838SLei YU return std::reduce(std::begin(argList), std::end(argList), 58*0ab9d838SLei YU std::numeric_limits<double>::quiet_NaN(), 59*0ab9d838SLei YU [](auto a, auto b) { 60*0ab9d838SLei YU if (std::isnan(b)) 61*0ab9d838SLei YU { 62*0ab9d838SLei YU return a; 63*0ab9d838SLei YU } 64*0ab9d838SLei YU if (std::isnan(a)) 65*0ab9d838SLei YU { 66*0ab9d838SLei YU return b; 67*0ab9d838SLei YU } 68*0ab9d838SLei YU return std::max(a, b); 69*0ab9d838SLei YU }); 70*0ab9d838SLei YU } 71*0ab9d838SLei YU }; 72