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
master
Sébastien Villemot 2022-12-07 16:10:03 +01:00
parent c721718bf6
commit 83bfc792af
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 2 additions and 2 deletions

View File

@ -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};