ode4j icon indicating copy to clipboard operation
ode4j copied to clipboard

Look into using a library for matrix math

Open tzaeschke opened this issue 12 years ago • 4 comments
trafficstars

MTJ/MTJ-n: https://github.com/fommil/matrix-toolkits-java

EJML: http://code.google.com/p/efficient-java-matrix-library/

Comparison: https://code.google.com/p/java-matrix-benchmark/wiki/RuntimeCorei7v2600_2013_10

Also, any inclusion of such libraries should consider that ODE partly takes special precautions to improve mathematical instability.

tzaeschke avatar Oct 31 '13 11:10 tzaeschke

Big ODE4j fan here. I'm using jBLAS for matrix math in some projects that link to ODE4j. However, I haven't done any speed tests against MTJ.

kephale avatar Oct 31 '13 13:10 kephale

Hey, good to hear there are some fans :-), I get very little feedback. I just updated the title and issue text. I got the MTJ/EJML suggestion from another ode4j user. According to the comparison above, EJML is best for small matrices and MTJ-n is best for larger ones. EJML appears to be faster than jBLAS for matrices of all sizes.

Of course, I guess it depends on which operations would actually be used.

MTJ also appears to be based on BLAS.

Anyway, this migration won't be happening anytime soon, unless there are volunteers?

tzaeschke avatar Oct 31 '13 16:10 tzaeschke

Alright, I'll think about volunteering, but can't promise anything at the moment. I'm back to considering this issue for some of my own code.

It is a shame MTJ seems to do so poorly on small matrices. I'm taking hits from rotation ops and solving large matrix systems. That being said, I guess I'm sold on EJML for speeding up my rotations. So my vote goes for EJML.

I wonder if it would be possible to cheaply and dynamically transition between the two libraries during runtime...

[Actually, I may retract my vote for now. Rotations aren't a good enough reason, since they really should probably just be unrolled anyway.]

kephale avatar Nov 02 '13 16:11 kephale

Indeed, most of the 1x3, 1x4, 3x3, 3x4 and 4x4 operations are already unrolled.

ghost avatar Nov 02 '13 16:11 ghost