Some functions for matrix math in JS using TypedArrays