From 75dbe4afde19fe1b9c82f1486e19e7679c8ad665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 10 Apr 2014 11:43:26 +0200 Subject: [PATCH] Bugfix: M_.sigma_e_is_diagonal could be wrong if there were several shocks blocks. --- ModFile.cc | 3 +++ Shocks.cc | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ModFile.cc b/ModFile.cc index 27299dea..649440c9 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -594,6 +594,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b mOutputFile << "M_.H = 0;" << endl << "M_.Correlation_matrix_ME = 1;" << endl; + // May be later modified by a shocks block + mOutputFile << "M_.sigma_e_is_diagonal = 1;" << endl; + // Initialize M_.det_shocks mOutputFile << "M_.det_shocks = [];" << endl; diff --git a/Shocks.cc b/Shocks.cc index 25adbdee..8373d9d9 100644 --- a/Shocks.cc +++ b/Shocks.cc @@ -89,9 +89,14 @@ ShocksStatement::writeOutput(ostream &output, const string &basename) const writeDetShocks(output); writeVarAndStdShocks(output); writeCovarAndCorrShocks(output); + + /* M_.sigma_e_is_diagonal is initialized to 1 by ModFile.cc. + If there are no off-diagonal elements, and we are not in overwrite mode, + then we don't reset it to 1, since there might be previous shocks blocks + with off-diagonal elements. */ if (covar_shocks.size()+corr_shocks.size() > 0) output << "M_.sigma_e_is_diagonal = 0;" << endl; - else + else if (overwrite) output << "M_.sigma_e_is_diagonal = 1;" << endl; }