Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix(no_init()) #907

Closed
romainfrancois opened this issue Oct 1, 2018 · 6 comments
Closed

Matrix(no_init()) #907

romainfrancois opened this issue Oct 1, 2018 · 6 comments

Comments

@romainfrancois
Copy link
Contributor

The constructor does not set nrows. https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/vector/Matrix.h#L92

    explicit Matrix( const no_init_matrix& obj) {
        VECTOR::set__( Rf_allocMatrix( RTYPE, obj.nrow(), obj.ncol() ) );
    }

I have a patch that I'll submit as a pull request.

romainfrancois added a commit to tidyverse/dplyr that referenced this issue Oct 1, 2018
romainfrancois added a commit to tidyverse/dplyr that referenced this issue Oct 1, 2018
@romainfrancois
Copy link
Contributor Author

Is a thumbs up reaction enough green light to send the pull request ?

romainfrancois added a commit to tidyverse/dplyr that referenced this issue Oct 1, 2018
@kevinushey
Copy link
Contributor

Do you recall why we maintain nrows as a variable separate to what's already defined as part of the dims attribute? Just for efficiency in lookup?

@romainfrancois
Copy link
Contributor Author

IIRC this was about performance, i.e. implementing the ( operator so that we can cheaply go from i, j to the underlying vector index.

@eddelbuettel
Copy link
Member

eddelbuettel commented Oct 1, 2018

I always liked how Armadillo exports this as read-only variables rather than calls: http://arma.sourceforge.net/docs.html#attributes

Ours did come earlier, and I think it was indeed the performance / easy of use consideration.

romainfrancois added a commit to tidyverse/dplyr that referenced this issue Oct 1, 2018
@kevinushey
Copy link
Contributor

Sounds good. Either way this definitely warrants a patch; thanks for taking the time to prepare one.

@eddelbuettel
Copy link
Member

And making sure it passes tests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants