From 0ef2f8c4bd36d59c2fe190c2283ff66fc7be5ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 19 Feb 2010 14:24:29 +0100 Subject: [PATCH] Estimation DLL: optimization of DecisionRules --- mex/sources/estimation/DecisionRules.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mex/sources/estimation/DecisionRules.cc b/mex/sources/estimation/DecisionRules.cc index b786407e3..72f9afc38 100644 --- a/mex/sources/estimation/DecisionRules.cc +++ b/mex/sources/estimation/DecisionRules.cc @@ -80,6 +80,14 @@ 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 @@ -102,21 +110,13 @@ DecisionRules::compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw ( 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); - MatrixView(D, n - n_static, 0, n_mixed, n_fwrd + n_back + 2*n_mixed).setAll(0.0); - for (size_t i = 0; i < n_mixed; i++) - D(n - n_static + i, beta_back[i]) = 1.0; // Construct matrix E 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, E, n_back_mixed + pi_fwrd[j], 0); - for (size_t j = 0; j < n_mixed; j++) - MatrixView(E, 0, n_back_mixed + beta_fwrd[j], n - n_static, 1).setAll(0.0); - mat::negate(MatrixView(E, 0, 0, n - n_static, n_fwrd + n_back + 2*n_mixed)); - MatrixView(E, n - n_static, 0, n_mixed, n_fwrd + n_back + 2*n_mixed).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; + mat::negate(MatrixView(E, 0, 0, n - n_static, n_fwrd + n_back + 2*n_mixed)); // Here we take the opposite of some of the zeros initialized in the constructor, but it is not a problem // Perform the generalized Schur size_t sdim;