Skip to content
Snippets Groups Projects
Commit dfbf1989 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

K-order DLL: add test for NaN/Inf in param/steady-state vectors to avoid...

K-order DLL: add test for NaN/Inf in param/steady-state vectors to avoid crashes (thanks to J. Pfeifer for reporting this)
(cherry picked from commit 0f9ec8b2)
parent 006501aa
No related branches found
Tags
No related merge requests found
...@@ -106,16 +106,22 @@ extern "C" { ...@@ -106,16 +106,22 @@ extern "C" {
double *dparams = (double *) mxGetData(mxFldp); double *dparams = (double *) mxGetData(mxFldp);
int npar = (int) mxGetM(mxFldp); int npar = (int) mxGetM(mxFldp);
Vector modParams(dparams, npar); Vector modParams(dparams, npar);
if (!modParams.isFinite())
DYN_MEX_FUNC_ERR_MSG_TXT("The parameters vector contains NaN or Inf");
mxFldp = mxGetField(M_, 0, "Sigma_e"); mxFldp = mxGetField(M_, 0, "Sigma_e");
dparams = (double *) mxGetData(mxFldp); dparams = (double *) mxGetData(mxFldp);
npar = (int) mxGetN(mxFldp); npar = (int) mxGetN(mxFldp);
TwoDMatrix vCov(npar, npar, dparams); TwoDMatrix vCov(npar, npar, dparams);
if (!vCov.isFinite())
DYN_MEX_FUNC_ERR_MSG_TXT("The covariance matrix of shocks contains NaN or Inf");
mxFldp = mxGetField(dr, 0, "ys"); // and not in order of dr.order_var mxFldp = mxGetField(dr, 0, "ys"); // and not in order of dr.order_var
dparams = (double *) mxGetData(mxFldp); dparams = (double *) mxGetData(mxFldp);
const int nSteady = (int) mxGetM(mxFldp); const int nSteady = (int) mxGetM(mxFldp);
Vector ySteady(dparams, nSteady); Vector ySteady(dparams, nSteady);
if (!ySteady.isFinite())
DYN_MEX_FUNC_ERR_MSG_TXT("The steady state vector contains NaN or Inf");
mxFldp = mxGetField(dr, 0, "nstatic"); mxFldp = mxGetField(dr, 0, "nstatic");
const int nStat = (int) mxGetScalar(mxFldp); const int nStat = (int) mxGetScalar(mxFldp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment