Fast 4x4 matrix multiplication in Java with NIO float buffers?

The real answer is of course to test different implementations and check which one is fastest.

The real answer is of course to test different implementations and check which one is fastest. My guess, without testing, would be that as the matrices are so small, expanding the loops by hand would result in the fastest code. E.g.

Something like result00 = this00 * matrix200 + this01 * matrix210 + this02 * matrix220 + this03 * matrix230; result01 = // ... and so forth or then maybe just unroll the innermost loop, and retain the two outermost ones to save some typing as well as I$.

Note that the JIT compiler is quite good at unrolling loops where necessary, so you might find there's not much in it. – Neil Coffey May 9 '10 at 17:35.

Go through the FloatBuffer.array() if that operation is supported. Then just perform the necessary multiplications through that array, and return the resulting matrix. Have a look at GameDev.Net - Matrix Math for the exact computations.

If you want to optimize it further, you could try out Strassens Algorithm. You wouldn't even need to pad your matrices, since they are square and of a size that is a power of 2.

1 As the wikipedia article on Strassen says: "Practical implementations of Strassen's algorithm switch to standard methods of matrix multiplication for small enough submatrices, for which they are more efficient. The particular crossover point for which Strassen's algorithm is more efficient depends on the specific implementation and hardware. It has been estimated that Strassen's algorithm is faster for matrices with widths from 32 to 128 for optimized implementations." – janneb May 9 '10 at 12:38 Good point.

Thanks! – aioobe May 9 '10 at 12:39.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions