Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Bruno Luong
Bruno Luong il 17 Mar 2024
Modificato: Bruno Luong il 17 Mar 2024
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 Commento
weyronndsb000
weyronndsb000 il 17 Mar 2024
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Operating on Diagonal Matrices in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by