Skip to main content

hermitian_lanczos_lowest_eigenpair

Function hermitian_lanczos_lowest_eigenpair 

Source
pub fn hermitian_lanczos_lowest_eigenpair<T, F>(
    apply_a: F,
    initial: &T,
    options: &HermitianLanczosOptions,
) -> Result<HermitianLanczosResult<T>, KrylovError>
where T: TensorVectorSpace, F: Fn(&T) -> Result<T>,
Expand description

Compute the lowest eigenpair of a Hermitian matrix-free operator. The operator is supplied as apply_a, which maps a vector to A * vector. The algorithm builds an orthonormal Krylov basis using modified Gram-Schmidt with a second reorthogonalization pass, forms the small projected matrix V^dagger A V, and solves that small Hermitian problem via tensorbackend. The full operator matrix is never materialized.

§Arguments

  • apply_a - Matrix-free Hermitian operator application.

  • initial - Nonzero initial vector that defines the starting Krylov vector.

  • options - Krylov dimension, convergence tolerances, and Hermitian

    validation settings.

§Returns

The lowest Ritz eigenpair and the true residual norm.

§Errors

Returns an error when the operator is not Hermitian-compatible (a shape mismatch or a KrylovError::NonHermitian projection failure), when the options are invalid (a KrylovError::InvalidOptions), when the initial vector is numerically zero (a KrylovError::ZeroInitialVector), or when an underlying tensor or backend operation fails (a KrylovError::Operation). Non-convergence is reported through HermitianLanczosResult::converged and does not produce an error.

§Examples

use tensor4all_core::{DynIndex, IdxTensor, TensorVectorSpace};
use tensor4all_core::krylov::{hermitian_lanczos_lowest_eigenpair, HermitianLanczosOptions};
let i = DynIndex::new_dyn(2);
let initial = IdxTensor::from_dense(vec![i.clone()], vec![1.0_f64, 1.0]).unwrap();
let result = hermitian_lanczos_lowest_eigenpair(
    |x: &IdxTensor| Ok(x.clone()),
    &initial,
    &HermitianLanczosOptions::default(),
).unwrap();
assert!(result.converged);
assert!((result.eigenvalue - 1.0).abs() < 1.0e-12);