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.
This adds some additional functionality for matrix multiplication.
First, it adds
crossprod
andtcrossprod
, 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 ofmtimes
, the main reason to use them is because they have specializations for BLAS functions where they are appropriate. Where I include calls tomtimes
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)
wherea
is one-dimensional andb
is two-dimensional, usemtimes
in that case).Second, it adds
quadraticForm
andquadraticFormSymmetric
, which implement the call toa' * b * a
whereb
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 tomtimes
andmtimesSymmetric
without an attempt to avoid allocations.