[Rcpp-commits] r1225 - in pkg/RcppGSL: inst/unitTests src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 13 14:21:23 CEST 2010


Author: romain
Date: 2010-05-13 14:21:22 +0200 (Thu, 13 May 2010)
New Revision: 1225

Modified:
   pkg/RcppGSL/inst/unitTests/runit.gsl.R
   pkg/RcppGSL/src/RcppGSL.cpp
Log:
added simple unit test to show conversion from RcppGSL::vector<int> to NumericVector (in two steps)

Modified: pkg/RcppGSL/inst/unitTests/runit.gsl.R
===================================================================
--- pkg/RcppGSL/inst/unitTests/runit.gsl.R	2010-05-13 12:15:48 UTC (rev 1224)
+++ pkg/RcppGSL/inst/unitTests/runit.gsl.R	2010-05-13 12:21:22 UTC (rev 1225)
@@ -117,3 +117,8 @@
 	checkEquals( res, sum(x[,1]), msg = "RcppGSL::matrix<double>(SEXP)" )
 }
 
+test.gsl.RcppGSL.vector <- function(){
+	res <- .Call( "test_gsl_vector_conv", PACKAGE = "RcppGSL" )
+	checkEquals( res, 0:9, msg = "RcppGSL::vector<int> -> IntegerVector" )
+}
+

Modified: pkg/RcppGSL/src/RcppGSL.cpp
===================================================================
--- pkg/RcppGSL/src/RcppGSL.cpp	2010-05-13 12:15:48 UTC (rev 1224)
+++ pkg/RcppGSL/src/RcppGSL.cpp	2010-05-13 12:21:22 UTC (rev 1225)
@@ -238,3 +238,13 @@
 	return res ;
 }
 
+RCPP_FUNCTION_0(Rcpp::IntegerVector, test_gsl_vector_conv){
+	RcppGSL::vector<int> vec(10) ;
+	for( int i=0; i<10; i++){
+		gsl_vector_int_set( vec, i, i ) ;	
+	}
+	Rcpp::IntegerVector x ; 
+	x = vec ;
+	return x ;
+}
+



More information about the Rcpp-commits mailing list