From 1329b57ff25efd4805072ec2f589dd3a388486d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Mon, 13 Dec 2010 17:15:08 +0100 Subject: [PATCH] Estimation DLL: fix DecisionRules::compute() (was not reentrant, since GeneralizedSchurDecomposition::compute() modifies D and E) --- mex/sources/estimation/DecisionRules.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mex/sources/estimation/DecisionRules.cc b/mex/sources/estimation/DecisionRules.cc index 1e96560c5..75fea6762 100644 --- a/mex/sources/estimation/DecisionRules.cc +++ b/mex/sources/estimation/DecisionRules.cc @@ -84,14 +84,6 @@ DecisionRules::DecisionRules(size_t n_arg, size_t p_arg, pi_fwrd.push_back(i); else beta_fwrd.push_back(i); - - // Construct the fixed part of D and E - D.setAll(0.0); - for (size_t i = 0; i < n_mixed; i++) - D(n - n_static + i, beta_back[i]) = 1.0; - E.setAll(0.0); - for (size_t i = 0; i < n_mixed; i++) - E(n - n_static + i, n_back_mixed + beta_fwrd[i]) = 1.0; } void @@ -110,12 +102,18 @@ DecisionRules::compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw ( QR.computeAndLeftMultByQ(S, "T", A); // Construct matrix D + D.setAll(0.0); + for (size_t i = 0; i < n_mixed; i++) + D(n - n_static + i, beta_back[i]) = 1.0; for (size_t j = 0; j < n_back_mixed; j++) mat::col_copy(A, n_back_mixed + zeta_back_mixed[j], n_static, n - n_static, D, j, 0); MatrixView(D, 0, n_back_mixed, n - n_static, n_fwrd_mixed) = MatrixView(A, n_static, n_back_mixed + n, n - n_static, n_fwrd_mixed); // Construct matrix E + E.setAll(0.0); + for (size_t i = 0; i < n_mixed; i++) + E(n - n_static + i, n_back_mixed + beta_fwrd[i]) = 1.0; MatrixView(E, 0, 0, n - n_static, n_back_mixed) = MatrixView(A, n_static, 0, n - n_static, n_back_mixed); for (size_t j = 0; j < n_fwrd; j++) mat::col_copy(A, n_back_mixed + zeta_fwrd_mixed[pi_fwrd[j]], n_static, n - n_static, -- GitLab