Commit bbab112d authored by Sébastien Villemot's avatar Sébastien Villemot

Support for output of arbitrary derivation order (in MATLAB and DLL modes)

Does not work for Julia mode, neither with block and bytecode.

Note: in DLL mode, the number of temporary terms in no longer given in the
‘ntt’ symbol; it must be computed using ‘M_.dynamic_tmp_nbr’.

Ref dynare#217
parent e689032c
Pipeline #1131 passed with stage
in 1 minute and 30 seconds
This diff is collapsed.
......@@ -750,7 +750,7 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri
|| mod_file_struct.ramsey_model_present || mod_file_struct.identification_present
|| mod_file_struct.calib_smoother_present)
dynamic_model.set_cutoff_to_zero();
if (mod_file_struct.order_option < 1 || mod_file_struct.order_option > 3)
if (mod_file_struct.order_option < 1)
{
cerr << "ERROR: Incorrect order option..." << endl;
exit(EXIT_FAILURE);
......
......@@ -1276,12 +1276,12 @@ ModelTree::computeDerivatives(int order, const set<int> &vars)
assert (order >= 1);
// Do not shrink the vectors, since they have a minimal size of 4 (see constructor)
derivatives.resize(max(static_cast<size_t>(order), derivatives.size()));
NNZDerivatives.resize(max(static_cast<size_t>(order), NNZDerivatives.size()), 0);
derivatives.resize(max(static_cast<size_t>(order+1), derivatives.size()));
NNZDerivatives.resize(max(static_cast<size_t>(order+1), NNZDerivatives.size()), 0);
// First-order derivatives
for (int var : vars)
for (int eq = 0; eq < (int) equations.size(); eq++)
for (int eq = 0; eq < static_cast<int>(equations.size()); eq++)
{
expr_t d1 = equations[eq]->getDerivative(var);
if (d1 == Zero)
......@@ -1306,9 +1306,15 @@ ModelTree::computeDerivatives(int order, const set<int> &vars)
indices.push_back(var);
// At this point, indices of endogenous variables are sorted in non-decreasing order
derivatives[o][indices] = d;
do
// We output symmetries at order ≤ 3
if (o <= 3)
{
do
NNZDerivatives[o]++;
while (next_permutation(next(indices.begin()), indices.end()));
}
else
NNZDerivatives[o]++;
while (next_permutation(next(indices.begin()), indices.end()));
}
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment