Rcpp: Matrix utility function ones, zeros, eye, ...

Created on 22 Oct 2016  路  3Comments  路  Source: RcppCore/Rcpp

There are a bunch of matrix construction helpers in typical Matrix packages such as Armadillo. We could add some:

  • ones(n) to fill a matrix of size n with ones (not sure if we need non-square size here)
  • zeros(n) similarly to fill with zeros
  • eye(n) to file a matrix of zeros along the diagonal.

We do have diag() as an extractor though.

Most helpful comment

I'm not sure if you wanted to add member and non-member versions of these functions, as is done with Armadillo, but I put something together to tackle (just) the latter case, and can submit a PR if you'd like to review.

All 3 comments

I'm not sure if you wanted to add member and non-member versions of these functions, as is done with Armadillo, but I put something together to tackle (just) the latter case, and can submit a PR if you'd like to review.

Simpler may well be better -- was thinking 'sugar' so non-member functions is my leaning too.

I think this has been fixed in #566 and #569

Was this page helpful?
0 / 5 - 0 ratings