diff --git a/mex/sources/estimation/InitializeKalmanFilter.cc b/mex/sources/estimation/InitializeKalmanFilter.cc index 57373820a..1b071965e 100644 --- a/mex/sources/estimation/InitializeKalmanFilter.cc +++ b/mex/sources/estimation/InitializeKalmanFilter.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2012 Dynare Team + * Copyright (C) 2010-2013 Dynare Team * * This file is part of Dynare. * @@ -63,16 +63,6 @@ InitializeKalmanFilter::setT(Matrix &T, int &info) mat::assignByVectors(T, mat::nullVec, pi_bm_vbm, g_x, zeta_varobs_back_mixed, mat::nullVec); } -void -InitializeKalmanFilter::setRQR(Matrix &R, const MatrixView &Q, Matrix &RQRt, int &info) -{ - mat::assignByVectors(R, mat::nullVec, mat::nullVec, g_u, zeta_varobs_back_mixed, mat::nullVec); - - // Matrix RQRt=R*Q*R' - blas::gemm("N", "N", 1.0, R, Q, 0.0, RQ); // R*Q - blas::gemm("N", "T", 1.0, RQ, R, 0.0, RQRt); // R*Q*R' -} - void InitializeKalmanFilter::setPstar(Matrix &Pstar, Matrix &Pinf, const Matrix &T, const Matrix &RQRt, int &info) { diff --git a/mex/sources/estimation/InitializeKalmanFilter.hh b/mex/sources/estimation/InitializeKalmanFilter.hh index 25c6f6eb2..4ddced4de 100644 --- a/mex/sources/estimation/InitializeKalmanFilter.hh +++ b/mex/sources/estimation/InitializeKalmanFilter.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2012 Dynare Team + * Copyright (C) 2010-2013 Dynare Team * * This file is part of Dynare. * @@ -49,9 +49,9 @@ public: double qz_criterium_arg, double lyapunov_tol_arg, int &info); virtual ~InitializeKalmanFilter(); // initialise parameter dependent KF matrices only but not Ps - template - void initialize(VEC &steadyState, const VectorView &deepParams, Matrix &R, - const MatrixView &Q, Matrix &RQRt, Matrix &T, + template + void initialize(Vec1 &steadyState, const Vec2 &deepParams, Mat1 &R, + const Mat2 &Q, Matrix &RQRt, Matrix &T, double &penalty, const MatrixConstView &dataView, MatrixView &detrendedDataView, int &info) { @@ -63,9 +63,9 @@ public: } // initialise all KF matrices - template - void initialize(VEC &steadyState, const VectorView &deepParams, Matrix &R, - const MatrixView &Q, Matrix &RQRt, Matrix &T, Matrix &Pstar, Matrix &Pinf, + template + void initialize(Vec1 &steadyState, const Vec2 &deepParams, Mat1 &R, + const Mat2 &Q, Matrix &RQRt, Matrix &T, Matrix &Pstar, Matrix &Pinf, double &penalty, const MatrixConstView &dataView, MatrixView &detrendedDataView, int &info) { @@ -86,7 +86,16 @@ private: Matrix g_u; Matrix Rt, RQ; void setT(Matrix &T, int &info); - void setRQR(Matrix &R, const MatrixView &Q, Matrix &RQRt, int &info); + + template + void setRQR(Mat1 &R, const Mat2 &Q, Matrix &RQRt, int &info) + { + mat::assignByVectors(R, mat::nullVec, mat::nullVec, g_u, zeta_varobs_back_mixed, mat::nullVec); + + // Matrix RQRt=R*Q*R' + blas::gemm("N", "N", 1.0, R, Q, 0.0, RQ); // R*Q + blas::gemm("N", "T", 1.0, RQ, R, 0.0, RQRt); // R*Q*R' + } void setPstar(Matrix &Pstar, Matrix &Pinf, const Matrix &T, const Matrix &RQRt, int &info); }; diff --git a/mex/sources/estimation/KalmanFilter.hh b/mex/sources/estimation/KalmanFilter.hh index 6a688e2f1..be3c2e868 100644 --- a/mex/sources/estimation/KalmanFilter.hh +++ b/mex/sources/estimation/KalmanFilter.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Dynare Team + * Copyright (C) 2009-2013 Dynare Team * * This file is part of Dynare. * @@ -54,9 +54,9 @@ public: double qz_criterium_arg, const std::vector &varobs_arg, double riccati_tol_arg, double lyapunov_tol_arg, int &info); - template - double compute(const MatrixConstView &dataView, VEC &steadyState, - const MatrixView &Q, const Matrix &H, const VectorView &deepParams, + template + double compute(const MatrixConstView &dataView, Vec1 &steadyState, + const Mat1 &Q, const Matrix &H, const Vec2 &deepParams, VectorView &vll, MatrixView &detrendedDataView, size_t start, size_t period, double &penalty, int &info) { diff --git a/mex/sources/estimation/ModelSolution.hh b/mex/sources/estimation/ModelSolution.hh index 3e690ffa6..19088f883 100644 --- a/mex/sources/estimation/ModelSolution.hh +++ b/mex/sources/estimation/ModelSolution.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2012 Dynare Team + * Copyright (C) 2010-2013 Dynare Team * * This file is part of Dynare. * @@ -42,8 +42,8 @@ public: const std::vector &zeta_back_arg, const std::vector &zeta_mixed_arg, const std::vector &zeta_static_arg, double qz_criterium); virtual ~ModelSolution() {}; - template - void compute(VEC &steadyState, const VectorView &deepParams, Matrix &ghx, Matrix &ghu) throw (DecisionRules::BlanchardKahnException, GeneralizedSchurDecomposition::GSDException) + template + void compute(Vec1 &steadyState, const Vec2 &deepParams, Mat1 &ghx, Mat2 &ghu) throw (DecisionRules::BlanchardKahnException, GeneralizedSchurDecomposition::GSDException) { // compute Steady State ComputeSteadyState(steadyState, deepParams); @@ -66,9 +66,9 @@ private: DynamicModelDLL dynamicDLLp; Vector llXsteadyState; //Matrix jacobian; - template - void ComputeModelSolution(VEC &steadyState, const VectorView &deepParams, - Matrix &ghx, Matrix &ghu) + template + void ComputeModelSolution(Vec1 &steadyState, const Vec2 &deepParams, + Mat1 &ghx, Mat2 &ghu) throw (DecisionRules::BlanchardKahnException, GeneralizedSchurDecomposition::GSDException) { // set extended Steady State @@ -88,8 +88,8 @@ private: //compute rules decisionRules.compute(jacobian, ghx, ghu); } - template - void ComputeSteadyState(VEC &steadyState, const VectorView &deepParams) + template + void ComputeSteadyState(Vec1 &steadyState, const Vec2 &deepParams) { // does nothig for time being. } diff --git a/mex/sources/estimation/utils/dynamic_dll.hh b/mex/sources/estimation/utils/dynamic_dll.hh index 2ea77ef3a..d4ab4b7d4 100644 --- a/mex/sources/estimation/utils/dynamic_dll.hh +++ b/mex/sources/estimation/utils/dynamic_dll.hh @@ -57,9 +57,9 @@ public: virtual ~DynamicModelDLL(); //! evaluate Dynamic model DLL - template - void eval(const Vector &y, const Matrix &x, const VectorView &modParams, VEC &ySteady, - Vector &residual, Matrix *g1, Matrix *g2, Matrix *g3) throw (TSException) + template + void eval(const Vec1 &y, const Mat1 &x, const Vec2 &modParams, const Vec3 &ySteady, + Vec4 &residual, Matrix *g1, Matrix *g2, Matrix *g3) throw (TSException) { assert(y.getStride() == 1); assert(x.getLd() == x.getRows());