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

diag function #88

Open
cdeterman opened this issue Sep 24, 2018 · 2 comments
Open

diag function #88

cdeterman opened this issue Sep 24, 2018 · 2 comments

Comments

@cdeterman
Copy link
Contributor

In reference to the SO question here perhaps it would be a good idea to implement the diag function in bigmemory? Given that it is just a way of accessing the elements within the matrix I think it is most appropriate for it to be within bigmemory. The question would just come down to do we want to simply provide a wrapper using the special matrix accessor, as provided in @privefl answer, or would it be better to implement in C++?

Thoughts?

@privefl
Copy link
Contributor

privefl commented Sep 24, 2018

Implementing it in C++ would require a dispatcher.
It is just two lines of (efficient) R code:

seq_d <- seq_len(min(dim(X)))
X[cbind(seq_d, seq_d)]

So, I think it would not be worth it..

@cdeterman
Copy link
Contributor Author

@privefl That is perfectly fine with me. The only thing I am suggesting is wrapping those lines in a diag method so a user can simply call

diag(big_mat)

It is simply more convenient and expected with matrix operations. Either as an S4 or S3 method I don't think matters too much in this case. At least that is my two cents.

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

2 participants