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

Efficient elementwise operations? #1

Open
dhicks opened this issue Aug 14, 2022 · 0 comments
Open

Efficient elementwise operations? #1

dhicks opened this issue Aug 14, 2022 · 0 comments

Comments

@dhicks
Copy link

dhicks commented Aug 14, 2022

Context: I'm trying to use bigalgebra to calculate Hellinger distance on matrices of discrete probability distributions.

To do this calculation, I need to calculate elementwise square roots and do an elementwise subtraction 1 - X. I can't seem to find any way to do the elementwise square root without dropping back to standard matrices. For the elementwise subtraction, I can create a matrix of 1s as

ones = matrix(1, nrow = n, ncol = n) |>
    as.big.matrix()

But creating this matrix is surprisingly slow (about 3 times slower than a $n \times k$ by $k \times n$ multiplication) and seems to introduce a bunch of memory overhead that isn't cleaned up by automatic garbage collection. Then the elementwise difference using daxpy() is also surprisingly slow, taking more than twice as long as creating ones.

MWE attached. Thanks in advance for any suggestions!

bigmemory.R.zip

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

1 participant