[Rcpp-devel] Sparse matrix operations

Søren Højsgaard sorenh at math.aau.dk
Tue Feb 4 10:30:13 CET 2014

Just to clarify this (for myself): 

In a broader perspective, isn't it so now that there is very limited need for as< >(some_SEXP)? 

When calling from R we can declare input to be NumericMatrices, NumericVectors ets, but we can also declare it to be arma-matrices, arma-vectors etc AND also Eigen-matrices etc?

Where one definitely needs as< >() is when inputting some SEXP which one wants to coerce to some STL container? 

Are there other cases where one definitely needs the coercion via as<>()??


-----Original Message-----
From: Dirk Eddelbuettel [mailto:edd at debian.org] 
Sent: 3. februar 2014 20:20
To: Douglas Bates
Cc: Dirk Eddelbuettel; French, Joshua; Søren Højsgaard; rcpp-devel at lists.r-forge.r-project.org
Subject: Re: [Rcpp-devel] Sparse matrix operations

On 3 February 2014 at 12:59, Douglas Bates wrote:
| On Mon, Feb 3, 2014 at 11:48 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
|     On 3 February 2014 at 10:23, French, Joshua wrote:
|     | Soren and Doug,
|     |
|     | Thanks for the info about the sparse matrices.  I'll give it a go and
|     seen what
|     | happens.  If it works out, then perhaps I'll be able to provide a nice
|     | RcppGallery example.
|     Yes -- there isn't much yet in RcppArmadillo but this is expected to
|     grow. And CRAN now has rARPACK so we get cheaply to the object code too.
|     One last comment I should have made earlier: "dense" data from R comes over
|     cheaply as a SEXP; "sparse" will always require a copy.  Keep that in
|     mind,
|     and on the margin don't believe anything any of us say but keep profiling
|     and
|     measuring :)
| Not really.  RcppEigen offers conversion of SEXPs to 
| Eigen::SparseMatrix and Eigen::MappedSparseMatrix types.  The second 
| uses the storage from R without copying and hence should generally be declared with the const modifier.

Oooops. My bad.

I guess I generalized from my less performing converters contributed to RcppArmadillo. Time permitting, maybe I should have another look at RcppEigen and see if I can do better for RcppArmadillo.

| I think that wonderful vignetter by Bates and Eddelbuettel describes 
| this :-)



Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com

More information about the Rcpp-devel mailing list