From: Marios Karaoulis on 4 Jun 2010 14:19 Hi, I have a large matrix like k(20000,200000). It is always square, symmetric and have tons of zeros (so i can make it sparse). this is part of the program %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for e=1:large_number I=icon(1,e); J=icon(2,e); L=icon(3,e); %%%%%%%%%%%%%%%%%%%%%%%%%%% ke=[1 2 3;2 8 4;3 4 9]; %symmetric matrix, changes in every loop %%%%%%%%%%%%%%%% % Add [K^e] to [K] for i=1:3 for j=1:3 k(icon(i,e),icon(j,e))=k(icon(i,e),icon(j,e))+ke(i,j); end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if in my code i write k=zeros(20000,20000) then I get out of memory if i use k=sparse(20000,20000), it takes forever to finish. I am thinking of 2 solutions 1) Since I know that k is symmetric, is any advise to store it using a bandwidth technique (like Cuthill-McKee)? I have found a good example in c which I can use (burnett, finite element theory), but then I need the decomposition of this matrix. In this book, there is a modified gaus-jordan elimination, but if I write this algorithm in matlab it takes forever to calculate. 2) I am trying to store in every iteration the indexes of the matrix like %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tmp1=1; for e=1:large_number I=icon(1,e); J=icon(2,e); L=icon(3,e); %%%%%%%%%%%%%%%%%%%%%%%%%%% ke=[1 2 3;2 8 4;3 4 9]; %symmetric matrix, changes in every loop %%%%%%%%%%%%%%%% % Add [K^e] to [K] for i=1:3 for j=1:3 index1(tmp1)=icon(i,e); index2(tmp1)=icon(j,e); val(tmp1)=ke(i,j); tmp1=tmp1+1; end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% how can I now create the sparse matrix k? k=sparse(index1,index2,val,20000,20000); This way in every element in, it will just store a value. I want to store the value it has plus the value it already has. Any suggestions?
|
Pages: 1 Prev: 3-D Plot Movie Next: plot output from two for-loops in log-log scale |