I am currently working on a real-time implementation of a finite-element method solver which requires large matrix operations.
I encountered the following issue:
In my code, I need to perform addition of two matrices which are both M x M where M has minimum value of 5000. I know that the second matrix is a diagonal matrix.
So, for example code snippet like this
M = 5000;
A = randn(M, M);
B = eye(M);
C = A + B;
Unfortunately, this operation costs between 50 ms and 70 ms of speed, which is a lot in my application.
I also tried to only manipulate only the diagonal indices but in terms of timing there was no real improvement.
Is there any way of improving this in terms of speed?
Thanks and best regards,