File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -278,26 +278,26 @@ class Vector :
278
278
/* *
279
279
* offset based on the dimensions of this vector
280
280
*/
281
- size_t offset (const size_t & i, const size_t & j) const {
281
+ R_xlen_t offset (const int & i, const int & j) const {
282
282
if ( !::Rf_isMatrix (Storage::get__ ()) ) throw not_a_matrix () ;
283
283
284
284
/* we need to extract the dimensions */
285
- int * dim = dims () ;
286
- size_t nrow = static_cast < size_t >( dim[0 ]) ;
287
- size_t ncol = static_cast < size_t >( dim[1 ]) ;
288
- if ( i >= nrow || j >= ncol ) throw index_out_of_bounds () ;
289
- return i + nrow*j ;
285
+ const int * dim = dims () ;
286
+ const int nrow = dim[0 ] ;
287
+ const int ncol = dim[1 ] ;
288
+ if (i < 0 || i >= nrow || j < 0 || j >= ncol ) throw index_out_of_bounds () ;
289
+ return i + static_cast <R_xlen_t>( nrow) *j ;
290
290
}
291
291
292
292
/* *
293
293
* one dimensional offset doing bounds checking to ensure
294
294
* it is valid
295
295
*/
296
- size_t offset (const size_t & i) const {
297
- if ( static_cast <R_xlen_t>(i) >= ::Rf_xlength (Storage::get__ ()) ) throw index_out_of_bounds () ;
296
+ R_xlen_t offset (const R_xlen_t & i) const {
297
+ if (i < 0 || i >= ::Rf_xlength (Storage::get__ ()) ) throw index_out_of_bounds () ;
298
298
return i ;
299
299
}
300
-
300
+
301
301
R_xlen_t offset (const std::string& name) const {
302
302
SEXP names = RCPP_GET_NAMES ( Storage::get__ () ) ;
303
303
if ( Rf_isNull (names) ) throw index_out_of_bounds ();
You can’t perform that action at this time.
0 commit comments