cantgetno197
cantgetno197

Reputation: 11

How to do LDL decomposition when all I have is an LU solver that always applies pivoting?

I'm hoping I'm just missing a simple trick of matrix arithmetic, but the issue I'm having is that all I have access to is an LU solver (Matlab LU* or SuperLU) and I need an LDL decomposition of a symmetric matrix A. So I thought "no problem", since an LU decomposition is unique and an LDL decomposition is unique then D is just the diagonals of U.

But the issue is that it never does A = LU, but rather PA = LU and PA isn't symmetric! So I can't figure out how to determine A = LDL from PA = LU

Is there something easy I can do to fix this? Any help is greatly appreciated.

P.S. Pre-emptive: Yes, I really, really, really, really do need an LDL decomposition. Not there's not another option. Yes, I'm sure. No, you don't need me to lay out the exact problem for you to confirm that I do indeed need an LDL decomposition.

*I know Matlab has its own LDL function, but I'm only using it to prototype and the libraries available to me in C++ (mostly SuperLU) don't seem to have any such function.

Upvotes: 1

Views: 931

Answers (1)

Martin
Martin

Reputation: 11

Use [L,U] = LU_decomposition(A). Then compute D=Uinv(transpose(L)). Then it holds A = LU = L * D * L'. Notice that D is upper right triangular since inv(transpose(L)) and U are upper right triangular.

Obviously, if A is symmetric then D is symmetric and you have your LDLT decomposition. Hope that helps.

Cheers, Martin

Upvotes: 1

Related Questions