diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index 9b13454a4c328378eb99c57916333d11bad06cd6..c979828b1ea1dc555086eed53aeba8c46e4788c9 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -96,7 +96,7 @@ Interpreter::compute_block_time(int Per_u_, bool evaluate, int block_num) { int var, lag = 0, op; ostringstream tmp_out; - double v1, v2; + double v1, v2, v3; bool go_on = true; double ll; while (go_on) @@ -635,6 +635,26 @@ Interpreter::compute_block_time(int Per_u_, bool evaluate, int block_num) Stack.push(sqrt(v1)); #ifdef DEBUG tmp_out << " |sqrt(" << v1 << ")|"; +#endif + break; + default: + ; + } + break; + case FTRINARY: + op = ((FTRINARY_ *) it_code->second)->get_op_type(); + v3 = Stack.top(); + Stack.pop(); + v2 = Stack.top(); + Stack.pop(); + v1 = Stack.top(); + Stack.pop(); + switch (op) + { + case oNormcdf: + Stack.push(0.5*(1+erf((v1-v2)/v3/M_SQRT2))); +#ifdef DEBUG + tmp_out << " |normcdf(" << v1 << ", " << v2 << ", " << v2 << ")|"; #endif break; default: diff --git a/preprocessor/CodeInterpreter.hh b/preprocessor/CodeInterpreter.hh index 90774f6a697d87eef24319c9b4ab7369c9319df8..cc201ee0cac43c084789411295d4589a3ca64a3a 100644 --- a/preprocessor/CodeInterpreter.hh +++ b/preprocessor/CodeInterpreter.hh @@ -85,6 +85,7 @@ enum Tags FUNARY, //!< A Unary operator - 14 FBINARY, //!< A binary operator - 15 + FTRINARY, //!< A trinary operator -15' FCUML, //!< Cumulates the result - 16 @@ -565,6 +566,22 @@ public: }; }; +class FTRINARY_ : public TagWithOneArgument<uint8_t> +{ +public: + inline FTRINARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FTRINARY) + { + }; + inline FTRINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FTRINARY, op_type_arg) + { + }; + inline uint8_t + get_op_type() + { + return arg1; + }; +}; + class FOK_ : public TagWithOneArgument<int> { public: @@ -1010,6 +1027,13 @@ public: tags_liste.push_back(make_pair(FBINARY, code)); code += sizeof(FBINARY_); break; + case FTRINARY: +# ifdef DEBUGL + mexPrintf("FTRINARY\n"); +# endif + tags_liste.push_back(make_pair(FTRINARY, code)); + code += sizeof(FTRINARY_); + break; case FOK: # ifdef DEBUGL mexPrintf("FOK\n"); diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc index f8445b519e7f7cd12ee03f8702786f5cf22c4c0d..c224cd56ac9fdcee91b2c5f71d3f6525be075eaa 100644 --- a/preprocessor/ExprNode.cc +++ b/preprocessor/ExprNode.cc @@ -2954,8 +2954,8 @@ TrinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms arg1->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic); arg2->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic); arg3->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic); - FBINARY_ fbinary(op_code); - fbinary.write(CompileCode); + FTRINARY_ ftrinary(op_code); + ftrinary.write(CompileCode); } void