condest

Function condest 

Source
pub fn condest<F>(
    a: &CsrMatrix<F>,
    norm_type: Option<&str>,
    tol: Option<F>,
    maxiter: Option<usize>,
) -> SparseResult<F>
where F: Float + NumAssign + Sum + SparseElement + 'static + Debug,
Expand description

Estimate the condition number of a sparse matrix

This function estimates cond(A) = ||A||_2 * ||A^(-1)||_2 using norm estimation. For efficiency, it estimates ||A^(-1)||_2 by solving (A^T * A) * x = b for random b and using power iteration to estimate the smallest singular value.

§Arguments

  • a - The sparse matrix
  • norm_type - The norm to use: “1” for 1-norm, “2” for 2-norm (default: “2”)
  • tol - Convergence tolerance (default: 1e-6)
  • maxiter - Maximum number of iterations (default: 100)

§Returns

An estimate of the condition number

§Examples

use scirs2_sparse::csr::CsrMatrix;
use scirs2_sparse::linalg::condest;

let rows = vec![0, 1];
let cols = vec![0, 1];
let data = vec![2.0, 3.0];
let matrix = CsrMatrix::new(data, rows, cols, (2, 2)).unwrap();

let cond_estimate = condest(&matrix, None, None, Some(1)).unwrap();