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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 29 16:33:41 CET 2012


Author: edd
Date: 2012-01-29 16:33:40 +0100 (Sun, 29 Jan 2012)
New Revision: 3452

Modified:
   pkg/Rcpp/inst/include/Rcpp/sugar/functions/diff.h
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
   pkg/Rcpp/inst/unitTests/runit.Vector.R
   pkg/Rcpp/inst/unitTests/runit.sugar.R
Log:
update copyright on files touched in 2012 to 2012


Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/diff.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/diff.h	2012-01-29 15:24:20 UTC (rev 3451)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/diff.h	2012-01-29 15:33:40 UTC (rev 3452)
@@ -2,7 +2,7 @@
 //
 // diff.h: Rcpp R/C++ interface class library -- diff
 //
-// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of Rcpp.
 //

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-01-29 15:24:20 UTC (rev 3451)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-01-29 15:33:40 UTC (rev 3452)
@@ -2,7 +2,7 @@
 //
 // Vector.h: Rcpp R/C++ interface class library -- vectors
 //
-// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of Rcpp.
 //

Modified: pkg/Rcpp/inst/unitTests/runit.Vector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Vector.R	2012-01-29 15:24:20 UTC (rev 3451)
+++ pkg/Rcpp/inst/unitTests/runit.Vector.R	2012-01-29 15:33:40 UTC (rev 3452)
@@ -1,6 +1,6 @@
 #!/usr/bin/r -t
 #
-# Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+# Copyright (C) 2010 - 2012  Dirk Eddelbuettel and Romain Francois
 #
 # This file is part of Rcpp.
 #
