flatmat.js is a
library of fast linear algebra functions. API description & speed tests below.
2-D matrices are stored flat: as
1-D arrays of numbers.
Most code is automatically generated for performance (see
Comparison with a hand-written loop implementation.
Comparison with an implementation for matrices stored as 2-D arrays.
As of 2017-02-23 2-D arrays had roughly 2 times the speed of the 1-D flatmat implementation (just above). Not good? On the other hand, for matrix multiplication (and xvmxv) 1-D goes ca 5 to 10 times faster. So there is a tradeoff, depending on the type of application.
Comparison with an implementation directly in 1-D.
(x-V)^T * M * (x-V)
Measure the speed of the product
(x-V)^T * M * (x-V) where
V are vectors, and
M a square matrix. This is useful when computing the exponent term in a Gaussian probability density function.
Comparison with a hand-written implementation (loops).
The source files used for the tests. Also browsable on GitHub