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

Improve function efficiency through matrix algebra #11

Closed
Rekyt opened this issue Dec 15, 2020 · 3 comments
Closed

Improve function efficiency through matrix algebra #11

Rekyt opened this issue Dec 15, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@Rekyt
Copy link
Member

Rekyt commented Dec 15, 2020

I'm pretty sure that the call to apply() in fd_raoq() could be simplified through matrix algebra:
https://github.com/Bisaloo/fundiversity/blob/1e175ba88531e08242ab9c69b9e470b4cee9e759/R/fd_raoq.R#L60-L62

@Rekyt Rekyt added the enhancement New feature or request label Dec 15, 2020
@Bisaloo
Copy link
Collaborator

Bisaloo commented Dec 15, 2020

diag(sp_com %*% tcrossprod(dist_matrix, sp_com))

Now, an interesting question is trying to understand what values outside of the diagonal mean 🤔

@Bisaloo
Copy link
Collaborator

Bisaloo commented Dec 16, 2020

expr min lq mean median uq max neval
fd_raoq(traits = traits_birds, sp_com = site_sp_birds) 1.119820 1.167955 1.577048 1.207574 1.300485 8.713098 1000
fd_raoq_old(traits = traits_birds, sp_com = site_sp_birds) 2.045435 2.100812 3.159528 2.160546 2.357134 100.263167 1000

@Bisaloo
Copy link
Collaborator

Bisaloo commented Dec 16, 2020

Fixed by 5240f08.

@Bisaloo Bisaloo closed this as completed Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants