File tree Expand file tree Collapse file tree 4 files changed +32
-4
lines changed
Expand file tree Collapse file tree 4 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1+ 2016-10-24 Qiang Kou <qkou@umail.iu.edu>
2+
3+ * inst/include/Rcpp/sugar/Range.h : fix range sugar ambiguity
4+ * inst/unitTests/cpp/sugar.cpp: range sugar unit test
5+ * inst/unitTests/runit.sugar.R: range sugar unit test
6+
172016-10-24 Nathan Russell <russell.nr2012@gmail.com>
28
39 * inst/include/Rcpp/vector/MatrixBase.h: Change sugar
Original file line number Diff line number Diff line change @@ -60,21 +60,21 @@ namespace Rcpp{
6060 return orig ;
6161 }
6262
63- Range& operator +=(R_xlen_t n ) {
63+ Range& operator +=( int n ) {
6464 start += n ; end_ += n ;
6565 return *this ;
6666 }
6767
68- Range& operator -=(R_xlen_t n ) {
68+ Range& operator -=( int n ) {
6969 start -= n ; end_ -= n ;
7070 return *this ;
7171 }
7272
73- Range operator +( R_xlen_t n ){
73+ Range operator +( int n ){
7474 return Range ( start + n, end_ + n ) ;
7575 }
7676
77- Range operator -( R_xlen_t n ){
77+ Range operator -( int n ){
7878 return Range ( start - n, end_ - n ) ;
7979 }
8080
Original file line number Diff line number Diff line change @@ -303,6 +303,18 @@ NumericVector runit_Range(){
303303 return xx ;
304304}
305305
306+ // [[Rcpp::export]]
307+ IntegerVector runit_range_plus (int start, int end, int n) {
308+ IntegerVector vec = Range (start, end) + n;
309+ return vec;
310+ }
311+
312+ // [[Rcpp::export]]
313+ IntegerVector runit_range_minus (int start, int end, int n) {
314+ IntegerVector vec = Range (start, end) - n;
315+ return vec;
316+ }
317+
306318// [[Rcpp::export]]
307319NumericVector runit_sapply ( NumericVector xx ){
308320 NumericVector res = sapply ( xx, square<double >() );
Original file line number Diff line number Diff line change @@ -360,6 +360,16 @@ if (.runThisTest) {
360360 checkEquals(fx(), c( exp(seq_len(4 )), exp(- seq_len(4 ))))
361361 }
362362
363+ test.sugar.Range.plus <- function ( ){
364+ fx <- runit_range_plus
365+ checkEquals( fx(1 , 10 , 2 ), c(1 : 10 ) + 2 )
366+ }
367+
368+ test.sugar.Range.minus <- function ( ){
369+ fx <- runit_range_minus
370+ checkEquals( fx(1 , 10 , 2 ), c(1 : 10 ) - 2 )
371+ }
372+
363373 test.sugar.sapply <- function ( ){
364374 fx <- runit_sapply
365375 checkEquals( fx(1 : 10 ) , (1 : 10 )^ 2 )
You can’t perform that action at this time.
0 commit comments