I recently ran a benchmark comparing the performance math commons 3.6.1's
linear algebra library to the that of scala Breeze (
https://github.com/scalanlp/breeze).
I looked at det, inverse, Cholesky factorization, addition, and
multiplication, including matrices with 10, 100, 500, and 1000 elements,
with symmetric, nonsymmetric, and nonsquare cases where applicable.
In general, I was pleasantly surprised: math commons performed about as
well as Breeze, despite the latter relying on native libraries. There was
one exception, however:
m0.multiply(m1)
where m0 and m1 are both Array2DRowRealMatrix instances. It scaled very
poorly in math commons, being much slower than nominally more expensive
operations like inv and the Breeze implementation. Does anyone have a
thought as to what's going on? In case it's useful, one representative test
involves multiplying two instances of
new Array2DRowRealMatrix(matVals)
where matVals is 1000x1000 entries of math.random and the second instance
is created as part of the loop. This part of the benchmark is not specific
to the expensive multiplication step, and takes very little time relative
to the multiplication itself. I'm using System.nanotime for the timing, and
take the average time over several consecutive iterations, on a 3.5 GHz
Intel Core i7, Oracle JRE (build 1.8.0_05b13).
Thanks,
Chris
