フィルターのクリア

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 Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by