[Rcpp-commits] r1017 - in pkg/RcppGSL: . inst/include src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Apr 6 15:49:29 CEST 2010
Author: romain
Date: 2010-04-06 15:49:29 +0200 (Tue, 06 Apr 2010)
New Revision: 1017
Modified:
pkg/RcppGSL/DESCRIPTION
pkg/RcppGSL/inst/include/RcppGSL.h
pkg/RcppGSL/inst/include/RcppGSLForward.h
pkg/RcppGSL/src/RcppGSL.cpp
Log:
support for gsl_matrix
Modified: pkg/RcppGSL/DESCRIPTION
===================================================================
--- pkg/RcppGSL/DESCRIPTION 2010-04-06 13:48:29 UTC (rev 1016)
+++ pkg/RcppGSL/DESCRIPTION 2010-04-06 13:49:29 UTC (rev 1017)
@@ -8,6 +8,6 @@
Description: Glue between Rcpp and the GNU GSL
License: GPL (>=2)
LazyLoad: yes
-Depends: Rcpp (>= 0.7.11.3)
+Depends: Rcpp (>= 0.7.11.4)
LinkingTo: Rcpp
SystemRequirements: GNU GSL
Modified: pkg/RcppGSL/inst/include/RcppGSL.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSL.h 2010-04-06 13:48:29 UTC (rev 1016)
+++ pkg/RcppGSL/inst/include/RcppGSL.h 2010-04-06 13:49:29 UTC (rev 1017)
@@ -130,6 +130,14 @@
return wrap( x.data, x.data + x.size ) ;
}
+
+/* matrices */
+
+template <> SEXP wrap( const gsl_matrix& x){
+ return internal::rowmajor_wrap( x.data, x.size1, x.size2 ) ;
+}
+
+
}
#endif
Modified: pkg/RcppGSL/inst/include/RcppGSLForward.h
===================================================================
--- pkg/RcppGSL/inst/include/RcppGSLForward.h 2010-04-06 13:48:29 UTC (rev 1016)
+++ pkg/RcppGSL/inst/include/RcppGSLForward.h 2010-04-06 13:49:29 UTC (rev 1017)
@@ -21,7 +21,8 @@
#define RCPPGSL__RCPPGSLFORWARD_H
#include <RcppCommon.h>
-#include <gsl/gsl_vector.h>
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_matrix.h>
/* forward declarations */
namespace Rcpp{
@@ -59,9 +60,34 @@
}
+// namespace RcppGsl {
+// template <typename T> struct contained ; /* not defined on purpose */
+// template <> struct contained<gsl_vector>{Êtypedef double type ;} ;
+// template <> struct contained<gsl_vector_float>{Êtypedef float type ; } ;
+// template <> struct contained<gsl_vector_int>{ typedef int type; } ;
+// template <> struct contained<gsl_vector_long>{ typedef long type ; } ;
+// template <> struct contained<gsl_vector_char>{ typedef Rbyte type ; } ;
+// template <> struct contained<gsl_vector_complex>{ typedef gsl_complex type ; } ;
+// template <> struct contained<gsl_vector_complex_float>{ typedef gsl_complex_float type ; };
+// template <> struct contained<gsl_vector_complex_long_double>{ typedef gsl_complex_long_double type ; } ;
+// template <> struct contained<gsl_vector_long_double>{ typedef long double type ; }
+// template <> struct contained<gsl_vector_short>{Êtypedef short type ; }
+// template <> struct contained<gsl_vector_uchar>{ typedef unsigned char type ; } ;
+// template <> struct contained<gsl_vector_uint>{ typedef unsigned int type ; } ;
+// template <> struct contained<gsl_vector_ushort>{ typedef unsigned short type ; } ;
+// template <> struct contained<gsl_vector_ulong>{ typedef unsigned long type ; } ;
+//
+// template <typename T> struct needs_reinterpret : public ::Rcpp::traits::false_type{} ;
+// template <> struct needs_reinterpret<gsl_vector_complex> : public ::Rcpp::traits::true_type{} ;
+// template <> struct needs_reinterpret<gsl_vector_complex_float> : public ::Rcpp::traits::true_type{} ;
+// template <> struct needs_reinterpret<gsl_vector_complex_long_double> : public ::Rcpp::traits::true_type{} ;
+// template <> struct needs_reinterpret<gsl_vector_char> : public ::Rcpp::traits::true_type{} ;
+// }
+
+
template <> SEXP wrap( const gsl_vector& ) ;
+ template <> SEXP wrap( const gsl_vector_int& ) ;
template <> SEXP wrap( const gsl_vector_float& ) ;
- template <> SEXP wrap( const gsl_vector_int& ) ;
template <> SEXP wrap( const gsl_vector_long& ) ;
template <> SEXP wrap( const gsl_vector_char& ) ;
template <> SEXP wrap( const gsl_vector_complex& ) ;
@@ -74,6 +100,9 @@
template <> SEXP wrap( const gsl_vector_ushort& ) ;
template <> SEXP wrap( const gsl_vector_ulong& ) ;
+
+ template <> SEXP wrap( const gsl_matrix& ) ;
+
}
#endif
Modified: pkg/RcppGSL/src/RcppGSL.cpp
===================================================================
--- pkg/RcppGSL/src/RcppGSL.cpp 2010-04-06 13:48:29 UTC (rev 1016)
+++ pkg/RcppGSL/src/RcppGSL.cpp 2010-04-06 13:49:29 UTC (rev 1017)
@@ -54,3 +54,15 @@
return res ;
}
+
+extern "C" SEXP test_gsl_matrix(){
+ gsl_matrix * x_double = gsl_matrix_alloc(5, 2); gsl_matrix_set_identity( x_double ) ;
+
+ List res = List::create(
+ _["gsl_matrix"] = *x_double
+ ) ;
+
+ gsl_matrix_free( x_double );
+
+ return res ;
+}
More information about the Rcpp-commits
mailing list