Commit fb6a11f5 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

move estimation-dll to its own repository: https://github.com/DynareTeam/estimation-dll.git

parent 38c29758
......@@ -86,10 +86,6 @@ CPPFLAGS="$CPPFLAGS_SAVED"
# Don't use deprecated hash structures
AC_DEFINE([BOOST_NO_HASH], [], [Don't use deprecated STL hash structures])
# Check for dlopen(), needed by tests for estimation DLL
AC_CHECK_LIB([dl], [dlopen], [LIBADD_DLOPEN="-ldl"], [])
AC_SUBST([LIBADD_DLOPEN])
# Check for libmatio, needed by Dynare++
AX_MATIO
AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"])
......@@ -199,10 +195,6 @@ AC_CONFIG_FILES([Makefile
dynare++/kord/Makefile
dynare++/src/Makefile
mex/sources/Makefile
mex/sources/estimation/Makefile
mex/sources/estimation/tests/Makefile
mex/sources/estimation/libmat/Makefile
mex/sources/estimation/libmat/tests/Makefile
])
AC_ARG_ENABLE([matlab], AS_HELP_STRING([--disable-matlab], [disable compilation of MEX files for MATLAB]), [], [enable_matlab=yes])
......
mex_PROGRAMS = logposterior logMHMCMCposterior
# We use shared flags so that automake does not compile things two times
AM_CPPFLAGS += -I$(top_srcdir)/../../sources/estimation/libmat -I$(top_srcdir)/../../sources/estimation/utils $(CPPFLAGS_MATIO) $(BOOST_CPPFLAGS) $(GSL_CPPFLAGS)
AM_LDFLAGS += $(LDFLAGS_MATIO) $(BOOST_LDFLAGS) $(GSL_LDFLAGS)
LDADD = $(LIBADD_DLOPEN) $(LIBADD_MATIO) $(GSL_LIBS)
TOPDIR = $(top_srcdir)/../../sources/estimation
MAT_SRCS = \
$(TOPDIR)/libmat/Matrix.hh \
$(TOPDIR)/libmat/Matrix.cc \
$(TOPDIR)/libmat/Vector.hh \
$(TOPDIR)/libmat/Vector.cc \
$(TOPDIR)/libmat/BlasBindings.hh \
$(TOPDIR)/libmat/DiscLyapFast.hh \
$(TOPDIR)/libmat/GeneralizedSchurDecomposition.cc \
$(TOPDIR)/libmat/GeneralizedSchurDecomposition.hh \
$(TOPDIR)/libmat/LapackBindings.hh \
$(TOPDIR)/libmat/LUSolver.cc \
$(TOPDIR)/libmat/LUSolver.hh \
$(TOPDIR)/libmat/QRDecomposition.cc \
$(TOPDIR)/libmat/QRDecomposition.hh \
$(TOPDIR)/libmat/VDVEigDecomposition.cc \
$(TOPDIR)/libmat/VDVEigDecomposition.hh
COMMON_SRCS = \
$(MAT_SRCS) \
$(TOPDIR)/DecisionRules.cc \
$(TOPDIR)/DecisionRules.hh \
$(TOPDIR)/DetrendData.cc \
$(TOPDIR)/DetrendData.hh \
$(TOPDIR)/EstimatedParameter.cc \
$(TOPDIR)/EstimatedParameter.hh \
$(TOPDIR)/EstimatedParametersDescription.cc \
$(TOPDIR)/EstimatedParametersDescription.hh \
$(TOPDIR)/EstimationSubsample.cc \
$(TOPDIR)/EstimationSubsample.hh \
$(TOPDIR)/InitializeKalmanFilter.cc \
$(TOPDIR)/InitializeKalmanFilter.hh \
$(TOPDIR)/KalmanFilter.cc \
$(TOPDIR)/KalmanFilter.hh \
$(TOPDIR)/LogLikelihoodSubSample.cc \
$(TOPDIR)/LogLikelihoodSubSample.hh \
$(TOPDIR)/LogLikelihoodMain.hh \
$(TOPDIR)/LogLikelihoodMain.cc \
$(TOPDIR)/LogPosteriorDensity.cc \
$(TOPDIR)/LogPosteriorDensity.hh \
$(TOPDIR)/LogPriorDensity.cc \
$(TOPDIR)/LogPriorDensity.hh \
$(TOPDIR)/ModelSolution.cc \
$(TOPDIR)/ModelSolution.hh \
$(TOPDIR)/Prior.cc \
$(TOPDIR)/Prior.hh \
$(TOPDIR)/SteadyStateSolver.cc \
$(TOPDIR)/SteadyStateSolver.hh \
$(TOPDIR)/utils/dynamic_dll.cc \
$(TOPDIR)/utils/dynamic_dll.hh \
$(TOPDIR)/utils/static_dll.cc \
$(TOPDIR)/utils/static_dll.hh
nodist_logposterior_SOURCES = \
$(COMMON_SRCS) \
$(TOPDIR)/logposterior.cc
nodist_logMHMCMCposterior_SOURCES = \
$(COMMON_SRCS) \
$(TOPDIR)/Proposal.cc \
$(TOPDIR)/Proposal.hh \
$(TOPDIR)/RandomWalkMetropolisHastings.hh \
$(TOPDIR)/logMHMCMCposterior.cc
......@@ -10,7 +10,7 @@ SUBDIRS += k_order_perturbation dynare_simul_
endif
if HAVE_GSL
SUBDIRS += ms_sbvar estimation
SUBDIRS += ms_sbvar
endif
if HAVE_SLICOT
......
dnl Process this file with autoconf to produce a configure script.
dnl Copyright (C) 2009-2014 Dynare Team
dnl Copyright (C) 2009-2017 Dynare Team
dnl
dnl This file is part of Dynare.
dnl
......@@ -72,15 +72,6 @@ case ${host_os} in
esac
AX_PTHREAD
# Check for boost libraries used in estimation DLL
AC_LANG_PUSH([C++])
AX_BOOST_BASE([1.36], [], [AC_MSG_ERROR([Can't find Boost >= 1.36])])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_CHECK_HEADER([boost/random/linear_congruential.hpp], [], [AC_MSG_ERROR([Can't find Boost Random Library])])
AC_CHECK_HEADER([boost/math/distributions/beta.hpp], [], [AC_MSG_ERROR([Can't find Boost Math Library])])
CPPFLAGS="$CPPFLAGS_SAVED"
AC_LANG_POP([C++])
# Check for dlopen(), needed by k_order_perturbation DLL
AC_CHECK_LIB([dl], [dlopen], [LIBADD_DLOPEN="-ldl"], [])
AC_SUBST([LIBADD_DLOPEN])
......@@ -150,7 +141,7 @@ Dynare is now configured for building the following components...
Binaries (with "make"):
MEX files for MATLAB (except those listed below): $BUILD_MEX_MATLAB
k-order and dynare_simul MEX files for MATLAB: $BUILD_KORDER_DYNSIMUL_MEX_MATLAB
K-order and dynare_simul MEX files for MATLAB: $BUILD_KORDER_DYNSIMUL_MEX_MATLAB
MS-SBVAR MEX files for MATLAB: $BUILD_MS_SBVAR_MEX_MATLAB
Kalman Steady State MEX file for MATLAB: $BUILD_KALMAN_STEADY_STATE_MATLAB
M2HTML documentation: $BUILD_M2HTML
......@@ -165,7 +156,6 @@ AC_CONFIG_FILES([Makefile
gensylv/Makefile
k_order_perturbation/Makefile
dynare_simul_/Makefile
estimation/Makefile
kalman_steady_state/Makefile
ms_sbvar/Makefile
block_kalman_filter/Makefile
......
include ../mex.am
include ../../estimation.am
......@@ -18,7 +18,7 @@ endif
if HAVE_GSL
if HAVE_MATIO
SUBDIRS += ms_sbvar estimation
SUBDIRS += ms_sbvar
endif
endif
......
dnl Process this file with autoconf to produce a configure script.
dnl Copyright (C) 2009-2015 Dynare Team
dnl Copyright (C) 2009-2017 Dynare Team
dnl
dnl This file is part of Dynare.
dnl
......@@ -52,15 +52,6 @@ AX_PROG_LN_S
AC_PROG_MKDIR_P
AM_PROG_AR
AX_PTHREAD
# Check for boost libraries used in estimation DLL
AC_LANG_PUSH([C++])
AX_BOOST_BASE([1.36], [], [AC_MSG_ERROR([Can't find Boost >= 1.36])])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_CHECK_HEADER([boost/random/linear_congruential.hpp], [], [AC_MSG_ERROR([Can't find Boost Random Library])])
AC_CHECK_HEADER([boost/math/distributions/beta.hpp], [], [AC_MSG_ERROR([Can't find Boost Math Library])])
CPPFLAGS="$CPPFLAGS_SAVED"
AC_LANG_POP([C++])
# Check for dlopen(), needed by k_order_perturbation DLL
AC_CHECK_LIB([dl], [dlopen], [LIBADD_DLOPEN="-ldl"], [])
AC_SUBST([LIBADD_DLOPEN])
......@@ -68,7 +59,7 @@ AC_SUBST([LIBADD_DLOPEN])
AX_GSL
AM_CONDITIONAL([HAVE_GSL], [test "x$has_gsl" = "xyes"])
# Check for libmatio, needed by estimation DLL (only under Octave, as an alternative to MATLAB's libmat)
# Check for libmatio, needed by k-order, dynare_simul, ms-sbvar (only under Octave, as an alternative to MATLAB's libmat)
AX_MATIO
AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"])
......@@ -100,9 +91,9 @@ else
fi
if test "x$MKOCTFILE" != "x" -a "x$has_matio" = "xyes"; then
BUILD_ESTIMATION_KORDER_DYNSIMUL_MEX_OCTAVE="yes"
BUILD_KORDER_DYNSIMUL_MEX_OCTAVE="yes"
else
BUILD_ESTIMATION_KORDER_DYNSIMUL_MEX_OCTAVE="no (missing MatIO library)"
BUILD_KORDER_DYNSIMUL_MEX_OCTAVE="no (missing MatIO library)"
fi
if test "x$MKOCTFILE" != "x" -a "x$has_slicot" = "xyes"; then
......@@ -145,7 +136,7 @@ Binaries (with "make"):
MEX files for Octave (except those listed below): $BUILD_MEX_OCTAVE
MS-SBVAR MEX files for Octave: $BUILD_MS_SBVAR_MEX_OCTAVE
Kalman Steady State MEX file for Octave: $BUILD_KALMAN_STEADY_STATE_OCTAVE
Estimation, k-order and dynare_simul MEX for Octave: $BUILD_ESTIMATION_KORDER_DYNSIMUL_MEX_OCTAVE
K-order and dynare_simul MEX for Octave: $BUILD_KORDER_DYNSIMUL_MEX_OCTAVE
Linsolve for Octave: $BUILD_LINSOLVE_OCTAVE
Ordschur for Octave: $BUILD_ORDSCHUR_OCTAVE
......@@ -159,7 +150,6 @@ AC_CONFIG_FILES([Makefile
gensylv/Makefile
k_order_perturbation/Makefile
dynare_simul_/Makefile
estimation/Makefile
qzcomplex/Makefile
ordschur/Makefile
kalman_steady_state/Makefile
......
EXEEXT = .mex
include ../mex.am
include ../../estimation.am
SUBDIRS = estimation
EXTRA_DIST = \
dynblas.h \
dynlapack.h \
......
/*
* Copyright (C) 2010-2017 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cassert>
#include <algorithm>
#include "DecisionRules.hh"
DecisionRules::DecisionRules(size_t n_arg, size_t p_arg,
const std::vector<size_t> &zeta_fwrd_arg,
const std::vector<size_t> &zeta_back_arg,
const std::vector<size_t> &zeta_mixed_arg,
const std::vector<size_t> &zeta_static_arg,
double qz_criterium) :
n(n_arg), p(p_arg), zeta_fwrd(zeta_fwrd_arg), zeta_back(zeta_back_arg),
zeta_mixed(zeta_mixed_arg), zeta_static(zeta_static_arg),
n_fwrd(zeta_fwrd.size()), n_back(zeta_back.size()),
n_mixed(zeta_mixed.size()), n_static(zeta_static.size()),
n_back_mixed(n_back+n_mixed), n_fwrd_mixed(n_fwrd+n_mixed),
n_dynamic(n-n_static),
S(n, n_static),
A(n, n_back_mixed + n + n_fwrd_mixed),
D(n_fwrd + n_back + 2*n_mixed),
E(n_fwrd + n_back + 2*n_mixed),
Z_prime(n_fwrd + n_back + 2*n_mixed),
QR(n, n_static, n_back_mixed + n + n_fwrd_mixed),
GSD(n_fwrd + n_back + 2*n_mixed, qz_criterium),
LU1(n_fwrd_mixed),
LU2(n_back_mixed),
LU3(n_static),
Z21(n_fwrd_mixed, n_back_mixed),
g_y_back(n_back_mixed),
g_y_back_tmp(n_back_mixed),
g_y_static(n_static, n_back_mixed),
A0s(n_static),
A0d(n_static, n_dynamic),
g_y_dynamic(n_dynamic, n_back_mixed),
g_y_static_tmp(n_fwrd_mixed, n_back_mixed),
g_u_tmp1(n, n_back_mixed),
g_u_tmp2(n),
LU4(n)
{
assert(n == n_back + n_fwrd + n_mixed + n_static);
set_union(zeta_fwrd.begin(), zeta_fwrd.end(),
zeta_mixed.begin(), zeta_mixed.end(),
back_inserter(zeta_fwrd_mixed));
set_union(zeta_back.begin(), zeta_back.end(),
zeta_mixed.begin(), zeta_mixed.end(),
back_inserter(zeta_back_mixed));
set_union(zeta_back_mixed.begin(), zeta_back_mixed.end(),
zeta_fwrd.begin(), zeta_fwrd.end(),
back_inserter(zeta_dynamic));
// Compute beta_back and pi_back
for (size_t i = 0; i < n_back_mixed; i++)
if (find(zeta_mixed.begin(), zeta_mixed.end(), zeta_back_mixed[i])
== zeta_mixed.end())
pi_back.push_back(i);
else
beta_back.push_back(i);
// Compute beta_fwrd and pi_fwrd
for (size_t i = 0; i < n_fwrd_mixed; i++)
if (find(zeta_mixed.begin(), zeta_mixed.end(), zeta_fwrd_mixed[i])
== zeta_mixed.end())
pi_fwrd.push_back(i);
else
beta_fwrd.push_back(i);
}
void
DecisionRules::compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw (BlanchardKahnException, GeneralizedSchurDecomposition::GSDException)
{
assert(jacobian.getRows() == n
&& jacobian.getCols() == (n_back_mixed + n + n_fwrd_mixed + p));
assert(g_y.getRows() == n && g_y.getCols() == n_back_mixed);
assert(g_u.getRows() == n && g_u.getCols() == p);
// 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++)
mat::col_copy(jacobian, n_back_mixed+zeta_static[i], S, i);
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,
E, n_back_mixed + pi_fwrd[j], 0);
MatrixView E_tmp(E, 0, 0, n - n_static, n_fwrd + n_back + 2*n_mixed);
mat::negate(E_tmp); // 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;
GSD.compute(E, D, Z_prime, sdim);
if (n_back_mixed != sdim)
throw BlanchardKahnException(true, n_fwrd_mixed, n_fwrd + n_back + 2*n_mixed - sdim);
// Compute DR for forward variables w.r. to endogenous
MatrixView Z21_prime(Z_prime, 0, n_back_mixed, n_back_mixed, n_fwrd_mixed),
Z22_prime(Z_prime, n_back_mixed, n_back_mixed, n_fwrd_mixed, n_fwrd_mixed);
mat::transpose(Z21, Z21_prime);
try
{
LU1.invMult("T", Z22_prime, Z21);
}
catch (LUSolver::LUException &e)
{
throw BlanchardKahnException(false, n_fwrd_mixed, n_fwrd + n_back + 2*n_mixed - sdim);
}
mat::negate(Z21);
const Matrix &g_y_fwrd = Z21;
for (size_t i = 0; i < n_fwrd_mixed; i++)
mat::row_copy(g_y_fwrd, i, g_y, zeta_fwrd_mixed[i]);
// Compute DR for backward variables w.r. to endogenous
MatrixView Z11_prime(Z_prime, 0, 0, n_back_mixed, n_back_mixed),
T11(D, 0, 0, n_back_mixed, n_back_mixed),
S11(E, 0, 0, n_back_mixed, n_back_mixed);
mat::set_identity(g_y_back);
g_y_back_tmp = Z11_prime;
LU2.invMult("N", g_y_back_tmp, g_y_back);
g_y_back_tmp = g_y_back;
blas::gemm("N", "N", 1.0, S11, g_y_back_tmp, 0.0, g_y_back);
LU2.invMult("N", T11, g_y_back);
g_y_back_tmp = g_y_back;
blas::gemm("N", "N", 1.0, Z11_prime, g_y_back_tmp, 0.0, g_y_back);
// TODO: avoid to copy mixed variables again, rather test it...
for (size_t i = 0; i < n_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
if (n_static > 0)
{
g_y_static = MatrixView(A, 0, 0, n_static, n_back_mixed);
for (size_t i = 0; i < n_dynamic; i++)
{
mat::row_copy(g_y, zeta_dynamic[i], g_y_dynamic, i);
mat::col_copy(A, n_back_mixed + zeta_dynamic[i], 0, n_static, A0d, i, 0);
}
blas::gemm("N", "N", 1.0, A0d, g_y_dynamic, 1.0, g_y_static);
blas::gemm("N", "N", 1.0, g_y_fwrd, g_y_back, 0.0, g_y_static_tmp);
blas::gemm("N", "N", 1.0, MatrixView(A, 0, n_back_mixed + n, n_static, n_fwrd_mixed),
g_y_static_tmp, 1.0, g_y_static);
for (size_t i = 0; i < n_static; i++)
mat::col_copy(A, n_back_mixed + zeta_static[i], 0, n_static, A0s, i, 0);
LU3.invMult("N", A0s, g_y_static);
mat::negate(g_y_static);
for (size_t i = 0; i < n_static; i++)
mat::row_copy(g_y_static, i, g_y, zeta_static[i]);
}
// 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);
g_u_tmp2 = MatrixConstView(jacobian, 0, n_back_mixed, n, n);
for (size_t i = 0; i < n_back_mixed; i++)
{
VectorView c1 = mat::get_col(g_u_tmp2, zeta_back_mixed[i]),
c2 = mat::get_col(g_u_tmp1, i);
vec::add(c1, c2);
}
g_u = MatrixConstView(jacobian, 0, n_back_mixed + n + n_fwrd_mixed, n, p);
LU4.invMult("N", g_u_tmp2, g_u);
mat::negate(g_u);
}
std::ostream &
operator<<(std::ostream &out, const DecisionRules::BlanchardKahnException &e)
{
if (e.order)
out << "The Blanchard-Kahn order condition is not satisfied: you have " << e.n_fwrd_vars << " forward variables for " << e.n_explosive_eigenvals << " explosive eigenvalues";
else
out << "The Blanchard Kahn rank condition is not satisfied";
return out;
}
/*
* Copyright (C) 2010-2017 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
#include <vector>
#include "Vector.hh"
#include "Matrix.hh"
#include "QRDecomposition.hh"
#include "GeneralizedSchurDecomposition.hh"
#include "LUSolver.hh"
class DecisionRules
{
private:
const size_t n, p;
const std::vector<size_t> zeta_fwrd, zeta_back, zeta_mixed, zeta_static;
const size_t n_fwrd, n_back, n_mixed, n_static, n_back_mixed, n_fwrd_mixed, n_dynamic;
std::vector<size_t> zeta_fwrd_mixed, zeta_back_mixed, zeta_dynamic,
beta_back, beta_fwrd, pi_back, pi_fwrd;
Matrix S, A, D, E, Z_prime;
QRDecomposition QR;
GeneralizedSchurDecomposition GSD;
LUSolver LU1, LU2, LU3;
Matrix Z21, g_y_back, g_y_back_tmp;
Matrix g_y_static, A0s, A0d, g_y_dynamic, g_y_static_tmp;
Matrix g_u_tmp1, g_u_tmp2;
LUSolver LU4;
public:
class BlanchardKahnException
{
public:
//! True if the model fails the order condition. False if it fails the rank condition.
const bool order;
const int n_fwrd_vars, n_explosive_eigenvals;
BlanchardKahnException(bool order_arg, int n_fwrd_vars_arg, int n_explosive_eigenvals_arg) : order(order_arg), n_fwrd_vars(n_fwrd_vars_arg), n_explosive_eigenvals(n_explosive_eigenvals_arg)
{
};
};
/*!
The zetas are supposed to follow C convention (first vector index is zero).
*/
DecisionRules(size_t n_arg, size_t p_arg, const std::vector<size_t> &zeta_fwrd_arg,
const std::vector<size_t> &zeta_back_arg, const std::vector<size_t> &zeta_mixed_arg,
const std::vector<size_t> &zeta_static_arg, double qz_criterium);
virtual ~DecisionRules()
{
};
/*!
\param jacobian First columns are backetermined vars at t-1 (in the order of zeta_back_mixed), then all vars at t (in the orig order), then forward vars at t+1 (in the order of zeta_fwrd_mixed), then exogenous vars.
*/
void compute(const Matrix &jacobian, Matrix &g_y, Matrix &g_u) throw (BlanchardKahnException, GeneralizedSchurDecomposition::GSDException);
template<class Vec1, class Vec2>
void getGeneralizedEigenvalues(Vec1 &eig_real, Vec2 &eig_cmplx);
};
std::ostream &operator<<(std::ostream &out, const DecisionRules::BlanchardKahnException &e);
template<class Vec1, class Vec2>
void
DecisionRules::getGeneralizedEigenvalues(Vec1 &eig_real, Vec2 &eig_cmplx)
{
GSD.getGeneralizedEigenvalues(eig_real, eig_cmplx);
}
/*
* Copyright (C) 2009-2017 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
///////////////////////////////////////////////////////////
// DetrendData.cpp
// Implementation of the Class DetrendData
// Created on: 02-Feb-2010 13:01:15
///////////////////////////////////////////////////////////
#include "DetrendData.hh"
DetrendData::DetrendData(const std::vector<size_t> &varobs_arg,
bool noconstant_arg)
: varobs(varobs_arg), noconstant(noconstant_arg)
{
};
void
DetrendData::detrend(const VectorView &SteadyState, const MatrixConstView &dataView,
MatrixView &detrendedDataView)
{
if (noconstant)
detrendedDataView = dataView;
else
{
for (size_t i = 0; i < varobs.size(); i++)
for (size_t j = 0; j < dataView.getCols(); j++)
detrendedDataView(i, j) = dataView(i, j) - SteadyState(varobs[i]);
}
};
/*
* Copyright (C) 2009-2017 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
///////////////////////////////////////////////////////////
// DetrendData.h
// Implementation of the Class DetrendData
// Created on: 02-Feb-2010 13:01:15
///////////////////////////////////////////////////////////
#if !defined(DetrendData_312823A1_6248_4af0_B204_DB22F1237E9B__INCLUDED_)
#define DetrendData_312823A1_6248_4af0_B204_DB22F1237E9B__INCLUDED_
#include "Matrix.hh"
class DetrendData
{
public:
virtual ~DetrendData()