fix bugs with cbrt

- it was not handled in the model block
- output was incorrect for MATLAB/Octave and LaTeX
issue#70
Houtan Bastani 2019-12-04 10:43:46 +01:00
parent abbdbb5862
commit 2db2133796
No known key found for this signature in database
GPG Key ID: 000094FB955BE169
2 changed files with 18 additions and 1 deletions

View File

@ -1014,6 +1014,8 @@ hand_side : '(' hand_side ')'
{ $$ = driver.add_atan($3); }
| SQRT '(' hand_side ')'
{ $$ = driver.add_sqrt($3); }
| CBRT '(' hand_side ')'
{ $$ = driver.add_cbrt($3); }
| ABS '(' hand_side ')'
{ $$ = driver.add_abs($3); }
| SIGN '(' hand_side ')'

View File

@ -2777,7 +2777,22 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
output << "sqrt";
break;
case UnaryOpcode::cbrt:
output << "cbrt";
if (isMatlabOutput(output_type))
{
output << "nthroot(";
arg->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
output << ", 3)";
return;
}
else if (isLatexOutput(output_type))
{
output << R"(\sqrt[3]{)";
arg->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
output << "}";
return;
}
else
output << "cbrt";
break;
case UnaryOpcode::abs:
output << "abs";