patrick-kidger / lineax

Linear solvers in JAX and Equinox. https://docs.kidger.site/lineax
Apache License 2.0
332 stars 22 forks source link

Add example using preconditioning. #8

Open patrick-kidger opened 1 year ago

frederic-bender commented 1 month ago

Hey, I'm using a Newton-GMRES-algorithm for implicitly solving large ODEs, based on Diffrax/Optimistix/Lineax – a pretty awesome set of libraries!

Right now I'm trying to figure out, how to create a Jacobi-preconditioner (or a more advanced one) for matrix-free computations. Using lx.diagonal(...) materializes the Jacobian and therefore is not possible for a vector of length ~500,000. Do you have any idea how to solve this problem?

patrick-kidger commented 1 month ago

This depends on the kind of operator you have. A tridiagonal linear operator, for example, can get the diagonal without further materialization!

However it's a classic (sad) fact in autodifferentiation that accessing the diagonal of a Jacobian requires computing the whole Jacobian.

You'll probably need to find a different approach for your problem.

Sorry I couldn't be more help!