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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 7 09:39:53 CEST 2010


Author: romain
Date: 2010-04-07 09:39:52 +0200 (Wed, 07 Apr 2010)
New Revision: 1022

Modified:
   pkg/RcppGSL/inst/include/RcppGSLForward.h
   pkg/RcppGSL/inst/include/RcppGSL_vector_view.h
   pkg/RcppGSL/inst/unitTests/runit.gsl.R
   pkg/RcppGSL/src/RcppGSL.cpp
Log:
test gsl.vector.view

Modified: pkg/RcppGSL/inst/include/RcppGSLForward.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSLForward.h	2010-04-07 07:18:49 UTC (rev 1021)
+++ pkg/RcppGSL/inst/include/RcppGSLForward.h	2010-04-07 07:39:52 UTC (rev 1022)
@@ -89,6 +89,21 @@
 	template <> SEXP wrap( const gsl_vector_ushort_view& ) ;
 	template <> SEXP wrap( const gsl_vector_ulong_view& ) ;
 	
+	template <> SEXP wrap( const gsl_vector_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_int_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_float_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_long_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_char_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_complex_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_complex_float_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_complex_long_double_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_long_double_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_short_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_uchar_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_uint_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_ushort_const_view& ) ;
+	template <> SEXP wrap( const gsl_vector_ulong_const_view& ) ;
+	
 	template <> SEXP wrap( const gsl_matrix& ) ;
 	template <> SEXP wrap( const gsl_matrix_int& ) ;
 	template <> SEXP wrap( const gsl_matrix_float& ) ;

Modified: pkg/RcppGSL/inst/include/RcppGSL_vector_view.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSL_vector_view.h	2010-04-07 07:18:49 UTC (rev 1021)
+++ pkg/RcppGSL/inst/include/RcppGSL_vector_view.h	2010-04-07 07:39:52 UTC (rev 1022)
@@ -17,8 +17,8 @@
 // You should have received a copy of the GNU General Public License
 // along with RcppGSL.  If not, see <http://www.gnu.org/licenses/>.
 
-#ifndef RCPPGSL__RCPPGSL_VECTOR_H
-#define RCPPGSL__RCPPGSL_VECTOR_H
+#ifndef RCPPGSL__RCPPGSL_VECTOR_VIEW_H
+#define RCPPGSL__RCPPGSL_VECTOR_VIEW_H
 
 #include <RcppGSLForward.h>
 #include <Rcpp.h>
@@ -28,10 +28,10 @@
 
 #define RCPPGSL_VIEW(SUFFIX)                                         \
 template <> SEXP wrap( const gsl_vector##SUFFIX##_view& x){          \
-	return wrap(x->vector) ;                                         \
+	return wrap(x.vector) ;                                         \
 }  ;                                                                 \
 template <> SEXP wrap( const gsl_vector##SUFFIX##_const_view& x ){   \
-   return wrap(x->vector) ;                                          \
+   return wrap(x.vector) ;                                          \
 }
 
 RCPPGSL_VIEW()

Modified: pkg/RcppGSL/inst/unitTests/runit.gsl.R
===================================================================
--- pkg/RcppGSL/inst/unitTests/runit.gsl.R	2010-04-07 07:18:49 UTC (rev 1021)
+++ pkg/RcppGSL/inst/unitTests/runit.gsl.R	2010-04-07 07:39:52 UTC (rev 1022)
@@ -69,3 +69,12 @@
 		msg = "wrap( gsl_matrix )" )
 
 }
+
+test.gsl.vector.view <- function(){
+	res <- .Call( "test_gsl_vector_view", PACKAGE = "RcppGSL" )
+	checkEquals( res, 
+		list( even = 2.0 * 0:4, odd = 2.0 * 0:4 + 1.0 ), 
+		msg = "wrap( gsl.vector.view )" )
+	
+}
+

Modified: pkg/RcppGSL/src/RcppGSL.cpp
===================================================================
--- pkg/RcppGSL/src/RcppGSL.cpp	2010-04-07 07:18:49 UTC (rev 1021)
+++ pkg/RcppGSL/src/RcppGSL.cpp	2010-04-07 07:39:52 UTC (rev 1022)
@@ -105,3 +105,21 @@
 	
 	return res ;
 }
+
+extern "C" SEXP test_gsl_vector_view(){
+	int n = 10 ;
+	gsl_vector *v = gsl_vector_calloc (n);
+	for( int i=0 ; i<n; i++){
+		gsl_vector_set( v, i, i ) ;	
+	}
+	gsl_vector_view v_even = gsl_vector_subvector_with_stride(v, 0, 2, n/2);
+    gsl_vector_view v_odd  = gsl_vector_subvector_with_stride(v, 1, 2, n/2);
+    
+    List res = List::create( 
+    	_["even"] = v_even, 
+    	_["odd" ] = v_odd
+    	) ;
+    gsl_vector_free(v);
+	
+    return res ;
+}



More information about the Rcpp-commits mailing list