@@ -19,72 +19,72 @@
 
 definitions <- function(){
     f <- list(
-        	"raw_" = list( 
-        		signature(), 
+        	"raw_" = list(
+        		signature(),
         		'
 				RawVector x(10) ;
 				for( int i=0; i<10; i++) x[i] = (Rbyte)i ;
 				return x ;
 				'
-        	), 
-        	"raw_REALSXP" = list( 
+        	),
+        	"raw_REALSXP" = list(
         		signature(vec = "raw" ),
         		'
 				RawVector x(vec) ;
-				for( int i=0; i<x.size(); i++) { 
+				for( int i=0; i<x.size(); i++) {
 					x[i] = x[i]*2 ;
 				}
 				return x ;
 				'
-        	), 
-        	"expression_" = list( 
-        		signature(), 
+        	),
+        	"expression_" = list(
+        		signature(),
         		'
 				ExpressionVector x(2) ;
 				x[0] = Symbol( "rnorm" ) ;
 				x[1] = Rf_lcons( Symbol("rnorm"), Rf_cons( Rf_ScalarReal(10.0), R_NilValue) ) ;
 				return x ;
 				'
-        	), 
-        	"expression_variadic" = list( 
-        		signature(), 
+        	),
+        	"expression_variadic" = list(
+        		signature(),
         		'
 				ExpressionVector x(2) ;
 				x[0] = Symbol( "rnorm" ) ;
 				x[1] = Language( "rnorm", 10.0 ) ;
 				return x ;
 				'
-        	), 
-        	"expression_parse" = list( 
-        		signature(), 
+        	),
+        	"expression_parse" = list(
+        		signature(),
         		'
 					ExpressionVector code( "local( { y <- sample(1:10); sort(y) })" ) ;
 					return code ;
 				'
-        	), 
-        	"expression_parseerror" = list( 
-        		signature(), 
+        	),
+        	"expression_parseerror" = list(
+        		signature(),
         		'
 					ExpressionVector code( "rnorm(" ) ;
 					return code ;
 				'
-        	), 
-        	"expression_eval" = list( 
-        		signature(), 
+        	),
+        	"expression_eval" = list(
+        		signature(),
         		'
 				ExpressionVector code( "local( { y <- sample(1:10); sort(y) })" ) ;
 				return code.eval() ;
 				'
-        	), 
-        	"expression_evalenv" = list( 
-        		signature(env = "environment"), 
+        	),
+        	"expression_evalenv" = list(
+        		signature(env = "environment"),
         		'
 				ExpressionVector code( "sort(x)" ) ;
 				return code.eval(env) ;
-				' 
-        	), 
-        	"complex_" = list( 
-        		signature(), 
+				'
+        	),
+        	"complex_" = list(
+        		signature(),
         		'
 				ComplexVector x(10) ;
 				Rcomplex rc ;
@@ -94,21 +94,21 @@
 				}
 				return x ;
 				'
-        	), 
-        	"complex_CPLXSXP" = list( 
-        		signature(vec = "complex" ), 
+        	),
+        	"complex_CPLXSXP" = list(
+        		signature(vec = "complex" ),
         		'
 				ComplexVector x(vec) ;
                 int nn = x.size();
-				for( int i=0; i<nn; i++) { 
+				for( int i=0; i<nn; i++) {
 					x[i].r = x[i].r*2 ;
 					x[i].i = x[i].i*2 ;
 				}
 				return x ;
 				'
-        	), 
-        	"complex_INTSXP" = list( 
-        		signature(vec = "integer" ), 
+        	),
+        	"complex_INTSXP" = list(
+        		signature(vec = "integer" ),
         		'
 				ComplexVector x(vec);
                 int nn = x.size();
@@ -117,9 +117,9 @@
                 x = x * tmp1;
 				return x ;
 				'
-        	), 
-        	"complex_REALSXP" = list( 
-        		signature(vec = "numeric" ), 
+        	),
+        	"complex_REALSXP" = list(
+        		signature(vec = "numeric" ),
         		'
 				ComplexVector x(vec);
                 int nn = x.size();
@@ -128,8 +128,8 @@
                 x = x * tmp1;
 				return x ;
 				'
-        	), 
-        	
+        	),
+
         	"integer_ctor"=list(
                   signature(),
                   'IntegerVector x(10) ;
@@ -238,20 +238,20 @@
                   ,"integer_create_zero"=list(
                    signature(),
                    'return IntegerVector::create();'
-                  ), 
-                  "integer_create_" = list( 
-                  signature(), 
+                  ),
+                  "integer_create_" = list(
+                  signature(),
                   '
-					List output(2); 
+					List output(2);
 					output[0] = IntegerVector::create( 10, 20 ) ;
-					output[1] = IntegerVector::create( 
-						_["foo"] = 20, 
+					output[1] = IntegerVector::create(
+						_["foo"] = 20,
 						_["bar"] = 30 ) ;
 					return output ;
-					' 
-                  ), 
-                  "integer_clone_" = list( 
-                  signature(x="integer"), 
+					'
+                  ),
+                  "integer_clone_" = list(
+                  signature(x="integer"),
                   '
 					IntegerVector vec(x) ;
 					IntegerVector dolly = clone( vec ) ;
@@ -260,53 +260,53 @@
 					}
 					return dolly ;
 					'
-                  ) , 
-                  
-                  
-                  
-           "numeric_" = list( 
+                  ) ,
+
+
+
+           "numeric_" = list(
         		signature(),
         		'
 				NumericVector x(10) ;
 				for( int i=0; i<10; i++) x[i] = i ;
 				return x ;
 				'
-        	), 
-        	"numeric_REALSXP" = list( 
-        		signature(vec = "numeric" ), 
+        	),
+        	"numeric_REALSXP" = list(
+        		signature(vec = "numeric" ),
         		'
 				NumericVector x(vec) ;
-				for( int i=0; i<x.size(); i++) { 
+				for( int i=0; i<x.size(); i++) {
 					x[i] = x[i]*2.0 ;
 				}
 				return x ;
-				'	
-        	), 
-        	"numeric_import" = list( 
-        		signature(), 
+				'
+        	),
+        	"numeric_import" = list(
+        		signature(),
         		'
 					std::vector<int> v(10) ;
 					for( int i=0; i<10; i++) v[i] = i ;
-					
+
 					return IntegerVector::import( v.begin(), v.end() ) ;
-				
+
 				'
-        	), 
-        	"numeric_importtransform" = list( 
-        		signature(), 
+        	),
+        	"numeric_importtransform" = list(
+        		signature(),
         		'
 					std::vector<double> v(10) ;
 					for( int i=0; i<10; i++) v[i] = i ;
-					
+
 					return NumericVector::import_transform( v.begin(), v.end(), square ) ;
-				
+
 				'
-        	)  , 
-        	
-        	
-        	
-        	
-        	
+        	)  ,
+
+
+
+
+
         	"list_ctor"=list(
                   signature(),
                   'List x(10) ;
@@ -405,29 +405,29 @@
                     list["foo"] = 10 ;
                     list["bar" ] = "foobar" ;
                     return list ;
-                   '), 
-              "list_create_" = list( 
-              	signature(), 
+                   '),
+              "list_create_" = list(
+              	signature(),
               	'
-					List output(2); 
+					List output(2);
 					output[0] = List::create( 10, "foo" ) ;
-					output[1] = List::create( 
-						_["foo"] = 10, 
+					output[1] = List::create(
+						_["foo"] = 10,
 						_["bar"] = true ) ;
 					return output ;
 				'
-              ), 
-              "list_stdcomplex" = list( 
+              ),
+              "list_stdcomplex" = list(
               		signature() , '
               			std::vector< std::complex<double> > v_double(10) ;
     					std::vector< std::complex<float> > v_float(10) ;
     					return List::create( _["float"] = v_float, _["double"] = v_double ) ;
     				'
-    			), 
-    			
-    			
-    			
-    			
+    			),
+
+
+
+
               "character_ctor"=list(
                   signature(),
                   'CharacterVector x(10) ;
@@ -565,76 +565,76 @@
                    'CharacterVector y(x) ;
 	            CharacterVector::iterator it = std::find( y.begin(), y.end(), "foo" ) ;
 	            return wrap( std::distance( y.begin(), it )); '
-	            
-	            ), "character_create_" = list( 
-	            	signature(), 
+
+	            ), "character_create_" = list(
+	            	signature(),
 	            	'
-						List output(2); 
+						List output(2);
 						output[0] = CharacterVector::create( "foo", "bar" ) ;
-						output[1] = CharacterVector::create( 
-							_["foo"] = "bar", 
+						output[1] = CharacterVector::create(
+							_["foo"] = "bar",
 							_["bar"] = "foo"
 							) ;
 						return output ;
 					'
-	            ), "complex_binary_sugar" = list( 
-	            	signature( x = "complex", y = "complex" ), 
+	            ), "complex_binary_sugar" = list(
+	            	signature( x = "complex", y = "complex" ),
 	            	'
 	            		ComplexVector xx(x), yy(y) ;
-	            		return List::create( 
-	            			_["+"] = xx + yy, 
-	            			_["-"] = xx - yy, 
-	            			_["*"] = xx * yy, 
+	            		return List::create(
+	            			_["+"] = xx + yy,
+	            			_["-"] = xx - yy,
+	            			_["*"] = xx * yy,
 	            			_["/"] = xx / yy
 	            		) ;
-	            	
+
 	            	'
-	            ), 
-	            "List_extract" = list( 
-	                signature( x = "list" ), 
+	            ),
+	            "List_extract" = list(
+	                signature( x = "list" ),
 	                '
 	                    List input(x) ;
 	                    bool a = input[0] ;
 	                    int b = input[1] ;
 	                    return List::create(a, b) ;
 	                '
-	            ), 
-	            "factors" = list( 
-	                signature( x = "factor" ), 
+	            ),
+	            "factors" = list(
+	                signature( x = "factor" ),
 	                '
 	                    StringVector s(x) ;
-	                    return s; 
+	                    return s;
 	                '
-	            ), 
-	            "IntegerVector_int_init" = list( 
-	                signature(), 
+	            ),
+	            "IntegerVector_int_init" = list(
+	                signature(),
 	                '
 	                    IntegerVector x(2,4) ;
 	                    return x ;
 	                '
 	            )
-                  
+
         )
 
         if (Rcpp:::capabilities()[["initializer lists"]]) {
-        	g <- list( 
+        	g <- list(
         		"raw_initializer_list"=list(
-        			signature(), 
+        			signature(),
         			'
 					RawVector x = {0,1,2,3} ;
 					for( int i=0; i<x.size(); i++) x[i] = x[i]*2 ;
 					return x ;
 					'
-        		), 
-        		"complex_initializer_list" = list( 
-        			signature(), 
+        		),
+        		"complex_initializer_list" = list(
+        			signature(),
         			'
 					Rcomplex c1 ; c1.r = c1.i = 0.0 ;
 					Rcomplex c2 ; c2.r = c2.i = 1.0 ;
 					ComplexVector x = { c1, c2 } ;
 					return x ;
 					'
-        		), 
+        		),
         		"integer_initializer_list"=list(
                   	signature(),
                   	'
@@ -642,17 +642,17 @@
 		   				for( int i=0; i<x.size(); i++) x[i] = x[i]*2 ;
 		   				return x ;
 		   			'
-		   		), 
-		   		
-		   		"numeric_initlist" = list( 
-        			signature(), 
+		   		),
+
+		   		"numeric_initlist" = list(
+        			signature(),
         			'
 						NumericVector x = {0.0,1.0,2.0,3.0} ;
 						for( int i=0; i<x.size(); i++) x[i] = x[i]*2 ;
 						return x ;
 					'
-        		), 
-        		
+        		),
+
         		"list_initializer_list"=list(
                   signature(),
                   'SEXP x0 = PROTECT( Rf_ScalarInteger( 0 ) ) ;
@@ -660,25 +660,25 @@
 		   			SEXP x2 = PROTECT( Rf_ScalarInteger( 2 ) ) ;
 		   			List x = { x0, x1, x2} ;
 		   			UNPROTECT(3) ;
-		   			return x ;'), 
-		   			
+		   			return x ;'),
+
 		   		"character_initializer_list"=list(
                   signature(),
                   'CharacterVector x = {"foo", "bar"} ;
                   return x ;')
 
-                  
-        	)     
+
+        	)
         	f <- c(f,g)
         }
         f
-    
+
 }
 
 includes <- function(){
 "
     inline double square( double x){ return x*x; }
-"    
+"
 }
 
 cxxargs <- function(){
@@ -688,9 +688,9 @@
 .setUp <- function() {
     tests <- ".rcpp.Vector"
     if( ! exists( tests, globalenv() )) {
-        fun <- Rcpp:::compile_unit_tests( 
-            definitions(), 
-            includes = includes(), 
+        fun <- Rcpp:::compile_unit_tests(
+            definitions(),
+            includes = includes(),
             cxxargs = cxxargs()
         )
         assign( tests, fun, globalenv() )
@@ -719,7 +719,7 @@
 	ex <- parse( text = "rnorm; rnorm(10)" )
 	# get rid of the srcref stuff so that we can compare
 	# more easily
-	attributes(ex) <- NULL 
+	attributes(ex) <- NULL
 	checkEquals( funx(),  ex , msg = "ExpressionVector" )
 }
 
@@ -753,20 +753,20 @@
 	e[["x"]] <- sample(1:10)
 	checkEquals( funx(e), 1:10, msg = "ExpressionVector::eval in specific environment" )
 }
-         
+
 test.ComplexVector <- function(){
 	funx <- .rcpp.Vector$complex_
 	checkEquals( funx(), 0:9*(1+1i), msg = "ComplexVector" )
 }
 test.ComplexVector.CPLXSXP <- function(){
 	funx <- .rcpp.Vector$complex_CPLXSXP
-     vv = (0:9)*(1+1i) ## not working - funx changes its argument 
+     vv = (0:9)*(1+1i) ## not working - funx changes its argument
 	#checkEquals( funx(vv), 2*vv, msg = "ComplexVector( CPLXSXP) " )
 	checkEquals( funx((0:9)*(1+1i)), 2*(0:9)*(1+1i), msg = "ComplexVector( CPLXSXP) " )
 }
 test.ComplexVector.INTSXP <- function(){
 	funx <- .rcpp.Vector$complex_INTSXP
-    vv <- 0L:9L  
+    vv <- 0L:9L
 	checkEquals( funx(vv), (2+0i)*vv, msg = "ComplexVector( INTSXP) " )
 }
 test.ComplexVector.REALSXP <- function(){
@@ -932,7 +932,7 @@
 
 test.IntegerVector.create <- function(){
     fun <- .rcpp.Vector$integer_create_
-	checkEquals( fun(), list( c( 10L, 20L) , c(foo = 20L, bar = 30L) ), 
+	checkEquals( fun(), list( c( 10L, 20L) , c(foo = 20L, bar = 30L) ),
 		msg = "IntegerVector::create" )
 }
 
@@ -943,11 +943,11 @@
 	checkEquals( x, 1:10, msg = "clone" )
 	checkEquals( y, 10:1, msg = "clone" )
 }
-          
 
 
 
 
+
 test.NumericVector <- function(){
 	funx <- .rcpp.Vector$numeric_
 	checkEquals( funx(), as.numeric(0:9), msg = "NumericVector(int)" )
@@ -967,18 +967,18 @@
 
 test.NumericVector.import <- function(){
 	funx <- .rcpp.Vector$numeric_import
-	checkEquals( funx(), 0:9, msg = "IntegerVector::import" ) 
+	checkEquals( funx(), 0:9, msg = "IntegerVector::import" )
 }
 
 test.NumericVector.import.transform <- function(){
 	funx <- .rcpp.Vector$numeric_importtransform
 	checkEquals( funx(), (0:9)^2, msg = "NumericVector::import_transform" )
 }
-         
 
 
 
 
+
 test.List <- function(){
     fun <- .rcpp.Vector$list_ctor
     checkEquals( fun(), as.list( 2*0:9), msg = "GenericVector" )
@@ -1101,22 +1101,22 @@
 
 test.List.create <- function(){
 	fun <- .rcpp.Vector$list_create_
-    checkEquals( fun(), list( list( 10L, "foo" ), list(foo = 10L, bar =  TRUE ) ), 
+    checkEquals( fun(), list( list( 10L, "foo" ), list(foo = 10L, bar =  TRUE ) ),
 		msg = "List::create" )
 }
 
 test.List.stdcomplex <- function(){
 	fun <- .rcpp.Vector$list_stdcomplex
-    checkEquals( 
-		fun(), 
-		list( float = rep(0+0i, 10), double = rep(0+0i, 10) ), 
+    checkEquals(
+		fun(),
+		list( float = rep(0+0i, 10), double = rep(0+0i, 10) ),
 		msg = "range wrap over std::complex" )
 }
-           
 
 
 
 
+
 test.CharacterVector <- function(){
     fun <- .rcpp.Vector$character_ctor
     checkEquals( fun(), rep("foo",10L), msg = "CharacterVector" )
@@ -1229,10 +1229,10 @@
     fun <- .rcpp.Vector$character_find_
     checkEquals( fun( c("bar", "foo", "bob") ), 1L, msg = "support for std::find in CharacterVector" )
 }
-    
+
 test.CharacterVector.create <- function(){
 	fun <- .rcpp.Vector$character_create_
-    checkEquals( fun(), list( c( "foo", "bar" ), c(foo = "bar", bar = "foo" ) ), 
+    checkEquals( fun(), list( c( "foo", "bar" ), c(foo = "bar", bar = "foo" ) ),
 	 	msg = "CharacterVector::create" )
 }
 
@@ -1240,12 +1240,12 @@
 	fun <- .rcpp.Vector$complex_binary_sugar
     x <- (1+1i) * 1:10
     y <- (2-3i) * 1:10
-    
-	checkEquals( 
-		fun(x, y), 
-		list( 
-			"+" = x + y, 
-			"-" = x - y, 
+
+	checkEquals(
+		fun(x, y),
+		list(
+			"+" = x + y,
+			"-" = x - y,
 			"*" = x * y,
 			"/" = x / y
 		), msg = "complex binary operators" )

Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.sugar.R	2012-01-29 15:24:20 UTC (rev 3451)
+++ pkg/Rcpp/inst/unitTests/runit.sugar.R	2012-01-29 15:33:40 UTC (rev 3452)
@@ -1,6 +1,6 @@
 #!/usr/bin/r -t
 #
-# Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+# Copyright (C) 2010 - 2012  Dirk Eddelbuettel and Romain Francois
 #
 # This file is part of Rcpp.
 #
@@ -668,9 +668,9 @@
 			        as_vector( outer( NumericVector(x) , NumericVector(y) , std::plus<double>() ) )
 			    ) ;
 			    '
-			), 
+			),
 			"runit_diff_REALSXP_NA" = list(
-			    signature( x_= "numeric" ), 
+			    signature( x_= "numeric" ),
 			    '
 			         NumericVector x(x_) ;
 			         NumericVector res= diff(x) ;
@@ -1320,7 +1320,7 @@
     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 )



More information about the Rcpp-commits mailing list