diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 4503f2c4..8b424eb3 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -4441,7 +4441,11 @@ DynamicModel::computeChainRuleJacobian() switch (derivType) { case BlockDerivativeType::standard: - d = derivatives[1][{ eq_orig, deriv_id }]; + if (auto it = derivatives[1].find({ eq_orig, deriv_id }); + it != derivatives[1].end()) + d = it->second; + else + d = Zero; break; case BlockDerivativeType::chainRule: d = equations[eq_orig]->getChainRuleDerivative(deriv_id, recursive_vars); diff --git a/src/ModelTree.hh b/src/ModelTree.hh index d3e2a5c3..32c11974 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -106,7 +106,7 @@ protected: For each derivation order, stores a map whose key is a vector of integer: the first integer is the equation index, the remaining ones are the derivation IDs of variables (in non-decreasing order, to avoid storing symmetric - elements several times) */ + elements several times). Only non-zero derivatives are stored. */ vector, expr_t>> derivatives; //! Number of non-zero derivatives