<div dir="ltr"><div><div>A pretty nice feature of Eigen is that it allows you to map an existing memory address to an Eigen object, so the data stored in R can be directly reused by Eigen. This may be the key point if we want to avoid copying data from R to Eigen/Armadillo. Dirk, does Armadillo has such kind of constructor to receive a pointer as input to initialize a vector or matrix?<br>
<br>Currently RcppEigen supports direct conversion from dgCMatrix, the column-oriented sparse matrix class in the Matrix package. After you finish the conversion, you can make use of all the fancy stuffs on sparse matrices provided by Eigen, including basic arithmetic operations, linear algebra solvers and matrix factorizations. It really helped me a lot when developing rARPACK. Thank you Doug and Dirk. :-)<br>
<br><br><br></div>Best,<br></div>Yixuan<br><div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-03 Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
On 3 February 2014 at 12:59, Douglas Bates wrote:<br>
| On Mon, Feb 3, 2014 at 11:48 AM, Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br>
|<br>
|<br>
|     On 3 February 2014 at 10:23, French, Joshua wrote:<br>
|     | Soren and Doug,<br>
|     |<br>
|     | Thanks for the info about the sparse matrices.  I'll give it a go and<br>
|     seen what<br>
|     | happens.  If it works out, then perhaps I'll be able to provide a nice<br>
|     | RcppGallery example.<br>
|<br>
|     Yes -- there isn't much yet in RcppArmadillo but this is expected to<br>
|     grow. And CRAN now has rARPACK so we get cheaply to the object code too.<br>
|<br>
|     One last comment I should have made earlier: "dense" data from R comes over<br>
|     cheaply as a SEXP; "sparse" will always require a copy.  Keep that in<br>
|     mind,<br>
|     and on the margin don't believe anything any of us say but keep profiling<br>
|     and<br>
|     measuring :)<br>
|<br>
|<br>
| Not really.  RcppEigen offers conversion of SEXPs to Eigen::SparseMatrix and<br>
| Eigen::MappedSparseMatrix types.  The second uses the storage from R without<br>
| copying and hence should generally be declared with the const modifier.<br>
<br>
</div></div>Oooops. My bad.<br>
<br>
I guess I generalized from my less performing converters contributed to<br>
RcppArmadillo. Time permitting, maybe I should have another look at RcppEigen<br>
and see if I can do better for RcppArmadillo.<br>
<div class="im"><br>
| I think that wonderful vignetter by Bates and Eddelbuettel describes this :-)<br>
<br>
</div>:-)<br>
<div class="HOEnZb"><div class="h5"><br>
Dirk<br>
<br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Yixuan Qiu <<a href="mailto:yixuan.qiu@cos.name" target="_blank">yixuan.qiu@cos.name</a>><br>Department of Statistics,<br>Purdue University<br>
</div>