Skip to main content

rlst_suitesparse/
lib.rs

1//! SuiteSparse bindings for RLST sparse matrices.
2//!
3//! This crate currently provides a safe UMFPACK interface for solving real and
4//! complex double-precision systems stored as [`rlst::sparse::csr_mat::CsrMatrix`].
5//! SuiteSparse must be installed natively. Set `SUITESPARSE_PATH` to its
6//! installation prefix when it is not discoverable in a standard location.
7//!
8//! ```
9//! use rlst::{FromAij, rlst_dynamic_array};
10//! use rlst::sparse::csr_mat::CsrMatrix;
11//! use rlst_suitesparse::UmfpackFactorize;
12//!
13//! let matrix = CsrMatrix::from_aij(
14//!     [2, 2],
15//!     &[0, 0, 1, 1],
16//!     &[0, 1, 0, 1],
17//!     &[4.0, 1.0, 2.0, 3.0],
18//! );
19//! let numeric = matrix.factorize()?;
20//! let mut rhs = rlst_dynamic_array!(f64, [2]);
21//! rhs[[0]] = 1.0;
22//! rhs[[1]] = 1.0;
23//! let solution = numeric.solve(&rhs)?;
24//! assert!((solution[[0]] - 0.2).abs() < 1e-12);
25//! assert!((solution[[1]] - 0.2).abs() < 1e-12);
26//! # Ok::<(), rlst_suitesparse::UmfpackError>(())
27//! ```
28
29#![warn(missing_docs)]
30
31/// Safe UMFPACK factorization and solve support.
32pub mod umfpack;
33
34pub use umfpack::{
35    UmfpackComplexNumeric, UmfpackError, UmfpackFactorizationStatus, UmfpackFactorize,
36    UmfpackNumeric, UmfpackResult,
37};