Write a Gauss-Seidel preconditioner for ML
Show older comments
I am having trouble writing a Gauss-Seidel preconditioner for ML. It says "out of memory," ML is actually a vector of 44229 entries on the first column so its a (44229,1) size. A Gauss-Siedel preconditioner is the diagonal plus the lower, but here we only have a vector (ML). So now the G-S preconditioner is the values from ML along the diagonal surrounded by zeros. PLEASE HELP!
%Lumped mass matrix
for i=1:3
for j=1:3
% \int_E phi_i * phi_i dE = A/6 and % \int_E phi_i * phi_j dE = A/12
if(i==j)
ML(index(n,j)) = ML(index(n,j))+areas(n)/6;
else
ML(index(n,j)) = ML(index(n,j))+areas(n)/12;
end
end
end
% %%%%%%%%%%%%%%%%%%%%%%%%%%% M PRECONDITIONER
[g h] = size(ML);
D = diag(ML);
% b = zeros(g);
% M = D + b;
ML = D^-1.*ML;
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Answers (1)
John D'Errico
on 1 Apr 2023
Edited: John D'Errico
on 1 Apr 2023
Learn what a sparse matrix is. And how to build them, how to use them.
help sparse
help spdiags
The point being, you don't want to create a FULL matrix of that size. Instead, a diagonal matrix is better built as a sparse matrix.
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!