Verified Commit fc9cc2dc authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Output symmetric elements in derivatives of hessian w.r.t. parameters

The preprocessor now writes all the symmetric elements in the "hp"
matrix (derivatives of the hessian w.r.t. parameters), for consistency with all
other derivatives output.

Previously it was only writing one of the two symmetric elements, when indices
of endogenous were different.
parent e3a3992c
Pipeline #381 passed with stage
in 1 minute and 45 seconds
......@@ -5526,6 +5526,24 @@ DynamicModel::writeParamsDerivativesFile(const string &basename, bool julia) con
third_derivs1_output << ";" << endl;
i++;
if (var1 != var2)
{
// Treat symmetric elements
third_derivs1_output << "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",1"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << "=" << eq+1 << ";" << endl
<< "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",2"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << "=" << var2_col << ";" << endl
<< "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",3"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << "=" << var1_col << ";" << endl
<< "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",4"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << "=" << param_col << ";" << endl
<< "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",5"
<< RIGHT_ARRAY_SUBSCRIPT(output_type)
<< "=hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i-1 << ",5"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << ";" << endl;
i++;
}
}
string filename = julia ? basename + "DynamicParamsDerivs.jl" : packageDir(basename) + "/dynamic_params_derivs.m";
......
......@@ -2798,6 +2798,24 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
third_derivs1_output << ";" << endl;
i++;
if (var1 != var2)
{
// Treat symmetric elements
third_derivs1_output << "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",1"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << "=" << eq+1 << ";" << endl
<< "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",2"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << "=" << var2_col << ";" << endl
<< "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",3"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << "=" << var1_col << ";" << endl
<< "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",4"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << "=" << param_col << ";" << endl
<< "hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i << ",5"
<< RIGHT_ARRAY_SUBSCRIPT(output_type)
<< "=hp" << LEFT_ARRAY_SUBSCRIPT(output_type) << i-1 << ",5"
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << ";" << endl;
i++;
}
}
ofstream paramsDerivsFile;
......
Supports Markdown
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