On Tue, Jun 13, 2017 at 10:56 AM Binxiang Ni <binxian...@gmail.com> wrote:

> Hi,
>
> I am working on fixing sparse matrix conversion for RcppArmadillo. Now a
> problem comes up to me: what kind of sparse matrix is expected to pass from
> Armadillo to R? That is, what should the result of wrap() be? dgCMatrix(if
> logical, lgCMatrix or ngCMatrix)  or their original type?
>

What do you mean by "their original type"?

It seems that the correspondence is
Armadillo           Matrix package
sp_mat       <=> dgCMatrix
sp_cx_mat <=> zgCMatrix
sp_imat      <=> igCMatrix

After that you are going to need to convert the values vector in the
Armadillo representation to a datatype available in R.  (In fact there is
always an implicit conversion because the rowind and colptr vectors are
unsigned integers in Armadillo and integers in R.  However that change is
just a cast of a pointer.)

I wouldn't worry about the logical values because LOGICAL in R is just a
32-bit integer.  ngCMatrix in R is a pattern matrix which only stores the
positions of the non-zeros, not their values.  These are used in the
symbolic phase of many sparse matrix operations, particularly
decompositions.  The symbolic phase only uses the pattern of nonzeros.  It
doesn't appear that there is a corresponding type in Armadillo.
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to