Added Exporter and Unit Test for Map::RowVectorX<t> #32

Merged
merged 4 commits into from Apr 29, 2016

Projects

None yet

3 participants

@coatless coatless changed the title from Added Exporters and Unit Test for RowVectorXd to Added Exporters and Unit Test for RowVectorX<t> Apr 28, 2016
@eddelbuettel
Member

Thanks, James -- that is very helpful (and very fast). Paging @yixuan to take a peek too but I guess we should be able to fold this in.

@coatless coatless changed the title from Added Exporters and Unit Test for RowVectorX<t> to Added Exporter and Unit Test for Map::RowVectorX<t> Apr 28, 2016
@yixuan
Contributor
yixuan commented Apr 29, 2016

It looks pretty nice, thank you @coatless !

Could you please also convert tab to 4 spaces in RcppEigenWrap.h and make the indentation consistent with the context in runit.RcppEigen.R? (It is tiny issue but would be nice of you to do so.)

@eddelbuettel
Member

Good point tabs (I tend to avoid them) and four spaces. The Rcpp repo has some emacs config, it needed.

@coatless
Contributor

@yixuan done.

@eddelbuettel eddelbuettel commented on the diff Apr 29, 2016
inst/include/RcppEigenWrap.h
@@ -217,6 +217,21 @@ namespace Rcpp{
OUT get() {return OUT(vec.begin(), vec.size());}
} ;
+ // Provides only Map::RowVectorX<t> export
+ template<typename T>
+ class Exporter<Eigen::Map<Eigen::Matrix<T, 1, Eigen::Dynamic> > > {
+ typedef typename Eigen::Map<Eigen::Matrix<T, 1, Eigen::Dynamic> > OUT ;
+ const static int RTYPE = ::Rcpp::traits::r_sexptype_traits<T>::rtype ;
+ Rcpp::Vector<RTYPE> vec ;
+
+ public:
+ Exporter(SEXP x) : vec(x) {
+ if (TYPEOF(x) != RTYPE)
+ throw std::invalid_argument("Wrong R type for mapped rowvector");
+ }
+ OUT get() {return OUT(vec.begin(), vec.size());}
+ } ;
+
@eddelbuettel
eddelbuettel Apr 29, 2016 Member

That whole block is two-space-intended (after the initial four) but c'est la vie now, we'll get it next time or maybe I'll fix it tomorrow.

@eddelbuettel eddelbuettel merged commit 3948d5c into RcppCore:master Apr 29, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment