Skip to content

[Docs] Example in readme is giving NotPSDError #99

@jakee417

Description

@jakee417

📚 Documentation/Examples

** Is documentation wrong? **

In readme example for LinearOperator: https://github.com/cornellius-gp/linear_operator?tab=readme-ov-file#with-linearoperator

from linear_operator.operators import DiagLinearOperator, LowRankRootLinearOperator
# C = torch.randn(1000, 20)
# d = torch.randn(1000)
# b = torch.randn(1000)
A = LowRankRootLinearOperator(C) + DiagLinearOperator(d)  # represents C C^T + diag(d)
torch.linalg.solve(A, b)  # computes A^{-1} b efficiently!

will give

NotPSDError: Matrix not positive definite after repeatedly adding jitter up to 1.0e-06.

** Think you know how to fix the docs? ** (If so, we'd love a pull request from you!)

from linear_operator.operators import DiagLinearOperator, LowRankRootLinearOperator
C = torch.randn(1000, 20)
d = torch.ones(1000) * 1e-9
b = torch.randn(1000)
A = LowRankRootLinearOperator(C) + DiagLinearOperator(d)
torch.linalg.solve(A, b)

should solve the issue

(Link to LinearOperator documentation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions