[Rcpp-commits] r4048 - in pkg/RcppEigen: . inst/include

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 28 15:43:14 CET 2012


Author: romain
Date: 2012-11-28 15:43:14 +0100 (Wed, 28 Nov 2012)
New Revision: 4048

Modified:
   pkg/RcppEigen/ChangeLog
   pkg/RcppEigen/DESCRIPTION
   pkg/RcppEigen/inst/include/RcppEigenWrap.h
Log:
compatinility with Rcpp 0.10.1

Modified: pkg/RcppEigen/ChangeLog
===================================================================
--- pkg/RcppEigen/ChangeLog	2012-11-27 14:21:42 UTC (rev 4047)
+++ pkg/RcppEigen/ChangeLog	2012-11-28 14:43:14 UTC (rev 4048)
@@ -1,3 +1,7 @@
+2012-11-28  Romain Francois  <romain at r-enthusiasts.com>
+
+	* include/RcppEigenWrap.h: compatibility issue with Rcpp 0.10.1
+
 2012-08-14  Dirk Eddelbuettel  <edd at debian.org>
 
 	* R/flags.R: Add two (unexported) functions CxxFlags() and

Modified: pkg/RcppEigen/DESCRIPTION
===================================================================
--- pkg/RcppEigen/DESCRIPTION	2012-11-27 14:21:42 UTC (rev 4047)
+++ pkg/RcppEigen/DESCRIPTION	2012-11-28 14:43:14 UTC (rev 4048)
@@ -1,7 +1,7 @@
 Package: RcppEigen
 Type: Package
 Title: Rcpp integration for the Eigen templated linear algebra library.
-Version: 0.3.1
+Version: 0.3.2
 Date: 2012-08-07
 Author: Douglas Bates, Romain Francois and Dirk Eddelbuettel
 Maintainer: Douglas Bates <bates at stat.wisc.edu>
@@ -23,7 +23,7 @@
  bindings/bridge to Eigen) is licensed under the GNU GPL version 2 or
  later, as is the rest of Rcpp.
 License: GPL (>= 2)
-Depends: Rcpp (>= 0.9.6), Matrix (>= 1.0-1), R(>= 2.14.0)
+Depends: Rcpp (>= 0.10.1), Matrix (>= 1.0-1), R(>= 2.14.0)
 LazyLoad: yes
 LinkingTo: Rcpp
 Imports: Matrix

Modified: pkg/RcppEigen/inst/include/RcppEigenWrap.h
===================================================================
--- pkg/RcppEigen/inst/include/RcppEigenWrap.h	2012-11-27 14:21:42 UTC (rev 4047)
+++ pkg/RcppEigen/inst/include/RcppEigenWrap.h	2012-11-28 14:43:14 UTC (rev 4048)
@@ -154,87 +154,95 @@
 
 
     namespace traits {
-
         /* support for Rcpp::as */
-    
+        
+        template <typename T, int RTYPE>
+        class Eigen_Matrix_Exporter {
+            public:
+            Eigen_Matrix_Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_length(x)) {
+                if (TYPEOF(x) != RTYPE)
+                    throw std::invalid_argument("Wrong R type for mapped vector");
+                if (::Rf_isMatrix(x)) {
+                    int *dims = vec.dims() ;
+                    d_nrow = dims[0];
+                    d_ncol = dims[1];
+                }
+            }
+            T get() {return T(vec.begin(), d_nrow, d_ncol );}
+            private:
+                Rcpp::Vector<RTYPE> vec ;
+                int d_nrow, d_ncol ;
+        } ;
+       
+        
         template<typename T>
         class Exporter<Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1> > > {
+            typedef typename Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1> > OUT ;
+            const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+            Rcpp::Vector<RTYPE> vec ;
+        
         public:
-            typedef typename Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1> >  MVType;
-            Exporter(SEXP x) : d_size(::Rf_length(x)) {
-                const int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+            Exporter(SEXP x) : vec(x) {
                 if (TYPEOF(x) != RTYPE)
                     throw std::invalid_argument("Wrong R type for mapped vector");
-                typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE;
-                d_start         = ::Rcpp::internal::r_vector_start<RTYPE,STORAGE>(x);
             }
-            MVType get() {return MVType(d_start, d_size);}
-        protected:
-            const int d_size;
-            T*        d_start;
-        };
-
+            OUT get() {return OUT(vec.begin(), vec.size());}
+        } ;
+        
         template<typename T>
