Hi All,
TL;DR how can I use torch.linalg.ldl_factor
to get a lower triangular and diagonal matrix separately rather than a compact representation with pivoting?
I have a question about how exactly torch.linalg.ldl_factor
is used to extract the lower triangular and diagonal components of a matrix. I understand a compact representation involving pivoting is used, but I’m not familiar with it.
For example, the Wiki article on Cholesky decompositions has an LDL decomposition example,
However, when computing this within pytorch it gives a different representation. For example,
matrix = torch.tensor([[4,12,-16],
[12,37,-43],
[-16,-43,98]], dtype=torch.float32)
LD, pivot = torch.linalg.ldl_factor(matrix)
print(LD)
"""
returns
tensor([[ 4.0000, 0.0000, 0.0000],
[ 3.0000, 34.0000, 0.0000],
[-4.0000, 0.1471, 0.2647]])
"""
print(pivot)
#returns tensor([1, 3, 3], dtype=torch.int32)
So I assume there’s some way to take LD
and pivots
and use them to compute L
and D
separately? Is there a way to do this efficiently? Is this possible in pytorch?