From 5313286db5ec5379588264f19ec03fa20f00d7a0 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer <jpfeifer@gmx.de> Date: Wed, 19 Jul 2023 21:10:22 +0200 Subject: [PATCH] StaticModel: remove transformation of complex residuals --- src/ModelTree.hh | 8 -------- src/StaticModel.cc | 6 ------ 2 files changed, 14 deletions(-) diff --git a/src/ModelTree.hh b/src/ModelTree.hh index 60192407..305e85f7 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -2500,10 +2500,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 +2530,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 diff --git a/src/StaticModel.cc b/src/StaticModel.cc index 7b59a287..fb15c881 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -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", -- GitLab