Skip to content
Snippets Groups Projects
Verified Commit 83bfc792 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Sparse representation: fix bug in output of indices in driver and JSON files

It would previously forget to write the indices for the highest derivation
order (e.g. if order=3, then it would only write sparce indices up to 2nd
order).

Ref. dynare#1859
parent c721718b
No related branches found
No related tags found
No related merge requests found
......@@ -2242,7 +2242,7 @@ ModelTree::writeDriverSparseIndicesHelper(ostream &output) const
output << "]);" << endl;
// Write indices for the sparse higher-order derivatives
for (int i {2}; i < computed_derivs_order; i++)
for (int i {2}; i <= computed_derivs_order; i++)
{
output << "M_." << model_name << "_g" << i << "_sparse_indices = int32([";
for (const auto &[vidx, d] : derivatives[i])
......@@ -2292,7 +2292,7 @@ ModelTree::writeJsonSparseIndicesHelper(ostream &output) const
output << ']' << endl;
// Write indices for the sparse higher-order derivatives
for (int i {2}; i < computed_derivs_order; i++)
for (int i {2}; i <= computed_derivs_order; i++)
{
output << R"(, ")" << model_name << "_g" << i << R"(_sparse_indices": [)";
for (bool printed_something {false};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment