Efficient way to perform loops of matrix multiplications
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
David Goodmanson
el 27 de En. de 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.
Respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!