Skip to content
Snippets Groups Projects
Verified Commit 5cb6c91c 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.

(manually cherry picked from commit 85351d75)
parent c72acdac
No related branches found
No related tags found
No related merge requests found
Pipeline #8361 passed
/* /*
** Computes Quasi Monte-Carlo sequence. ** Computes Quasi Monte-Carlo sequence.
** **
** Copyright © 2010-2020 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).
** **
...@@ -70,7 +70,12 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -70,7 +70,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