pub fn eigs<T, S>(
matrix: &S,
k: Option<usize>,
which: Option<&str>,
options: Option<LanczosOptions>,
) -> SparseResult<EigenResult<T>>where
T: Float + Debug + Copy + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + Sum + SimdUnifiedOps + Send + Sync + 'static + ScalarOperand,
S: SparseArray<T>,
Expand description
Find eigenvalues and eigenvectors of a general (non-symmetric) sparse matrix
This function computes eigenvalues of general sparse matrices using iterative methods. For symmetric matrices, consider using the specialized symmetric solvers which are more efficient.
§Arguments
matrix
- The sparse matrix (any SparseArray implementation)k
- Number of eigenvalues to compute (optional, defaults to 6)which
- Which eigenvalues to compute:- “LM”: Largest magnitude
- “SM”: Smallest magnitude
- “LR”: Largest real part
- “SR”: Smallest real part
- “LI”: Largest imaginary part
- “SI”: Smallest imaginary part
options
- Additional options for the solver
§Returns
Eigenvalue computation result with the requested eigenvalues and eigenvectors
§Examples
use scirs2_sparse::linalg::eigs;
use scirs2_sparse::csr_array::CsrArray;
use scirs2_core::ndarray::Array1;
// Create a general sparse matrix
let data = Array1::from(vec![1.0, 2.0, 3.0, 4.0]);
let indices = Array1::from(vec![0, 1, 0, 1]);
let indptr = Array1::from(vec![0, 2, 4]);
let matrix = CsrArray::new(data, indices, indptr, (2, 2)).unwrap();
// Find the 2 largest eigenvalues in magnitude
let result = eigs(&matrix, Some(2), Some("LM"), None).unwrap();