sobol qmc_sequence MEX: dimension larger than 1111 returns a proper

Matlab error message instead of crashing
time-shift
Michel Juillard 2014-02-15 21:02:33 +01:00
parent b3bcf37cca
commit 45f7de33e8
1 changed files with 11 additions and 0 deletions

View File

@ -21,6 +21,7 @@
** AUTHOR(S): stephane DOT adjemian AT univ DASH lemans DOT fr
**/
#include <sstream>
#include <string.h>
#include <stdint.h>
#include <dynmex.h>
@ -28,6 +29,9 @@
#include "sobol.hh"
#include "gaussian.hh"
// the maximum dimension defined in sobol.ff (but undef at the end)
#define DIM_MAX 1111
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
/*
@ -100,6 +104,13 @@ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
DYN_MEX_FUNC_ERR_MSG_TXT("qmc_sequence:: First input (dimension) has to be greater than 1 for a uniform QMC on an hypershere!");
}
else if (dimension > DIM_MAX)
{
stringstream msg;
msg << "qmc_sequence:: First input (dimension) has to be smaller than " << DIM_MAX << " !";
DYN_MEX_FUNC_ERR_MSG_TXT(msg.str().c_str());
}
/*
** Test the optional fourth input argument and assign it to sequence_size.
*/