Error calculating inverse for matrix block of LU decomposition of a full row rank matrix

4 ビュー (過去 30 日間)
I have the following code for calculating LU for sparse rectangular matrices with full row rank
rows = 100;
columns = 120;
A = sprand(rows,columns,0.1);
while rank(full(A))<rows %full row rank matrix
A=sprand(rows,columns,0.1);
end
[L,U,P1,P2] = sparseLU(A);
U1 = U(:,1:rows); % first m columns of U, square matrix of order m
U2 = U(:,rows+1:columns); % rest of the matrix U
X = inv(U1);
function [lower,upper,P1,P2] = sparseLU(sparseA)
[L,U,P,Q] = lu(sparseA); % P*A*Q = L*U
lower = L;
upper = U;
P1 = P;
P2 = Q;
end
Breaks down when calculating the matrix X, which has only NaN values. After using spy() on U1 I noticed that it has zero entries on the main diagonal, but I'm not sure how this can happen since LU uses full pivoting and A is full row rank. My goal is to calculate X.
Any help is welcome.

採用された回答

Bruno Luong
Bruno Luong 2024 年 3 月 17 日
編集済み: Bruno Luong 2024 年 3 月 17 日
It's a little bit perturbant, but reading the lu doc I don't see why U1 must have the same rank than U (or A, meaning 100 on your example). Therefore there is no reason to expect that the diagonal of U have all non zero elements.
The full rank occurs if you swap one of the column of U2 with the column of U1 that has 0 on the main diagonal.
  1 件のコメント
weyronndsb000
weyronndsb000 2024 年 3 月 17 日
After perfoming LU I swapped the zero diagonal entries with non zero ones from the right side of the matrix while swapping the columns of the permutation matrix P2 on your advice using a while loop and now I have all non zeros on the main diagonal, thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by