How to accelerate matrix calculation with matlab?
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have 40800 linear sparse equations that have the following forms:
F(1)=2*x(1)+x(2)-10;
F(2)=x(9)+3*x(10)-7;......
F(40800)=x(40200)-x(1)+....-10;
I want to convert these equations to matrices by evaluating them at the columns of speye(N);
N=40200; %the number of variables
E=speye(N,N+1);
columns=cell(1,N);
beq=-evaluate_equations(E(:,N+1));
for i=1:N
columns{i}=evaluate_equations(E(:,i))+ beq;
end
Aeq=cell2mat(columns);
full(Aeq),
full(beq),
function F=evaluate_equations(x)
F(1)=2*x(1)+x(2)-10;
F(2)=x(9)+3*x(10)-7;......
F(40800)=x(40200)-x(1)+....-10;
F=F(:); %column vector
But Matlab is very slow. It can not build the matrices. However i use 8 workers to accelerate the computing. Have you an idea to overcome this problem? Thanks.
0 Commenti
Risposte (1)
Walter Roberson
il 7 Gen 2014
If they are sparse linear equations, could you not code them as a matrix multiplication in the first place? If you did that you could also skip the "for i" loop and do it as a single matrix multiplication.
4 Commenti
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!