-        class Exporter<Eigen::Map<Eigen::Array<T, Eigen::Dynamic, 1> > > {
+        class Exporter< Eigen::Map<Eigen::Array<T, Eigen::Dynamic, 1> > > {
+            typedef typename Eigen::Map<Eigen::Array<T, Eigen::Dynamic, 1> > OUT ;
+            const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+            Rcpp::Vector<RTYPE> vec ;
+        
         public:
-            typedef typename Eigen::Map<Eigen::Array<T, Eigen::Dynamic, 1> >  MAType;
-            Exporter(SEXP x) : d_size(::Rf_length(x)) {
-                const int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+            Exporter(SEXP x) : vec(x) {
                 if (TYPEOF(x) != RTYPE)
                     throw std::invalid_argument("Wrong R type for mapped vector");
-                typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE;
-                d_start         = ::Rcpp::internal::r_vector_start<RTYPE,STORAGE>(x);
             }
-            MAType get() {return MAType(d_start, d_size);}
-        protected:
-            const int d_size;
-            T*        d_start;
-        };
-
+            OUT get() {return OUT(vec.begin(), vec.size());}
+        } ;
+        
         template<typename T>
         class Exporter<Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> > > {
-        public:
-            typedef typename Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >  MMType;
-            Exporter(SEXP x) : d_nrow(::Rf_length(x)), d_ncol(1) {
-                const int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+            typedef typename Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> > OUT ;
+            const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+            Rcpp::Vector<RTYPE> vec ;
+            int d_nrow, d_ncol ;
+            
+            public:
+            Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_length(x)) {
                 if (TYPEOF(x) != RTYPE)
                     throw std::invalid_argument("Wrong R type for mapped vector");
-                typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE;
-                d_start         = ::Rcpp::internal::r_vector_start<RTYPE,STORAGE>(x);
                 if (::Rf_isMatrix(x)) {
-                    int *dims = INTEGER(::Rf_getAttrib(x, R_DimSymbol));
+                    int *dims = INTEGER( ::Rf_getAttrib( x, R_DimSymbol ) ) ;
                     d_nrow = dims[0];
                     d_ncol = dims[1];
                 }
             }
-            MMType get() {return MMType(d_start, d_nrow, d_ncol);}
-        protected:
-            int   d_nrow, d_ncol;
-            T*    d_start;
-        };
-
+            OUT get() {return OUT(vec.begin(), d_nrow, d_ncol );}
+        } ;  
+        
         template<typename T>
         class Exporter<Eigen::Map<Eigen::Array<T, Eigen::Dynamic, Eigen::Dynamic> > > {
-        public:
-            typedef typename Eigen::Map<Eigen::Array<T, Eigen::Dynamic, Eigen::Dynamic> >  MAType;
-            Exporter(SEXP x) : d_nrow(::Rf_length(x)), d_ncol(1) {
-                const int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+            typedef typename Eigen::Map<Eigen::Array<T, Eigen::Dynamic, Eigen::Dynamic> > OUT ;
+            const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+            Rcpp::Vector<RTYPE> vec ;
+            int d_nrow, d_ncol ;
+            
+            public:
+            Exporter(SEXP x) : vec(x), d_ncol(1), d_nrow(Rf_length(x)) {
                 if (TYPEOF(x) != RTYPE)
                     throw std::invalid_argument("Wrong R type for mapped vector");
-                typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE;
-                d_start         = ::Rcpp::internal::r_vector_start<RTYPE,STORAGE>(x);
                 if (::Rf_isMatrix(x)) {
-                    int *dims = INTEGER(::Rf_getAttrib(x, R_DimSymbol));
+                    int *dims = INTEGER( ::Rf_getAttrib( x, R_DimSymbol ) ) ;
                     d_nrow = dims[0];
                     d_ncol = dims[1];
                 }
             }
-            MAType get() {return MAType(d_start, d_nrow, d_ncol);}
-        protected:
-            int   d_nrow, d_ncol;
-            T*    d_start;
-        };
-
+            OUT get() {return OUT(vec.begin(), d_nrow, d_ncol );}
+        } ;  
+        
         template <typename T> 
         class Exporter<Eigen::Matrix<T, Eigen::Dynamic, 1> >
             : public IndexingExporter<Eigen::Matrix<T, Eigen::Dynamic, 1>, T> {



More information about the Rcpp-commits mailing list