<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Jun 13, 2017 at 10:56 AM Binxiang Ni <<a href="mailto:binxiangni@gmail.com">binxiangni@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>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?</div></div></blockquote><div><br></div><div>What do you mean by "their original type"?</div><div><br></div><div>It seems that the correspondence is</div><div>Armadillo           Matrix package</div><div>sp_mat       <=> dgCMatrix</div><div>sp_cx_mat <=> zgCMatrix</div><div>sp_imat      <=> igCMatrix</div><div><br></div><div>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.)<br></div><div><br></div><div>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.</div></div></div>