@@ -70,7 +70,7 @@ void mexFunction (int nlhs, mxArray* plhs[],
70
70
}
71
71
// First input argument (n or x)
72
72
double *x = (double *) mxGetData (prhs[0 ]);
73
- long unsigned int n = mxGetNumberOfElements (prhs[0 ]);
73
+ size_t n = mxGetNumberOfElements (prhs[0 ]);
74
74
bool isvec;
75
75
if ( n > 1 ) {
76
76
const mwSize *sz = mxGetDimensions (prhs[0 ]);
@@ -83,19 +83,19 @@ void mexFunction (int nlhs, mxArray* plhs[],
83
83
if ( mxIsComplex (prhs[0 ]) ) {
84
84
mexErrMsgTxt (" The first input argument (N) cannot contain an imaginary part." );
85
85
}
86
- if ( *x != static_cast <long unsigned int >(*x) ) {
86
+ if ( *x != static_cast <size_t >(*x) ) {
87
87
mexErrMsgTxt (" The value of the first input argument (N) must be a positive integer." );
88
88
}
89
89
if ( !mxIsFinite (*x) ) {
90
90
mexErrMsgTxt (" The first input argument (N) cannot be NaN or Inf." );
91
91
}
92
- n = static_cast <long unsigned int >(*x);
92
+ n = static_cast <size_t >(*x);
93
93
}
94
94
if ( !mxIsClass (prhs[0 ], " double" ) ) {
95
95
mexErrMsgTxt (" The first input argument (N or X) must be of type double." );
96
96
}
97
97
// Second input argument (nboot)
98
- const long unsigned int nboot = static_cast <const long unsigned int > ( *(mxGetPr (prhs[1 ])) );
98
+ const size_t nboot = static_cast <size_t > ( *(mxGetPr (prhs[1 ])) );
99
99
if ( mxGetNumberOfElements (prhs[1 ]) > 1 ) {
100
100
mexErrMsgTxt (" The second input argument (NBOOT) must be scalar." );
101
101
}
@@ -151,8 +151,8 @@ void mexFunction (int nlhs, mxArray* plhs[],
151
151
plhs[0 ] = mxCreateNumericArray (2 , dims,
152
152
mxDOUBLE_CLASS,
153
153
mxREAL); // Prepare array for sample indices
154
- long long unsigned int N = n * nboot; // Total counts of all sample indices
155
- long long unsigned int k; // Variable to store random number
154
+ size_t N = n * nboot; // Total counts of all sample indices
155
+ size_t k; // Variable to store random number
156
156
long long int d; // Counter for cumulative sum calculation
157
157
vector<long long int > c (n, nboot); // Counter for each of the sample indices
158
158
if ( nrhs > 4 && !mxIsEmpty (prhs[4 ]) ) {
@@ -168,7 +168,7 @@ void mexFunction (int nlhs, mxArray* plhs[],
168
168
mexErrMsgTxt (" WEIGHTS must be a vector of length N or be the same length as X." );
169
169
}
170
170
long long int s = 0 ;
171
- for ( int i = 0 ; i < n ; i++ ) {
171
+ for ( size_t i = 0 ; i < n ; i++ ) {
172
172
if ( !mxIsFinite (w[i]) ) {
173
173
mexErrMsgTxt (" The fifth input argument (WEIGHTS) cannot contain NaN or Inf." );
174
174
}
@@ -183,18 +183,18 @@ void mexFunction (int nlhs, mxArray* plhs[],
183
183
}
184
184
}
185
185
long long int m = 0 ; // Counter for LOO sample index r
186
- int r = -1 ; // Sample index for LOO
186
+ long long int r = -1 ; // Sample index for LOO
187
187
188
188
// Create pointer so that we can access elements of bootsam (i.e. plhs[0])
189
189
double *ptr = (double *) mxGetData (plhs[0 ]);
190
190
191
191
// Initialize pseudo-random number generator (Mersenne Twister 19937)
192
192
mt19937_64 rng (seed);
193
- uniform_int_distribution<long long unsigned int > distr (0 , n - 1 );
194
- uniform_int_distribution<long long unsigned int > distk (0 , N - 1 );
193
+ uniform_int_distribution<size_t > distr (0 , n - 1 );
194
+ uniform_int_distribution<size_t > distk (0 , N - 1 );
195
195
196
196
// Perform balanced sampling
197
- for ( int b = 0 ; b < nboot ; b++ ) {
197
+ for ( size_t b = 0 ; b < nboot ; b++ ) {
198
198
if ( loo == true ) {
199
199
// Note that the following division operations are for integers
200
200
if ( (b / n) == (nboot / n) ) {
@@ -205,7 +205,7 @@ void mexFunction (int nlhs, mxArray* plhs[],
205
205
m = c[r];
206
206
c[r] = 0 ;
207
207
}
208
- for ( int i = 0 ; i < n ; i++ ) {
208
+ for ( size_t i = 0 ; i < n ; i++ ) {
209
209
if ( loo == true ) {
210
210
// Only leave-one-out if sample index r doesn't account for all
211
211
// remaining sampling counts
@@ -215,10 +215,10 @@ void mexFunction (int nlhs, mxArray* plhs[],
215
215
loo = false ;
216
216
}
217
217
}
218
- distk.param (uniform_int_distribution<long long unsigned int >::param_type (0 , N - m - 1 ));
218
+ distk.param (uniform_int_distribution<size_t >::param_type (0 , N - m - 1 ));
219
219
k = distk (rng);
220
220
d = c[0 ];
221
- for ( int j = 0 ; j < n ; j++ ) {
221
+ for ( size_t j = 0 ; j < n ; j++ ) {
222
222
if ( k < d ) {
223
223
if (isvec) {
224
224
ptr[b * n + i] = x[j];
0 commit comments