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

:bug: qmc_sequence MEX: large input seeds would be truncated

The int64 input seed was converted to a double before being converted back to
an int64. But large integers cannot be represented exactly in a double.
parent 9dff1ff2
Branches
No related tags found
No related merge requests found
/* /*
** Computes Quasi Monte-Carlo sequence. ** Computes Quasi Monte-Carlo sequence.
** **
** Copyright © 2010-2022 Dynare Team ** Copyright © 2010-2023 Dynare Team
** **
** This file is part of Dynare (can be used outside Dynare). ** This file is part of Dynare (can be used outside Dynare).
** **
...@@ -73,7 +73,12 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -73,7 +73,12 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (!(mxIsNumeric(prhs[1]) && mxIsClass(prhs[1], "int64"))) if (!(mxIsNumeric(prhs[1]) && mxIsClass(prhs[1], "int64")))
mexErrMsgTxt("qmc_sequence:: Second input (seed) has to be an integer [int64]!"); mexErrMsgTxt("qmc_sequence:: Second input (seed) has to be an integer [int64]!");
int64_T seed = static_cast<int64_T>(mxGetScalar(prhs[1])); #if MX_HAS_INTERLEAVED_COMPLEX
int64_T seed = *mxGetInt64s(prhs[1]);
#else
int64_T seed = *static_cast<int64_T *>(mxGetData(prhs[1]));
#endif
/* /*
** Test the third input argument and assign it to type (kind of QMC sequence). ** Test the third input argument and assign it to type (kind of QMC sequence).
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment