Efficient way to perform loops of matrix multiplications
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have an implementation that involves multiplying matrices, summing them up, and storing them. It goes like this,
A = 0;
for i=1:1225
% Load operator A_i of size NxN
A_i = load('A_i.mat');
% z_i is some variable of size Nx1 that I compute in this loop
% x is some variable of size Nx1 calculated above this loop
% I have to perform some operations like these two
y_i = A_i*(z_i + x);
A = A + A_i*A_i'
end
My problem is the large amount of simulation time being consumed by the above code. Even when the operations inside the loop are efficient (let's say ~0.01mins), the entire looped implementation still consumes about ~12-13mins. Can somebody please help me out and suggest an efficient way to do this? Thanks so much!
7 Kommentare
David Goodmanson
am 27 Jan. 2018
Hi AA,
If N stays constant, when you compute them offline could you stack them into sets of 3d arrays, no one of which is large enough to overrun RAM? That way you would have to load stuff a lot less often.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!