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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 13 18:44:11 CEST 2011


Author: dmbates
Date: 2011-07-13 18:44:11 +0200 (Wed, 13 Jul 2011)
New Revision: 3140

Modified:
   pkg/RcppEigen/DESCRIPTION
   pkg/RcppEigen/inst/include/RcppEigenWrap.h
   pkg/RcppEigen/inst/unitTests/runit.RcppEigen.R
Log:
Dispatch on wrap to vector according to T::ColsAtCompileTime; modify tests to avoid the .eval() methods; bump Rcpp version dependence


Modified: pkg/RcppEigen/DESCRIPTION
===================================================================
--- pkg/RcppEigen/DESCRIPTION	2011-07-13 11:54:07 UTC (rev 3139)
+++ pkg/RcppEigen/DESCRIPTION	2011-07-13 16:44:11 UTC (rev 3140)
@@ -21,7 +21,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.4), methods
+Depends: Rcpp (>= 0.9.5.1), methods
 LazyLoad: yes
 LinkingTo: Rcpp
 Suggests: inline, RUnit

Modified: pkg/RcppEigen/inst/include/RcppEigenWrap.h
===================================================================
--- pkg/RcppEigen/inst/include/RcppEigenWrap.h	2011-07-13 11:54:07 UTC (rev 3139)
+++ pkg/RcppEigen/inst/include/RcppEigenWrap.h	2011-07-13 16:44:11 UTC (rev 3140)
@@ -38,7 +38,7 @@
         SEXP eigen_wrap_plain_dense( const T& obj, Rcpp::traits::true_type ){
             // FIXME: deal with RowMajor, etc ...
             const int RTYPE = Rcpp::traits::r_sexptype_traits<typename T::Scalar>::rtype ;
-            if( obj.cols() == 1 ) {
+            if( T::ColsAtCompileTime == 1 ) {
                 return wrap( obj.data(), obj.data() + obj.size() ) ;
             } else {
                 Rcpp::Matrix<RTYPE> x( obj.rows(), obj.cols(), obj.data() ) ;

Modified: pkg/RcppEigen/inst/unitTests/runit.RcppEigen.R
===================================================================
--- pkg/RcppEigen/inst/unitTests/runit.RcppEigen.R	2011-07-13 11:54:07 UTC (rev 3139)
+++ pkg/RcppEigen/inst/unitTests/runit.RcppEigen.R	2011-07-13 16:44:11 UTC (rev 3140)
@@ -25,15 +25,11 @@
 
     fx <- cxxfunction( , '
 
-    // The eval() method is necessary because the static methods Zero()
-    // and Identity() return expression objects, so that more general
-    // expressions involving them can be evaluated more effectively.  We
-    // have not yet written a wrap method for expression objects.
     List vecs = List::create(
-        _["Vec<complex>"] = Eigen::VectorXcd::Zero(5).eval(),
-        _["Vec<double>"]  = Eigen::VectorXd::Zero(5).eval(),
-        _["Vec<float>"]   = Eigen::VectorXf::Zero(5).eval(),
-        _["Vec<int>"]     = Eigen::VectorXi::Zero(5).eval()
+        _["Vec<complex>"] = Eigen::VectorXcd::Zero(5),
+        _["Vec<double>"]  = Eigen::VectorXd::Zero(5),
+        _["Vec<float>"]   = Eigen::VectorXf::Zero(5),
+        _["Vec<int>"]     = Eigen::VectorXi::Zero(5)
     );
 
     // A VectorX<T> behaves as a matrix with one column but is converted to
@@ -43,52 +39,52 @@
     // during execution of the code.  A MatrixX<T> object can be resized to have
     // a different number of columns.  A VectorX<T> object cannot.
     List cols = List::create(
-        _["Col<complex>"] = Eigen::MatrixXcd::Zero(5, 1).eval(),
-        _["Col<double>"]  = Eigen::MatrixXd::Zero(5, 1).eval(),
-        _["Col<float>"]   = Eigen::MatrixXf::Zero(5, 1).eval(),
-        _["Col<int>"]     = Eigen::MatrixXi::Zero(5, 1).eval()
+        _["Col<complex>"] = Eigen::MatrixXcd::Zero(5, 1),
+        _["Col<double>"]  = Eigen::MatrixXd::Zero(5, 1),
+        _["Col<float>"]   = Eigen::MatrixXf::Zero(5, 1),
+        _["Col<int>"]     = Eigen::MatrixXi::Zero(5, 1)
     );
 
     List rows = List::create(
-        _["Row<complex>"] = Eigen::RowVectorXcd::Zero(5).eval(),
-        _["Row<double>"]  = Eigen::RowVectorXd::Zero(5).eval(),
-        _["Row<float>"]   = Eigen::RowVectorXf::Zero(5).eval(),
-        _["Row<int>"]     = Eigen::RowVectorXi::Zero(5).eval()
+        _["Row<complex>"] = Eigen::RowVectorXcd::Zero(5),
+        _["Row<double>"]  = Eigen::RowVectorXd::Zero(5),
+        _["Row<float>"]   = Eigen::RowVectorXf::Zero(5),
+        _["Row<int>"]     = Eigen::RowVectorXi::Zero(5)
     );
 
     List matrices = List::create(
-        _["Mat<complex>"] = Eigen::MatrixXcd::Identity(3, 3).eval(),
-        _["Mat<double>"]  = Eigen::MatrixXd::Identity(3, 3).eval(),
-        _["Mat<float>"]   = Eigen::MatrixXf::Identity(3, 3).eval(),
-        _["Mat<int>"]     = Eigen::MatrixXi::Identity(3, 3).eval()
+        _["Mat<complex>"] = Eigen::MatrixXcd::Identity(3, 3),
+        _["Mat<double>"]  = Eigen::MatrixXd::Identity(3, 3),
+        _["Mat<float>"]   = Eigen::MatrixXf::Identity(3, 3),
+        _["Mat<int>"]     = Eigen::MatrixXi::Identity(3, 3)
     );
 
     // ArrayXX<t> objects have the same structure as matrices but allow
     // componentwise arithmetic.  A * B is matrix multiplication for
     // matrices and componentwise multiplication for arrays.
     List arrays2 = List::create(
-        _["Arr2<complex>"] = Eigen::ArrayXXcd::Zero(3, 3).eval(),
-        _["Arr2<double>"]  = Eigen::ArrayXXd::Zero(3, 3).eval(),
-        _["Arr2<float>"]   = Eigen::ArrayXXf::Zero(3, 3).eval(),
-        _["Arr2<int>"]     = Eigen::ArrayXXi::Zero(3, 3).eval()
+        _["Arr2<complex>"] = Eigen::ArrayXXcd::Zero(3, 3),
+        _["Arr2<double>"]  = Eigen::ArrayXXd::Zero(3, 3),
+        _["Arr2<float>"]   = Eigen::ArrayXXf::Zero(3, 3),
+        _["Arr2<int>"]     = Eigen::ArrayXXi::Zero(3, 3)
     );
 
     // ArrayX<t> objects have the same structure as VectorX<T> objects
     // but allow componentwise arithmetic, including functions like exp, log,
     // sqrt, ...
     List arrays1 = List::create(
-        _["Arr1<complex>"] = Eigen::ArrayXcd::Zero(5).eval(),
-        _["Arr1<double>"]  = Eigen::ArrayXd::Zero(5).eval(),
-        _["Arr1<float>"]   = Eigen::ArrayXf::Zero(5).eval(),
-        _["Arr1<int>"]     = Eigen::ArrayXi::Zero(5).eval()
+        _["Arr1<complex>"] = Eigen::ArrayXcd::Zero(5),
+        _["Arr1<double>"]  = Eigen::ArrayXd::Zero(5),
+        _["Arr1<float>"]   = Eigen::ArrayXf::Zero(5),
+        _["Arr1<int>"]     = Eigen::ArrayXi::Zero(5)
     );
 
     List operations = List::create(
-        _["Op_seq"]  = Eigen::ArrayXd::LinSpaced(6, 1, 10).eval(),  // arguments are length.out, start, end
-        _["Op_log"]  = Eigen::ArrayXd::LinSpaced(6, 1, 10).log().eval(),
-        _["Op_exp"]  = Eigen::ArrayXd::LinSpaced(6, 1, 10).exp().eval(),
-        _["Op_sqrt"] = Eigen::ArrayXd::LinSpaced(6, 1, 10).sqrt().eval(),
-        _["Op_cos"]  = Eigen::ArrayXd::LinSpaced(6, 1, 10).cos().eval()
+        _["Op_seq"]  = Eigen::ArrayXd::LinSpaced(6, 1, 10),  // arguments are length.out, start, end
+        _["Op_log"]  = Eigen::ArrayXd::LinSpaced(6, 1, 10).log(),
+        _["Op_exp"]  = Eigen::ArrayXd::LinSpaced(6, 1, 10).exp(),
+        _["Op_sqrt"] = Eigen::ArrayXd::LinSpaced(6, 1, 10).sqrt(),
+        _["Op_cos"]  = Eigen::ArrayXd::LinSpaced(6, 1, 10).cos()
     );
 
     List output = List::create(



More information about the Rcpp-commits mailing list