Prev: Radial Basis Function Neural Network Tool Box
Next: show to save a matlab generated image to specific location in
From: Franz-Josef on 23 May 2010 04:15 Hello everybody! My question is about sparse matrices. For my FE-Program, written in Matlab, I want to set values of certain columns and rows of a sparse matrix zero. For example: K(c,:) = 0, where c is a vector. If K is a full matrix, this operation takes only a second for matrix sizes up to 10000. If K is a sparse matrix this operation takes over one hour! What possibilities exist, to speed up this operation with sparse matrices? Thanks a lot for your suggestions! FJ
From: James Tursa on 23 May 2010 05:26 "Franz-Josef " <franz.falkner(a)uibk.ac.at> wrote in message <htao72$etb$1(a)fred.mathworks.com>... > Hello everybody! > My question is about sparse matrices. > For my FE-Program, written in Matlab, I want to set values of > certain columns and rows of a sparse matrix zero. For example: > K(c,:) = 0, where c is a vector. If K is a full matrix, this operation > takes only a second for matrix sizes up to 10000. If K is a sparse > matrix this operation takes over one hour! > What possibilities exist, to speed up this operation with sparse matrices? > Thanks a lot for your suggestions! > FJ What version of MATLAB are you using & what system are you running on? James Tursa
From: Loren Shure on 25 May 2010 13:09 In article <htao72$etb$1(a)fred.mathworks.com>, franz.falkner(a)uibk.ac.at says... > Hello everybody! > My question is about sparse matrices. > For my FE-Program, written in Matlab, I want to set values of > certain columns and rows of a sparse matrix zero. For example: > K(c,:) = 0, where c is a vector. If K is a full matrix, this operation > takes only a second for matrix sizes up to 10000. If K is a sparse > matrix this operation takes over one hour! > What possibilities exist, to speed up this operation with sparse matrices? > Thanks a lot for your suggestions! > FJ > Because of the way sparse matrices are stored (see info in doc), you are far better off speed-wise working with columns instead of rows. Perhaps that will work for you, but I can't tell. -- Loren http://blogs.mathworks.com/loren http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Tim Davis on 27 May 2010 19:40 "Franz-Josef " <franz.falkner(a)uibk.ac.at> wrote in message <htao72$etb$1(a)fred.mathworks.com>... > Hello everybody! > My question is about sparse matrices. > For my FE-Program, written in Matlab, I want to set values of > certain columns and rows of a sparse matrix zero. For example: > K(c,:) = 0, where c is a vector. If K is a full matrix, this operation > takes only a second for matrix sizes up to 10000. If K is a sparse > matrix this operation takes over one hour! > What possibilities exist, to speed up this operation with sparse matrices? > Thanks a lot for your suggestions! > FJ Try this instead: K=K' ; K(:,c) = 0; K=K' ; See http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/ for details.
From: James Tursa on 28 May 2010 02:30
"Franz-Josef " <franz.falkner(a)uibk.ac.at> wrote in message <htao72$etb$1(a)fred.mathworks.com>... > Hello everybody! > My question is about sparse matrices. > For my FE-Program, written in Matlab, I want to set values of > certain columns and rows of a sparse matrix zero. For example: > K(c,:) = 0, where c is a vector. If K is a full matrix, this operation > takes only a second for matrix sizes up to 10000. If K is a sparse > matrix this operation takes over one hour! > What possibilities exist, to speed up this operation with sparse matrices? > Thanks a lot for your suggestions! > FJ Can you give more details about the exact size and sparsity of your K matrix? I have tried 100MB matrices built with sprand and it only takes a couple of seconds to zero out a single row, and a few 10's of seconds to zero out 1000 rows. How big is your c vector? James Tursa |