Fix crash when the model contains 1st or 2nd ext fcn deriv nodes.
In the case where the external function computes itself its derivatives, the TEF terms were not always created before being used, hence leading to a preprocessor crash. This problem could only happen with ramsey_policy, because otherwise the model does not contain derivatives of external functions.issue#70
parent
8882f809c3
commit
bd2405e292
25
ExprNode.cc
25
ExprNode.cc
|
@ -5018,7 +5018,17 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
|
||||||
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
|
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
|
||||||
assert(first_deriv_symb_id != eExtFunSetButNoNameProvided);
|
assert(first_deriv_symb_id != eExtFunSetButNoNameProvided);
|
||||||
|
|
||||||
if (first_deriv_symb_id == symb_id || alreadyWrittenAsTefTerm(first_deriv_symb_id, tef_terms))
|
/* For a node with derivs provided by the user function, call the method
|
||||||
|
on the non-derived node */
|
||||||
|
if (first_deriv_symb_id == symb_id)
|
||||||
|
{
|
||||||
|
expr_t parent = datatree.AddExternalFunction(symb_id, arguments);
|
||||||
|
parent->writeExternalFunctionOutput(output, output_type, temporary_terms,
|
||||||
|
tef_terms);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alreadyWrittenAsTefTerm(first_deriv_symb_id, tef_terms))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IS_C(output_type))
|
if (IS_C(output_type))
|
||||||
|
@ -5285,8 +5295,17 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
|
||||||
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
|
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
|
||||||
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
|
assert(second_deriv_symb_id != eExtFunSetButNoNameProvided);
|
||||||
|
|
||||||
if (alreadyWrittenAsTefTerm(second_deriv_symb_id, tef_terms)
|
/* For a node with derivs provided by the user function, call the method
|
||||||
|| second_deriv_symb_id == symb_id)
|
on the non-derived node */
|
||||||
|
if (second_deriv_symb_id == symb_id)
|
||||||
|
{
|
||||||
|
expr_t parent = datatree.AddExternalFunction(symb_id, arguments);
|
||||||
|
parent->writeExternalFunctionOutput(output, output_type, temporary_terms,
|
||||||
|
tef_terms);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alreadyWrittenAsTefTerm(second_deriv_symb_id, tef_terms))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IS_C(output_type))
|
if (IS_C(output_type))
|
||||||
|
|
Loading…
Reference in New Issue