Hello.
The purpose of my code is solving O.D.E. and in the function I need to do large matrix multiplication every single time step.
Therefore, almost all CPU time taken is consumed in this matrix multiplications.
I think mentioning every detail of my code is not necessary. So, only simplified code is uploaded as follows:
C = rand(10000, 5000); B = rand(10000, 1000); for i = 1:1000 A = rand(10000, 1); D = (A.*B)'*C; end
Here, B and C are constant matrix but A is changed in every single for loop. That's why I put A into a for loop. (I used function rand here just for a simple example) I've tried GPU, mex file, etc. But I have not been able to find the way which is faster than normal MATLAB .* or * operation. I think I can pre-calculate the value of the multiplication between B and C to avoid multiplying B to A and C to (A.*B) again. But I have no idea. Could you guys please help me?
(The matrix are defined as a sparse matrix in my actual code)
Best Answer