[Rcpp-devel] iterator for sparse Matrix
saurabh.writes at gmail.com
Thu Jan 23 02:21:53 CET 2014
Apologies, I will break it down and tackle one thing at a time...
On Wed, Jan 22, 2014 at 8:13 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
> On 22 January 2014 at 18:04, Saurabh B wrote:
> | I am running into many issues. Here they are ranked in order of
> importance) -
> | 1) When I run this (incorrect) program -
> | stochDescCpp(param = rep(0,3), x = X, y = Y, maxit = 100)
> | I get -
> | Error in .Primitive(".Call")(<pointer: 0x0000000069d42560>, param, x, :
> | negative length vectors are not allowed
> | All the inputs are valid and work fine with the R version. So I don't
> | where this is coming from? I put a bunch of couts and I know that it is
> | happening inside the for loop but don't know why. In general, what is
> the best
> | way to debug code written this way? I am using RStudio.
> | 2) I don't know how to transpose the matrix in rCpp. I read that I could
> | using rCppArmadillo, but then I don't know how to convert from
> NumericMatrix to
> | arma matrix. I don't want to copy as this operation will happen 1000x of
> | so this has to be fast.
> | 3) I don't know how to randomly shuffle the rows. I tried RcppArmadillo::
> | sample but haven't gotten the output to work. E.g. do I access elements
> as x
> | (rowOrd[curIdx],_)?
> | 4) (minor issue) How do I add the bias unit? In other words, add a new
> | to the input matrix filled with all 1s. Do I have to create a new
> matrix, copy
> | it column by column? this is not a dealbreaker since I can do this in R
> | I send in the inputs.
> | Sorry if my questions are too basic and don't seem well researched. I am
> | to go for a practical example.
> You are trying too much at once. Attack each issue separately. Some of what
> you are after is basic, and there are plenty of examples for RcppArmadillo
> out there -- not to mention over 50 CRAN packages using it. It will help
> to study some of those.
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rcpp-devel