Extract data from sparse matrix in a parfor loop

3 次查看(过去 30 天)
Hi, I need to find eigenvectors and eigenvalues for a lot of 100*100 tri-diagonal matrices. they defined as follow:
A_kk = a_n ; % main diagonal (a_n is some vector)
A_kk_below = b_n*f; %below main diagonal (b_n is some vector, and f is a number which differ at each matrix)
A_kk_above = c_n*f; %above main diagonal (c_n is some vector, and f is a number which differ at each matrix)
I'm looking for a fast way to do it so my strategy was to define a large large tridiagonal sparse matrix. Then inside a parfor loop to take part of the sparse matrix and calculate its eigenvectors/values
N=100;
Len_f=100;
a_ln_t=zeros(N,N,Len_f);
parfor i=1:Len_f
A_f = full(A((i-1)*N+(1:N),(i-1)*N+(1:N))); % take part of the sparse matrix A
[EigV,Eig] = eig(A_f,'vector'); % find eigenvectors/values
[Eig,iEig] = sort(Eig); % sort eigenvalues
EigV = EigV(:,iEig); % sort eigenvectors
Eig_f(:,:,i) = EigV; % save results in variable
end
But the problem is that I get a warning when trying to take part of the sparse matrix.
"The entire array or structure "A" is a broadcast variable. This might result in unnecessary communication overhead"
Is there any suggestions on how to avoid this warning and improve this code and perhaps make it faster?
Any input on this matter would be highly appreciated

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by