K-order DLL: add test for NaN/Inf in param/steady-state vectors to avoid crashes (thanks to J. Pfeifer for reporting this)

time-shift
Sébastien Villemot 2011-02-07 11:12:32 +01:00
parent a6fe91a89a
commit 0f9ec8b2dc
1 changed files with 6 additions and 0 deletions

View File

@ -106,16 +106,22 @@ extern "C" {
double *dparams = (double *) mxGetData(mxFldp);
int npar = (int) mxGetM(mxFldp);
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");
dparams = (double *) mxGetData(mxFldp);
npar = (int) mxGetN(mxFldp);
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
dparams = (double *) mxGetData(mxFldp);
const int nSteady = (int) mxGetM(mxFldp);
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");
const int nStat = (int) mxGetScalar(mxFldp);