Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMRES and NormalCG sometimes handle singular matrices. #18

Open
patrick-kidger opened this issue Jun 2, 2023 · 0 comments
Open

GMRES and NormalCG sometimes handle singular matrices. #18

patrick-kidger opened this issue Jun 2, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@patrick-kidger
Copy link
Owner

patrick-kidger commented Jun 2, 2023

GMRES:

import lineax as lx
import jax.numpy as jnp

a = jnp.array([[1, 1], [0, 0]])
b = jnp.array([1, 0])
operator = lx.MatrixLinearOperator(a)
solver = lx.GMRES(rtol=1e-6, atol=1e-6)
sol = lx.linear_solve(operator, b, solver)
print(sol.value)  # [1. 0.]

Moreover note that whilst a @ sol.value == b, this is not the pseudoinverse solution.

Taken from https://users.wpi.edu/~walker/Papers/gmres-singular,SIMAX_18,1997,37-51.pdf ("GMRES on (nearly) singular systems")

This is particularly troublesome around autodiff, for which we may get incorrect gradients if a singular matrix is used.

Given the use of SVD as a subroutine within GMRES, we can probably detect this and do something smarter?

NormalCG:

import lineax as lx
import jax.numpy as jnp

matrix = jnp.array([[1.0, 0.0], [0.0, 0.0]])
vector = jnp.array([1., 2.])
out = lx.linear_solve(lx.MatrixLinearOperator(matrix), vector, solver=lx.NormalCG(rtol=1e-5, atol=1e-5))
print(out.value)
@patrick-kidger patrick-kidger added the bug Something isn't working label Jun 2, 2023
@patrick-kidger patrick-kidger changed the title GMRES sometimes handles singular matrices. GMRES and NormalCG sometimes handle singular matrices. Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant