bug fix: writeOutput calls from within writeOutput were losing tef_terms info

time-shift
Houtan Bastani 2011-04-12 13:33:03 +02:00
parent 4dbbba414f
commit a966eeb99f
1 changed files with 23 additions and 23 deletions

View File

@ -592,7 +592,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
if (output_type == oMatlabDynamicModelSparse || output_type == oMatlabStaticModelSparse) if (output_type == oMatlabDynamicModelSparse || output_type == oMatlabStaticModelSparse)
{ {
output << "("; output << "(";
datatree.local_variables_table[symb_id]->writeOutput(output, output_type, temporary_terms); datatree.local_variables_table[symb_id]->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ")"; output << ")";
} }
else else
@ -1626,7 +1626,7 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
new_output_type = output_type; new_output_type = output_type;
break; break;
} }
arg->writeOutput(output, new_output_type, temporary_terms); arg->writeOutput(output, new_output_type, temporary_terms, tef_terms);
return; return;
case oSteadyStateParamDeriv: case oSteadyStateParamDeriv:
{ {
@ -1678,7 +1678,7 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
} }
// Write argument // Write argument
arg->writeOutput(output, output_type, temporary_terms); arg->writeOutput(output, output_type, temporary_terms, tef_terms);
if (close_parenthesis) if (close_parenthesis)
output << RIGHT_PAR(output_type); output << RIGHT_PAR(output_type);
@ -2676,13 +2676,13 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
if (op_code == oPowerDeriv) if (op_code == oPowerDeriv)
{ {
if (IS_LATEX(output_type)) if (IS_LATEX(output_type))
unpackPowerDeriv()->writeOutput(output, output_type, temporary_terms); unpackPowerDeriv()->writeOutput(output, output_type, temporary_terms, tef_terms);
else else
{ {
output << "getPowerDeriv("; output << "getPowerDeriv(";
arg1->writeOutput(output, output_type, temporary_terms); arg1->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ","; output << ",";
arg2->writeOutput(output, output_type, temporary_terms); arg2->writeOutput(output, output_type, temporary_terms, tef_terms);
output << "," << powerDerivOrder << ")"; output << "," << powerDerivOrder << ")";
} }
return; return;
@ -2705,9 +2705,9 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
default: default:
; ;
} }
arg1->writeOutput(output, output_type, temporary_terms); arg1->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ","; output << ",";
arg2->writeOutput(output, output_type, temporary_terms); arg2->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ")"; output << ")";
return; return;
} }
@ -2731,7 +2731,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
} }
// Write left argument // Write left argument
arg1->writeOutput(output, output_type, temporary_terms); arg1->writeOutput(output, output_type, temporary_terms, tef_terms);
if (close_parenthesis) if (close_parenthesis)
output << RIGHT_PAR(output_type); output << RIGHT_PAR(output_type);
@ -2824,7 +2824,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
} }
// Write right argument // Write right argument
arg2->writeOutput(output, output_type, temporary_terms); arg2->writeOutput(output, output_type, temporary_terms, tef_terms);
if (IS_LATEX(output_type) && (op_code == oPower || op_code == oDivide)) if (IS_LATEX(output_type) && (op_code == oPower || op_code == oDivide))
output << "}"; output << "}";
@ -3703,21 +3703,21 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
{ {
// In C, there is no normcdf() primitive, so use erf() // In C, there is no normcdf() primitive, so use erf()
output << "(0.5*(1+erf((("; output << "(0.5*(1+erf(((";
arg1->writeOutput(output, output_type, temporary_terms); arg1->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ")-("; output << ")-(";
arg2->writeOutput(output, output_type, temporary_terms); arg2->writeOutput(output, output_type, temporary_terms, tef_terms);
output << "))/("; output << "))/(";
arg3->writeOutput(output, output_type, temporary_terms); arg3->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ")/M_SQRT2)))"; output << ")/M_SQRT2)))";
} }
else else
{ {
output << "normcdf("; output << "normcdf(";
arg1->writeOutput(output, output_type, temporary_terms); arg1->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ","; output << ",";
arg2->writeOutput(output, output_type, temporary_terms); arg2->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ","; output << ",";
arg3->writeOutput(output, output_type, temporary_terms); arg3->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ")"; output << ")";
} }
break; break;
@ -3726,23 +3726,23 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
{ {
//(1/(v3*sqrt(2*M_PI)*exp(pow((v1-v2)/v3,2)/2))) //(1/(v3*sqrt(2*M_PI)*exp(pow((v1-v2)/v3,2)/2)))
output << "(1/("; output << "(1/(";
arg3->writeOutput(output, output_type, temporary_terms); arg3->writeOutput(output, output_type, temporary_terms, tef_terms);
output << "*sqrt(2*M_PI)*exp(pow(("; output << "*sqrt(2*M_PI)*exp(pow((";
arg1->writeOutput(output, output_type, temporary_terms); arg1->writeOutput(output, output_type, temporary_terms, tef_terms);
output << "-"; output << "-";
arg2->writeOutput(output, output_type, temporary_terms); arg2->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ")/"; output << ")/";
arg3->writeOutput(output, output_type, temporary_terms); arg3->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ",2)/2)))"; output << ",2)/2)))";
} }
else else
{ {
output << "normpdf("; output << "normpdf(";
arg1->writeOutput(output, output_type, temporary_terms); arg1->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ","; output << ",";
arg2->writeOutput(output, output_type, temporary_terms); arg2->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ","; output << ",";
arg3->writeOutput(output, output_type, temporary_terms); arg3->writeOutput(output, output_type, temporary_terms, tef_terms);
output << ")"; output << ")";
} }
break; break;