Commit 3f2e29f7 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Adapt block_kalman_filter to Dynare's way of handling errors in MEX files

parent b21a99d9
......@@ -465,7 +465,8 @@ singularity_flag = 0;
if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
if no_missing_data_flag
if options_.block == 1
LIK = block_kalman_filter(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol, M_.nz_state_var, M_.n_diag);
[err, LIK] = block_kalman_filter(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol, M_.nz_state_var, M_.n_diag);
mexErrCheck('block_kalman_filter', err);
else
LIK = kalman_filter(Y,diffuse_periods+1,size(Y,2), ...
a,Pstar, ...
......
......@@ -213,8 +213,8 @@ det(double* F, int dim)
void
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
if (nlhs > 2)
DYN_MEX_FUNC_ERR_MSG_TXT("kalman_filter provides at most 2 output argument.");
if (nlhs > 3)
DYN_MEX_FUNC_ERR_MSG_TXT("kalman_filter provides at most 3 output argument.");
if (nrhs != 12)
DYN_MEX_FUNC_ERR_MSG_TXT("kalman_filter requires exactly 12 input arguments.");
//(T,R,Q,H,P,Y,start,mf,kalman_tol,riccati_tol, block)
......@@ -792,16 +792,19 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
t++;
}
}
if (nlhs >= 1)
// info = 0
plhs[0] = mxCreateDoubleScalar(0);
if (nlhs >= 2)
{
plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
double* pind = mxGetPr(plhs[0]);
plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
double* pind = mxGetPr(plhs[1]);
pind[0] = LIK;
}
if (nlhs == 2)
plhs[1] = plik;
if (nlhs == 3)
plhs[2] = plik;
mxFree(w);
#ifdef DIRECT
/*mxDestroyArray(nze);
......
Supports Markdown
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