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

Add crossprod, tcrossprod, and quadraticForm functionality #53

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

jmh530
Copy link
Contributor

@jmh530 jmh530 commented Aug 30, 2023

This adds some additional functionality for matrix multiplication.

First, it adds crossprod and tcrossprod, which are very similar to R's versions of these functions (https://stat.ethz.ch/R-manual/R-devel/library/base/html/crossprod.html). While there are some cases where this mimics the behavior of mtimes, the main reason to use them is because they have specializations for BLAS functions where they are appropriate. Where I include calls to mtimes it is mainly so that the functions can be used somewhat seamlessly (Note: I left off versions of these functions where the calls are mixed, so for instance, crossprod(a, b) where a is one-dimensional and b is two-dimensional, use mtimes in that case).

Second, it adds quadraticForm and quadraticFormSymmetric, which implement the call to a' * b * a where b is a general matrix or a symmetric matrix, respectively. This calculation can show up all over the place and can be useful to make it into a function to avoid repeating oneself. I implemented these functions somewhat naively with calls to mtimes and mtimesSymmetric without an attempt to avoid allocations.

@jmh530
Copy link
Contributor Author

jmh530 commented Sep 14, 2023

@9il This is able to be reviewed when you have time.

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

Successfully merging this pull request may close these issues.

1 participant