필터 지우기
필터 지우기

deleting row and column from very large Sparse matrix efficiently

조회 수: 14 (최근 30일)
amit
amit 2014년 11월 25일
답변: Zhuoran Han 2021년 1월 1일
dear frnds
I am performing the following operation for deleting row and column from very large *Sparse* stiffness (K) matrix
K(doft,:) = 0;
K(:,doft) = 0;
K(doft,doft) = speye(length(doft));
but it taking lots of time as indexing of sparse matrix is very slow. would you please suggest me the better option to do it efficiently.
Thanks in advance

답변 (1개)

Zhuoran Han
Zhuoran Han 2021년 1월 1일
This is an easy way to deal with boundary conditions in stiffness matrices, have you tried permutation?
Suppose your original matrix is A = [a b c; d e f; g h i], and your desired matrix is B = [a 0 c; 0 1 0; g 0 i], you can try to break A into 9 peices from a to i (all matrices instead of numbers), and concatenate them together. [] is quite fast with sparse matrices. If you want the upper left 100x100 from a 1000x1000 matrix, use A(1:100,1:100) similar to permutation.
Another idea might be faster, you reorder (permute) the entire matrix and move the "doft" rows and cols to lower right, and use A(1:900,1:900) to extract the entire upper left matrix, and then blkdiag with speye(100). blkdiag is very fast with sparse matices. Finally, try to back-permute the entire matrix.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by