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

Are there any matrix-free solvers? #190

Open
medakk opened this issue Apr 11, 2020 · 8 comments
Open

Are there any matrix-free solvers? #190

medakk opened this issue Apr 11, 2020 · 8 comments

Comments

@medakk
Copy link

medakk commented Apr 11, 2020

Hi! Does ndarray support any matrix-free solvers?

In matrix-free solver, instead of x = solve(A, b), we run x = solve(f, b), where f is a function f(y) = Ay that can evaluate the product of A and any vector. This is useful in some situations where we don't need to store the entire matrix. https://en.wikipedia.org/wiki/Matrix-free_methods

This is Eigen's version: https://eigen.tuxfamily.org/dox/group__MatrixfreeSolverExample.html

@bytesnake
Copy link
Contributor

bytesnake commented Apr 13, 2020

For eigenvalue problems there is #184 in the pipeline. It implements a blocked conjugated gradient algorithms in matrix-free fashion by accepting the linear operator as a closure here. A similar conjugated gradient algorithm could be implemented for equation solver.

@bytesnake
Copy link
Contributor

Do you have a specific use-case?

@medakk
Copy link
Author

medakk commented Apr 13, 2020

I'm working on a physics simulator. During the time integration step, I have to solve for a large matrix A Ax=b. The matrix A is quite sparse however and I could just use the sparse solver. But most of A is calculating the forces and the gradients of the forces, which could be done with explicitly storing it.

@bytesnake
Copy link
Contributor

bytesnake commented Apr 13, 2020 via email

@bytesnake
Copy link
Contributor

bytesnake commented Apr 13, 2020 via email

@medakk
Copy link
Author

medakk commented Apr 14, 2020

Thanks! I was reading that exact document(painless conjugate gradients). I think I'll use sprs for my work now.

Otherwise you need to implement GMRES (see issue #107) or BiCGSTAB.

By implement, do you mean a pure rust implementation or calling into a BLAS library to solve it? If you could give me some pointers on which part of the codebase this would touch, I could work on it.

@bytesnake
Copy link
Contributor

You still want to call into a BLAS library for optimized matrix-vector product, but the implementation itself is in Rust. If you're matrix is not symmetric, then the BiCGSTAB algorithm is IMO more easy to implement. You could also try to adapt previous attempts (these are two years old and probably won't compile anymore)
https://en.wikipedia.org/wiki/Biconjugate_gradient_stabilized_method
https://users.rust-lang.org/t/prior-work-on-krylov-subspace-methods/13261/5

@medakk
Copy link
Author

medakk commented Jun 21, 2020

EDIT: Disregard, I hadn't read the docs completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants