This SUCKS balls! I was at school today, trying to run my NMF algorithm on a 4MB image file. I started running the test around 12pm – it was chugging along happily as I was working on my Programming Languages homework (which is crazy btw).

I left at 6, and my program was still running. That’s 6 hours and counting. What’s funny is that Dr. Robila implemented the same algo in Matlab and it processed the very same image in under 5 minutes. Aaaagh!

Of course you need to take into consideration that in Matlab matrix multiplication, or a transpose is accomplished with a single operator. This means that there are years of tweaking, and anal optimization behind each of these. I’m doing all of this using loops, and my data is stored in Java’s DataBuffers. This means that every access is a function call.

I’m thinking about optimizing this using arrays. I will have to look into how much faster is it to access an element of a multidimensional array, as opposed to accessing an element of a DataBuffer. Perhaps it is not even worth bothering, as Java arrays are sort-of-objects anyway.

If that damn JDS machine freezes before finishing this 6+ hour run, I will take a fucking baseball bat to it or something :P I better see some results tomorrow!

Have you tried using one of the matrix libraries for Java? JAMA and Colt are not very fast, but ojAlgo, EJML, UJMP and Parallel Colt have good performance for matrix multiplication and transpose.

Hope this helps!

man MATLAB is best thing in the planet i love matlab

Have you tried JAMA? or octave or scilab? in case matlab is too expensive… Right now I’m actually trying to do a NMF by multiplicative updates to a 2500 x 1000 matrix using JAMA, I just have a little problem I’m trying to solve.