diff --git a/mex/sources/k_order_perturbation/k_ord_dynare.cc b/mex/sources/k_order_perturbation/k_ord_dynare.cc index cce518db9..ce0b1b855 100644 --- a/mex/sources/k_order_perturbation/k_ord_dynare.cc +++ b/mex/sources/k_order_perturbation/k_ord_dynare.cc @@ -211,27 +211,9 @@ KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const ve s[2] = revOrder[s2]; else s[2] = s2; - // reordering symmetry indices in increasing order - if (s[0] > s[1]) - { - int temp = s[0]; - s[0] = s[1]; - s[1] = temp; - } - if (s[1] > s[2]) - { - int temp = s[1]; - s[1] = s[2]; - s[2] = temp; - } - if (s[0] > s[1]) - { - int temp = s[0]; - s[0] = s[1]; - s[1] = temp; - } - double x = g.get(i, 2); - mdTi->insert(s, j, x); + double x = g.get(i, 2); + if (s.isSorted()) + mdTi->insert(s, j, x); } } diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index c69bb7ef6..f071edd86 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -2137,8 +2137,6 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll) const d3->writeOutput(third_derivatives_output, output_type, temporary_terms); third_derivatives_output << ";" << endl; - k++; - // Compute the column numbers for the 5 other permutations of (id1,id2,id3) and store them in a set (to avoid duplicates if two indexes are equal) set cols; cols.insert(id1 * hessianColsNbr + id3 * dynJacobianColsNbr + id2); @@ -2147,7 +2145,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll) const cols.insert(id3 * hessianColsNbr + id1 * dynJacobianColsNbr + id2); cols.insert(id3 * hessianColsNbr + id2 * dynJacobianColsNbr + id1); - int k2 = 0; // Keeps the offset of the permutation relative to k + int k2 = 1; // Keeps the offset of the permutation relative to k for (set::iterator it2 = cols.begin(); it2 != cols.end(); it2++) if (*it2 != ref_col) {