dimforge / nalgebra

Linear algebra library for Rust.
https://nalgebra.org
Apache License 2.0
3.93k stars 465 forks source link

[feature request] ETA sparse solvers? #1197

Open Makogan opened 1 year ago

Makogan commented 1 year ago

Hello,

The documentation seems to indicate there are currently no sparse solvers in nalgebra-sparse. I was wondering if there is a plan on releasing some in the near future.

Best and thank you for the awesome library.

iverks commented 1 year ago

Bumping this since I bumped into issues with this as well. I tried starting discussion on sparsemat, but in retrospect I have more faith in this happening for Nalgebra.

I tried implementing it myself, but was quickly stumped. I tried porting code from scipy.sparse, which I found out is (atleast for my application) only a thin wrapper around a bundled version of ARPACK-NG. simplified callstack:

  1. scipy.sparse.eigs(some_matrix, ...other_params)
  2. _UnsymmetricArpackParams().iterate()
  3. _UnsymmetricArpackParams()._arpack_solver() # This is a reference to the fortran library

The main issue I struggled with when trying to do this myself was with how to FFI with fortran. I tried then to reimplement the routines I needed, but I met the same issue because they depend on BLAS and LAPACK.

A great first step would be to implement a wrapper like the lapack crate around ARPACK-NG, or to reimplement it in rust using the lapack crate and the blas crate (if necessary)

Andlon commented 1 year ago

@Makogan: no one is working on this at the moment. However, I'm using some bindings to Intel MKL's sparse direct solvers in my own projects, based on my unreleased mkl-corrode library. I'm planning to eventually contribute these to nalgebra-sparse. Writing efficient sparse direct solvers is a major undertaking, for which I don't think I'll personally have any time soon. I think such an effort should anyway be consolidated in a lower-level crate, through which higher-level crates like nalgebra-sparse could wrap in a simpler API. The folks over at the Rust Linear Solver Toolbox project might eventually perhaps go in a direction like this, but I'm not aware of a concerted effort at this time.

@iverks: I'm a little confused, are you interested in a sparse eigenvalue solver? I think the original poster referred to linear system solvers. I'm further confused because you mention a number of dense linear algebra libraries (LAPACK/BLAS). Admittedly, dense decompositions/algorithms are often building blocks of sparse solvers, but I'm a little confused about what it is that you are actually suggesting.

iverks commented 1 year ago

You would be right, I wrongly assumed he was referring to sparse eigenvalue solvers. As you say, the reason I mentioned LAPACK/BLAS is because these subroutines are used as building blocks in ARPACK. My suggestion was making wrappers for ARPACK-NG, analogously to your suggestion of creating a lower level crate. This crate could then be used by nalgebra-sparse.