Merge branch 'complex_resid' of git.dynare.org:JohannesPfeifer/preprocessor

Ref. !80
master
Sébastien Villemot 2023-09-20 10:04:09 +02:00
commit bdb5cdacf2
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 0 additions and 22 deletions

View File

@ -2374,10 +2374,6 @@ ModelTree::writeSparseModelJuliaFiles(const string &basename) const
<< "@inbounds begin" << endl
<< d_sparse_output[0].str()
<< "end" << endl;
if constexpr(!dynamic)
output << " if ~isreal(residual)" << endl
<< " residual = real(residual)+imag(residual).^2;" << endl
<< " end" << endl;
output << " return nothing" << endl
<< "end" << endl << endl;
writeToFileIfModified(output, julia_dir / (prefix + "Resid!.jl"));
@ -2408,10 +2404,6 @@ ModelTree::writeSparseModelJuliaFiles(const string &basename) const
<< "@inbounds begin" << endl
<< d_sparse_output[1].str()
<< "end" << endl;
if constexpr(!dynamic)
output << " if ~isreal(g1_v)" << endl
<< " g1_v = real(g1_v)+2*imag(g1_v);" << endl
<< " end" << endl;
output << " return nothing" << endl
<< "end" << endl << endl;
writeToFileIfModified(output, julia_dir / (prefix + "G1!.jl"));
@ -2500,10 +2492,6 @@ ModelTree::writeSparseModelMFiles(const string &basename) const
<< "[T_order, T] = " << full_prefix << "resid_tt(y, x, params" << ss_arg << ", T_order, T);" << endl
<< "residual = NaN(" << equations.size() << ", 1);" << endl
<< d_sparse_output[0].str();
if constexpr(!dynamic)
output << "if ~isreal(residual)" << endl
<< " residual = real(residual)+imag(residual).^2;" << endl
<< "end" << endl;
output << "end" << endl;
output.close();
@ -2534,10 +2522,6 @@ ModelTree::writeSparseModelMFiles(const string &basename) const
<< "[T_order, T] = " << full_prefix << "g1_tt(y, x, params" << ss_arg << ", T_order, T);" << endl
<< "g1_v = NaN(" << jacobian_sparse_column_major_order.size() << ", 1);" << endl
<< d_sparse_output[1].str();
if constexpr(!dynamic)
output << "if ~isreal(g1_v)" << endl
<< " g1_v = real(g1_v)+2*imag(g1_v);" << endl
<< "end" << endl;
// On MATLAB < R2020a, sparse() does not accept int32 indices
output << "if ~isoctave && matlab_ver_less_than('9.8')" << endl
<< " sparse_rowval = double(sparse_rowval);" << endl

View File

@ -227,9 +227,6 @@ StaticModel::writeStaticMFile(const string &basename) const
ostringstream init_output, end_output;
init_output << "residual = zeros(" << equations.size() << ", 1);";
end_output << "if ~isreal(residual)" << endl
<< " residual = real(residual)+imag(residual).^2;" << endl
<< "end";
writeStaticMFileHelper(basename, "static_resid", "residual", "static_resid_tt",
temporary_terms_derivatives[0].size(),
"", init_output, end_output,
@ -238,9 +235,6 @@ StaticModel::writeStaticMFile(const string &basename) const
init_output.str("");
end_output.str("");
init_output << "g1 = zeros(" << equations.size() << ", " << symbol_table.endo_nbr() << ");";
end_output << "if ~isreal(g1)" << endl
<< " g1 = real(g1)+2*imag(g1);" << endl
<< "end";
writeStaticMFileHelper(basename, "static_g1", "g1", "static_g1_tt",
temporary_terms_derivatives[0].size() + temporary_terms_derivatives[1].size(),
"static_resid_tt",