Commit 1329b57f authored by Sébastien Villemot's avatar Sébastien Villemot

Estimation DLL: fix DecisionRules::compute() (was not reentrant, since...

Estimation DLL: fix DecisionRules::compute() (was not reentrant, since GeneralizedSchurDecomposition::compute() modifies D and E)
parent 35450a29
...@@ -84,14 +84,6 @@ DecisionRules::DecisionRules(size_t n_arg, size_t p_arg, ...@@ -84,14 +84,6 @@ DecisionRules::DecisionRules(size_t n_arg, size_t p_arg,
pi_fwrd.push_back(i); pi_fwrd.push_back(i);
else else
beta_fwrd.push_back(i); 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 void
...@@ -110,12 +102,18 @@ DecisionRules::compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw ( ...@@ -110,12 +102,18 @@ DecisionRules::compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw (
QR.computeAndLeftMultByQ(S, "T", A); QR.computeAndLeftMultByQ(S, "T", A);
// Construct matrix D // 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++) 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, mat::col_copy(A, n_back_mixed + zeta_back_mixed[j], n_static, n - n_static,
D, j, 0); 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, 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 // 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); 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++) 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, mat::col_copy(A, n_back_mixed + zeta_fwrd_mixed[pi_fwrd[j]], n_static, n - n_static,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment