C++ DecisionRules: support models with no static variables

time-shift
Sébastien Villemot 2013-02-07 16:03:11 +01:00
parent fac7319284
commit 6fc94a12d0
1 changed files with 26 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2010-2011 Dynare Team * Copyright (C) 2010-2013 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -95,11 +95,14 @@ DecisionRules::compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw (
assert(g_u.getRows() == n && g_u.getCols() == p); assert(g_u.getRows() == n && g_u.getCols() == p);
// Construct S, perform QR decomposition and get A = Q*jacobian // Construct S, perform QR decomposition and get A = Q*jacobian
A = MatrixConstView(jacobian, 0, 0, n, n_back_mixed + n + n_fwrd_mixed);
if (n_static > 0)
{
for (size_t i = 0; i < n_static; i++) for (size_t i = 0; i < n_static; i++)
mat::col_copy(jacobian, n_back_mixed+zeta_static[i], S, i); mat::col_copy(jacobian, n_back_mixed+zeta_static[i], S, i);
A = MatrixConstView(jacobian, 0, 0, n, n_back_mixed + n + n_fwrd_mixed);
QR.computeAndLeftMultByQ(S, "T", A); QR.computeAndLeftMultByQ(S, "T", A);
}
// Construct matrix D // Construct matrix D
D.setAll(0.0); D.setAll(0.0);
@ -166,6 +169,8 @@ DecisionRules::compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw (
mat::row_copy(g_y_back, i, g_y, zeta_back_mixed[i]); mat::row_copy(g_y_back, i, g_y, zeta_back_mixed[i]);
// Compute DR for static variables w.r. to endogenous // Compute DR for static variables w.r. to endogenous
if (n_static > 0)
{
g_y_static = MatrixView(A, 0, 0, n_static, n_back_mixed); g_y_static = MatrixView(A, 0, 0, n_static, n_back_mixed);
for (size_t i = 0; i < n_dynamic; i++) for (size_t i = 0; i < n_dynamic; i++)
{ {
@ -183,6 +188,7 @@ DecisionRules::compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw (
for (size_t i = 0; i < n_static; i++) for (size_t i = 0; i < n_static; i++)
mat::row_copy(g_y_static, i, g_y, zeta_static[i]); mat::row_copy(g_y_static, i, g_y, zeta_static[i]);
}
// Compute DR for all endogenous w.r. to shocks // Compute DR for all endogenous w.r. to shocks
blas::gemm("N", "N", 1.0, MatrixConstView(jacobian, 0, n_back_mixed + n, n, n_fwrd_mixed), g_y_fwrd, 0.0, g_u_tmp1); blas::gemm("N", "N", 1.0, MatrixConstView(jacobian, 0, n_back_mixed + n, n, n_fwrd_mixed), g_y_fwrd, 0.0, g_u_tmp1);