[Rcpp-commits] r2559 - pkg/RcppGSL/inst/include

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Nov 27 19:14:05 CET 2010


Author: romain
Date: 2010-11-27 19:14:05 +0100 (Sat, 27 Nov 2010)
New Revision: 2559

Modified:
   pkg/RcppGSL/inst/include/RcppGSL_matrix.h
   pkg/RcppGSL/inst/include/RcppGSL_matrix_view.h
   pkg/RcppGSL/inst/include/RcppGSL_vector_view.h
Log:
less line noise

Modified: pkg/RcppGSL/inst/include/RcppGSL_matrix.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSL_matrix.h	2010-11-27 18:10:26 UTC (rev 2558)
+++ pkg/RcppGSL/inst/include/RcppGSL_matrix.h	2010-11-27 18:14:05 UTC (rev 2559)
@@ -131,7 +131,20 @@
 	}                                                                       \
 }
 
-_RCPPGSL_DEF(double                   ,        )
+inline void matrix<double>::import( SEXP x) throw(::Rcpp::not_compatible) {
+	Rcpp::Matrix<RTYPE> mat( x );                                         
+	int nc = mat.ncol() ;                                                 
+	int nr = mat.nrow() ;                                                 
+	int i = 0, j = 0 ;                                                    
+	data = gsl_matrix_alloc( nr, nc ) ;                     
+	Rcpp::Matrix<RTYPE>::iterator it = mat.begin() ;                      
+	for( ; j<nc; j++){                                                    
+		for( i=0; i<nr; i++, it++){                                       
+			gsl_matrix_set( data, i, j, *it ) ;             
+		}                                                                 
+	}                                                                     
+}
+
 _RCPPGSL_DEF(int                      , _int   )
 _RCPPGSL_DEF(unsigned char            , _uchar )
 

Modified: pkg/RcppGSL/inst/include/RcppGSL_matrix_view.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSL_matrix_view.h	2010-11-27 18:10:26 UTC (rev 2558)
+++ pkg/RcppGSL/inst/include/RcppGSL_matrix_view.h	2010-11-27 18:14:05 UTC (rev 2559)
@@ -35,7 +35,6 @@
    return wrap(x.matrix) ;                                           \
 }
 
-RCPPGSL_VIEW()
 RCPPGSL_VIEW(_int)
 RCPPGSL_VIEW(_float)
 RCPPGSL_VIEW(_long)
@@ -51,6 +50,13 @@
 RCPPGSL_VIEW(_ulong)
 #undef RCPPGSL_VIEW
 
+#define RCPPGSL_VIEW(SUFFIX)                                      
+template <> SEXP wrap( const gsl_matrix_view& x){       
+	return wrap(x.matrix) ;                                       
+}                                                                 
+template <> SEXP wrap( const gsl_matrix_const_view& x ){
+   return wrap(x.matrix) ;                                        
+}
 template <typename T> SEXP wrap( const ::RcppGSL::matrix_view<T>& x){
 	return wrap( x.view.matrix ) ;
 }

Modified: pkg/RcppGSL/inst/include/RcppGSL_vector_view.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSL_vector_view.h	2010-11-27 18:10:26 UTC (rev 2558)
+++ pkg/RcppGSL/inst/include/RcppGSL_vector_view.h	2010-11-27 18:14:05 UTC (rev 2559)
@@ -35,7 +35,6 @@
    return wrap(x.vector) ;                                           \
 }
 
-RCPPGSL_VIEW()
 RCPPGSL_VIEW(_int)
 RCPPGSL_VIEW(_float)
 RCPPGSL_VIEW(_long)
@@ -51,6 +50,13 @@
 RCPPGSL_VIEW(_ulong)
 #undef RCPPGSL_VIEW
 
+template <> SEXP wrap( const gsl_vector_view& x){       
+	return wrap(x.vector) ;                                       
+}                                                                 
+template <> SEXP wrap( const gsl_vector_const_view& x ){
+   return wrap(x.vector) ;                                        
+}
+
 template <typename T> SEXP wrap( const ::RcppGSL::vector_view<T>& x){
 	return wrap( x.view.vector ) ;
 }



More information about the Rcpp-commits mailing list