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

Comments

Projects
None yet
3 participants
@romainfrancois
Contributor

romainfrancois commented Oct 1, 2018

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

This comment has been minimized.

Contributor

romainfrancois commented Oct 1, 2018

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

This comment has been minimized.

Contributor

kevinushey commented Oct 1, 2018

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

This comment has been minimized.

Contributor

romainfrancois commented Oct 1, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

kevinushey commented Oct 1, 2018

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

@eddelbuettel

This comment has been minimized.

Member

eddelbuettel commented Oct 1, 2018

And making sure it passes tests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment