Skip to content

Commit d06bc44

Browse files
committed
updated help info and tweaked data types of some variables
1 parent 02ab737 commit d06bc44

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/boot.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,8 @@
4444
// corresponding index is represented in bootsam. Therefore, the sum of WEIGHTS
4545
// should equal N * NBOOT.
4646
//
47-
// Note that the mex function compiled from this source code is not thread-safe.
48-
// Below is an example of a line of code one can run in Octave/Matlab before
49-
// attempting parallel operation of boot.mex in order to ensure that the initial
50-
// random seeds of each thread are unique:
51-
//
52-
// In Octave:
53-
// >> pararrayfun(nproc, @boot, 1, 1, false, 1:nproc)
54-
//
55-
// In Matlab:
56-
// >> ncpus = feature('numcores'); parfor i = 1:ncpus; boot (1, 1, false, i); end;
47+
// Compared to previous versions (in package versions <=5.6.0), the boot.mex
48+
// function is now thread safe.
5749
//
5850
// Requirements: Compilation requires C++11
5951
//
@@ -78,7 +70,7 @@ void mexFunction (int nlhs, mxArray* plhs[],
7870
}
7971
// First input argument (n or x)
8072
double *x = (double *) mxGetData (prhs[0]);
81-
int n = mxGetNumberOfElements (prhs[0]); // 32-bit int
73+
long unsigned int n = mxGetNumberOfElements (prhs[0]);
8274
bool isvec;
8375
if ( n > 1 ) {
8476
const mwSize *sz = mxGetDimensions (prhs[0]);
@@ -91,19 +83,19 @@ void mexFunction (int nlhs, mxArray* plhs[],
9183
if ( mxIsComplex (prhs[0]) ) {
9284
mexErrMsgTxt ("The first input argument (N) cannot contain an imaginary part.");
9385
}
94-
if ( *x != static_cast<int>(*x) ) {
86+
if ( *x != static_cast<long unsigned int>(*x) ) {
9587
mexErrMsgTxt ("The value of the first input argument (N) must be a positive integer.");
9688
}
9789
if ( !mxIsFinite (*x) ) {
9890
mexErrMsgTxt ("The first input argument (N) cannot be NaN or Inf.");
9991
}
100-
n = static_cast<int>(*x);
92+
n = static_cast<long unsigned int>(*x);
10193
}
10294
if ( !mxIsClass (prhs[0], "double") ) {
10395
mexErrMsgTxt ("The first input argument (N or X) must be of type double.");
10496
}
10597
// Second input argument (nboot)
106-
const int nboot = static_cast<const int> ( *(mxGetPr (prhs[1])) ); // 32-bit int
98+
const long unsigned int nboot = static_cast<const long unsigned int> ( *(mxGetPr (prhs[1])) );
10799
if ( mxGetNumberOfElements (prhs[1]) > 1 ) {
108100
mexErrMsgTxt ("The second input argument (NBOOT) must be scalar.");
109101
}
@@ -138,7 +130,7 @@ void mexFunction (int nlhs, mxArray* plhs[],
138130
if ( !mxIsClass (prhs[3], "double") ) {
139131
mexErrMsgTxt ("The fourth input argument (SEED) must be of type double.");
140132
}
141-
seed = static_cast<unsigned long int> ( *(mxGetPr(prhs[3])) );
133+
seed = static_cast<unsigned int> ( *(mxGetPr(prhs[3])) );
142134
if ( !mxIsFinite (seed) ) {
143135
mexErrMsgTxt ("The fourth input argument (SEED) cannot be NaN or Inf.");
144136
}
@@ -161,7 +153,7 @@ void mexFunction (int nlhs, mxArray* plhs[],
161153
mxREAL); // Prepare array for sample indices
162154
long long unsigned int N = n * nboot; // Total counts of all sample indices
163155
long long unsigned int k; // Variable to store random number
164-
long long unsigned int d; // Counter for cumulative sum calculation
156+
long long int d; // Counter for cumulative sum calculation
165157
vector<long long int> c(n, nboot); // Counter for each of the sample indices
166158
if ( nrhs > 4 && !mxIsEmpty (prhs[4]) ) {
167159
// Assign user defined weights (counts)

0 commit comments

Comments
 (0)