Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Bruno Luong
Bruno Luong el 17 de Mzo. de 2024
Editada: Bruno Luong el 17 de Mzo. de 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 comentario
weyronndsb000
weyronndsb000 el 17 de Mzo. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by