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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 6 12:10:24 CEST 2010


Author: romain
Date: 2010-04-06 12:10:23 +0200 (Tue, 06 Apr 2010)
New Revision: 1009

Modified:
   pkg/RcppGSL/inst/include/RcppGSL.h
   pkg/RcppGSL/inst/include/RcppGSLForward.h
   pkg/RcppGSL/inst/unitTests/runit.gsl.R
   pkg/RcppGSL/src/RcppGSL.cpp
Log:
gsl_vector_complex_float

Modified: pkg/RcppGSL/inst/include/RcppGSL.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSL.h	2010-04-06 10:03:42 UTC (rev 1008)
+++ pkg/RcppGSL/inst/include/RcppGSL.h	2010-04-06 10:10:23 UTC (rev 1009)
@@ -38,6 +38,20 @@
 			x.i = GSL_IMAG(from) ;
 			return x ;
 		}
+		
+		template<> gsl_complex_float caster<Rcomplex,gsl_complex_float>( Rcomplex from){
+			gsl_complex_float x ;
+			GSL_REAL(x) = static_cast<float>( from.r ) ;
+			GSL_IMAG(x) = static_cast<float>( from.i ) ;
+			return x ;
+		}
+		template<> Rcomplex caster<gsl_complex_float,Rcomplex>( gsl_complex_float from){
+			Rcomplex x ;
+			x.r = static_cast<double>( GSL_REAL(from) ) ;
+			x.i = static_cast<double>( GSL_IMAG(from) ) ;
+			return x ;
+		}
+	
 	}
 
 template <> SEXP wrap( const gsl_vector& x){
@@ -67,7 +81,13 @@
 		reinterpret_cast<gsl_complex*>(x.data), 
 		reinterpret_cast<gsl_complex*>(x.data) + x.size ) ;	
 }
-
+ 
+template <> SEXP wrap( const gsl_vector_complex_float& x){
+	return wrap( 
+		reinterpret_cast<gsl_complex_float*>(x.data), 
+		reinterpret_cast<gsl_complex_float*>(x.data) + x.size ) ;	
+}
+   
 } 
 
 #endif

Modified: pkg/RcppGSL/inst/include/RcppGSLForward.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSLForward.h	2010-04-06 10:03:42 UTC (rev 1008)
+++ pkg/RcppGSL/inst/include/RcppGSLForward.h	2010-04-06 10:10:23 UTC (rev 1009)
@@ -32,11 +32,22 @@
 		template<> struct wrap_type_traits<gsl_complex> { typedef wrap_type_primitive_tag wrap_category; } ;
 		template<> struct r_type_traits<gsl_complex>{ typedef r_type_primitive_tag r_category ; } ;
 		template<> struct r_type_traits< std::pair<const std::string,gsl_complex> >{ typedef r_type_primitive_tag r_category ; } ;
+	
+		/* support for gsl_complex_float */
+		template<> struct r_sexptype_traits<gsl_complex_float>{ enum{ rtype = CPLXSXP } ; } ;
+		template<> struct wrap_type_traits<gsl_complex_float> { typedef wrap_type_primitive_tag wrap_category; } ;
+		template<> struct r_type_traits<gsl_complex_float>{ typedef r_type_primitive_tag r_category ; } ;
+		template<> struct r_type_traits< std::pair<const std::string,gsl_complex_float> >{ typedef r_type_primitive_tag r_category ; } ;
+	
 	}
 	
 	namespace internal{
 		template<> gsl_complex caster<Rcomplex,gsl_complex>( Rcomplex from) ;
 		template<> Rcomplex caster<gsl_complex,Rcomplex>( gsl_complex from) ;
+		
+		template<> gsl_complex_float caster<Rcomplex,gsl_complex_float>( Rcomplex from) ;
+		template<> Rcomplex caster<gsl_complex_float,Rcomplex>( gsl_complex_float from) ;
+    
     }
 	
 	template <> SEXP wrap( const gsl_vector& ) ;
@@ -45,6 +56,7 @@
 	template <> SEXP wrap( const gsl_vector_long& ) ;
 	template <> SEXP wrap( const gsl_vector_char& ) ;
 	template <> SEXP wrap( const gsl_vector_complex& ) ;
+	template <> SEXP wrap( const gsl_vector_complex_float& ) ;
 }
 
 #endif

Modified: pkg/RcppGSL/inst/unitTests/runit.gsl.R
===================================================================
--- pkg/RcppGSL/inst/unitTests/runit.gsl.R	2010-04-06 10:03:42 UTC (rev 1008)
+++ pkg/RcppGSL/inst/unitTests/runit.gsl.R	2010-04-06 10:10:23 UTC (rev 1009)
@@ -26,7 +26,8 @@
 			"gsl_vector_int" = integer(10), 
 			"gsl_vector_long" = numeric(10), 
 			"gsl_vector_char" = raw(10), 
-			"gsl_vector_complex" = complex(10)
+			"gsl_vector_complex" = complex(10), 
+			"gsl_vector_complex_float" = complex(10)
 		), 
 		msg = "wrap( gsl_vector )" )
 }

Modified: pkg/RcppGSL/src/RcppGSL.cpp
===================================================================
--- pkg/RcppGSL/src/RcppGSL.cpp	2010-04-06 10:03:42 UTC (rev 1008)
+++ pkg/RcppGSL/src/RcppGSL.cpp	2010-04-06 10:10:23 UTC (rev 1009)
@@ -9,6 +9,7 @@
 	gsl_vector_long * x_long  = gsl_vector_long_calloc(10) ;
 	gsl_vector_char * x_char  = gsl_vector_char_calloc(10) ;
 	gsl_vector_complex * x_complex  = gsl_vector_complex_calloc(10) ;
+	gsl_vector_complex_float * x_complex_float  = gsl_vector_complex_float_calloc(10) ;
 	
 	/* create an R list containing copies of gsl data */
 	List res = List::create( 
@@ -17,7 +18,8 @@
 		_["gsl_vector_int"] = *x_int, 
 		_["gsl_vector_long"] = *x_long, 
 		_["gsl_vector_char"] = *x_char, 
-		_["gsl_vector_complex"] = *x_complex
+		_["gsl_vector_complex"] = *x_complex,
+		_["gsl_vector_complex_float"] = *x_complex_float
 		) ;
 	
 	/* cleanup gsl data */
@@ -27,6 +29,7 @@
 	gsl_vector_long_free( x_long );
 	gsl_vector_char_free( x_char );
 	gsl_vector_complex_free( x_complex );
+	gsl_vector_complex_float_free( x_complex_float );
 	
 	return res ;
 }



More information about the Rcpp-commits mailing list