Skip to content

Commit

Permalink
Return a TriangularLinearOperator instead of a DenseLinearOperator af…
Browse files Browse the repository at this point in the history
…ter cholesky root inv decomposition
  • Loading branch information
naefjo committed Jan 23, 2024
1 parent 6ffd165 commit 716222d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions linear_operator/operators/_linear_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2207,8 +2207,8 @@ def root_inv_decomposition(
:param method: Root decomposition method to use (symeig, diagonalization, lanczos, or cholesky).
:return: A tensor :math:`\mathbf R` such that :math:`\mathbf R \mathbf R^\top \approx \mathbf A^{-1}`.
"""
from linear_operator.operators.dense_linear_operator import to_linear_operator
from linear_operator.operators.root_linear_operator import RootLinearOperator
from linear_operator.operators.triangular_linear_operator import TriangularLinearOperator

if not self.is_square:
raise RuntimeError(
Expand All @@ -2229,7 +2229,7 @@ def root_inv_decomposition(
# we don't need the batch shape here, thanks to broadcasting
Eye = torch.eye(L.shape[-2], device=L.device, dtype=L.dtype)
Linv = torch.linalg.solve_triangular(L, Eye, upper=False)
res = to_linear_operator(Linv.mT)
res = TriangularLinearOperator(Linv.mT, upper=True)
inv_root = res
elif method == "lanczos":
if initial_vectors is not None:
Expand Down

0 comments on commit 716222d

Please sign in to comment.