[Rcpp-commits] r2413 - in pkg/Rcpp: . inst/include/Rcpp/sugar/operators inst/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 7 10:22:25 CET 2010
Author: romain
Date: 2010-11-07 10:22:24 +0100 (Sun, 07 Nov 2010)
New Revision: 2413
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h
pkg/Rcpp/inst/unitTests/runit.sugar.R
Log:
Minus_Vector_Primitive<RTYPE,false,T> was wrong
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2010-11-06 22:02:50 UTC (rev 2412)
+++ pkg/Rcpp/ChangeLog 2010-11-07 09:22:24 UTC (rev 2413)
@@ -1,3 +1,9 @@
+2010-11-07 Romain Francois <romain at r-enthusiasts.com>
+
+ * inst/include/Rcpp/sugar/operators/minus.h: fixed Minus_Vector_Primitive<RTYPE,false,T>
+
+ * inst/unitTests/runit.sugar.R: new test for the above
+
2010-11-05 Romain Francois <romain at r-enthusiasts.com>
* inst/include/Rcpp/Module.h: exposing multiple constructors in modules
Modified: pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h 2010-11-06 22:02:50 UTC (rev 2412)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/operators/minus.h 2010-11-07 09:22:24 UTC (rev 2413)
@@ -159,8 +159,8 @@
inline STORAGE operator[]( int i ) const {
if( rhs_na ) return rhs ;
- STORAGE x = rhs[i] ;
- return Rcpp::traits::is_na<RTYPE>(x) ? x : (lhs - x) ;
+ STORAGE x = lhs[i] ;
+ return Rcpp::traits::is_na<RTYPE>(x) ? x : (x - rhs) ;
}
inline int size() const { return lhs.size() ; }
Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.sugar.R 2010-11-06 22:02:50 UTC (rev 2412)
+++ pkg/Rcpp/inst/unitTests/runit.sugar.R 2010-11-07 09:22:24 UTC (rev 2413)
@@ -280,7 +280,9 @@
return List::create(
xx - 10,
10 - xx,
- xx - xx
+ xx - xx,
+ noNA( xx ) - 10,
+ 10 - noNA( xx )
) ;
'
),
@@ -946,7 +948,10 @@
test.sugar.minus <- function( ){
fx <- .rcpp.sugar$runit_minus
- checkEquals( fx(1:10) , list( (1:10)-10L, 10L-(1:10), rep(0L,10) ) )
+ checkEquals(
+ fx(1:10) ,
+ list( (1:10)-10L, 10L-(1:10), rep(0L,10), (1:10)-10L, 10L-(1:10) )
+ )
}
test.sugar.any.equal.not <- function( ){
More information about the Rcpp-commits
mailing list