[Rcpp-commits] r3727 - in pkg/RcppEigen/inst: include unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jul 30 22:28:34 CEST 2012
Author: dmbates
Date: 2012-07-30 22:28:34 +0200 (Mon, 30 Jul 2012)
New Revision: 3727
Modified:
pkg/RcppEigen/inst/include/RcppEigenWrap.h
pkg/RcppEigen/inst/unitTests/runit.RcppEigen.R
Log:
Another suggest from Gael Guennebaud to allow row vectors to be wrapped.
Changed the tests accordingly.
Modified: pkg/RcppEigen/inst/include/RcppEigenWrap.h
===================================================================
--- pkg/RcppEigen/inst/include/RcppEigenWrap.h 2012-07-28 18:22:07 UTC (rev 3726)
+++ pkg/RcppEigen/inst/include/RcppEigenWrap.h 2012-07-30 20:28:34 UTC (rev 3727)
@@ -80,13 +80,12 @@
// for plain dense objects
template <typename T>
SEXP eigen_wrap_plain_dense( const T& obj, Rcpp::traits::true_type ){
- int m = obj.rows(), n = obj.cols();
typename Eigen::internal::conditional<T::IsRowMajor,
Eigen::Matrix<typename T::Scalar,
T::RowsAtCompileTime,
- T::ColsAtCompileTime,
- Eigen::ColMajor>,
+ T::ColsAtCompileTime>,
const T&>::type objCopy(obj);
+ int m = obj.rows(), n = obj.cols();
SEXP ans = PROTECT(::Rcpp::wrap(objCopy.data(), objCopy.data() + m * n));
if( T::ColsAtCompileTime != 1 ) {
SEXP dd = PROTECT(::Rf_allocVector(INTSXP, 2));
Modified: pkg/RcppEigen/inst/unitTests/runit.RcppEigen.R
===================================================================
--- pkg/RcppEigen/inst/unitTests/runit.RcppEigen.R 2012-07-28 18:22:07 UTC (rev 3726)
+++ pkg/RcppEigen/inst/unitTests/runit.RcppEigen.R 2012-07-30 20:28:34 UTC (rev 3727)
@@ -45,12 +45,12 @@
_["Col<int>"] = Eigen::MatrixXi::Zero(5, 1)
);
-// List rows = List::create( // Do not try to wrap row vectors
-// _["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 rows = List::create(
+ _["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),
@@ -90,7 +90,7 @@
List output = List::create(
_["vectors : VectorX<T>"] = vecs,
_["matrices : MatrixX<T>"] = matrices,
-// _["rows : RowVectorX<T>"] = rows,
+ _["rows : RowVectorX<T>"] = rows,
_["columns : MatrixX<T>"] = cols,
_["arrays2d : ArrayXX<T>"] = arrays2,
_["arrays1d : ArrayX<T>"] = arrays1,
@@ -112,10 +112,10 @@
checkEquals( res[["matrices : MatrixX<T>"]][["Mat<float>"]], diag(nr=3L), msg = "MatrixXf::Identity(3,3)")
checkEquals( res[["matrices : MatrixX<T>"]][["Mat<int>"]], matrix(as.integer((diag(nr=3L))),nr=3L), msg = "MatrixXi::Identity(3,3)")
-# checkEquals( res[["rows : RowVectorX<T>"]][["Row<complex>"]], matrix(complex(5), nr=1L), msg = "RowVectorXcd::Zero(5)" )
-# checkEquals( res[["rows : RowVectorX<T>"]][["Row<double>"]], matrix(numeric(5), nr=1L), msg = "RowVectorXd::Zero(5)" )
-# checkEquals( res[["rows : RowVectorX<T>"]][["Row<float>"]], matrix(numeric(5), nr=1L), msg = "RowVectorXf::Zero(5)" )
-# checkEquals( res[["rows : RowVectorX<T>"]][["Row<int>"]], matrix(integer(5), nr=1L), msg = "RowVectorXi::Zero(5)" )
+ checkEquals( res[["rows : RowVectorX<T>"]][["Row<complex>"]], matrix(complex(5), nr=1L), msg = "RowVectorXcd::Zero(5)")
+ checkEquals( res[["rows : RowVectorX<T>"]][["Row<double>"]], matrix(numeric(5), nr=1L), msg = "RowVectorXd::Zero(5)")
+ checkEquals( res[["rows : RowVectorX<T>"]][["Row<float>"]], matrix(numeric(5), nr=1L), msg = "RowVectorXf::Zero(5)")
+ checkEquals( res[["rows : RowVectorX<T>"]][["Row<int>"]], matrix(integer(5), nr=1L), msg = "RowVectorXi::Zero(5)")
checkEquals( res[["columns : MatrixX<T>"]][["Col<complex>"]], as.matrix(complex(5)), msg = "MatrixXcd::Zero(5, 1)")
checkEquals( res[["columns : MatrixX<T>"]][["Col<double>"]], as.matrix(numeric(5)), msg = "MatrixXd::Zero(5, 1)")
More information about the Rcpp-commits
mailing list