Optimization for derivation of STEADY_STATE(…) operator in a dynamic context

In a dynamic context, the only potentially non-null derivatives of
STEADY_STATE(…) are the parameters. We know that the derivatives w.r.t. other
variables are zero, so store that information in non_null_derivatives.
master
Sébastien Villemot 2023-03-02 14:53:43 +01:00
parent d64317a64f
commit 41052ccb74
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 11 additions and 6 deletions

View File

@ -2136,13 +2136,18 @@ UnaryOpNode::prepareForDerivation()
preparedForDerivation = true;
arg->prepareForDerivation();
// Non-null derivatives are those of the argument (except for STEADY_STATE)
non_null_derivatives = arg->non_null_derivatives;
if (op_code == UnaryOpcode::steadyState || op_code == UnaryOpcode::steadyStateParamDeriv
|| op_code == UnaryOpcode::steadyStateParam2ndDeriv)
/* Non-null derivatives are those of the argument (except for STEADY_STATE in
a dynamic context, in which case the potentially non-null derivatives are
all the parameters) */
if ((op_code == UnaryOpcode::steadyState || op_code == UnaryOpcode::steadyStateParamDeriv
|| op_code == UnaryOpcode::steadyStateParam2ndDeriv)
&& datatree.isDynamic())
datatree.addAllParamDerivId(non_null_derivatives);
else
{
arg->prepareForDerivation();
non_null_derivatives = arg->non_null_derivatives;
}
}
expr_t