[Rcpp-commits] r3449 - in pkg/Rcpp/inst: include/Rcpp/sugar/functions unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 29 10:53:48 CET 2012


Author: romain
Date: 2012-01-29 10:53:47 +0100 (Sun, 29 Jan 2012)
New Revision: 3449

Modified:
   pkg/Rcpp/inst/include/Rcpp/sugar/functions/diff.h
   pkg/Rcpp/inst/unitTests/runit.sugar.R
Log:
regression test

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/diff.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/diff.h	2012-01-29 09:39:22 UTC (rev 3448)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/diff.h	2012-01-29 09:53:47 UTC (rev 3449)
@@ -83,8 +83,6 @@
 	mutable double previous ;
 } ;
 
-
-
 template <int RTYPE, typename LHS_T>
 class Diff<RTYPE,false,LHS_T> : public Rcpp::VectorBase< RTYPE, false , Diff<RTYPE,false,LHS_T> > {
 public:

Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.sugar.R	2012-01-29 09:39:22 UTC (rev 3448)
+++ pkg/Rcpp/inst/unitTests/runit.sugar.R	2012-01-29 09:53:47 UTC (rev 3449)
@@ -668,6 +668,14 @@
 			        as_vector( outer( NumericVector(x) , NumericVector(y) , std::plus<double>() ) )
 			    ) ;
 			    '
+			), 
+			"runit_diff_REALSXP_NA" = list(
+			    signature( x_= "numeric" ), 
+			    '
+			         NumericVector x(x_) ;
+			         NumericVector res= diff(x) ;
+			         return res ;
+			    '
 			)
 		)
 
@@ -1312,4 +1320,10 @@
     checkEquals( res[[1]], as.vector( diag(1:5) ) )
     checkEquals( res[[2]], as.vector( outer( 1:4, 1:5, "+" ) ) )
 }
+       
+test.sugar.asvector <- function(){
+    fx <- .rcpp.sugar$runit_diff_REALSXP_NA
+    x <- c( NA, 1.5, 2.5, NA, 3.5, 5.5, NA )
+    checkEquals( fx(x), c(NA, 1.0, NA, NA, 2.0, NA) )
+}
 



More information about the Rcpp-commits mailing list