Skip to main content

hermitian_eigendecomposition

Function hermitian_eigendecomposition 

Source
pub fn hermitian_eigendecomposition<T>(
    matrix: &Matrix<T>,
    hermitian_tol: f64,
) -> Result<HermitianEigendecomposition<T>, HermitianEigenError>
Expand description

Compute all eigenpairs of a small Hermitian projected matrix.

This validates Hermitian structure and symmetrizes accepted roundoff before calling the backend. It is meant for bounded Krylov/Rayleigh-Ritz matrices, not full tensor-network materialization.

§Arguments

  • matrix - Square Hermitian matrix in column-major Matrix layout.

  • hermitian_tol - Relative tolerance for checking A = A†, applied per

    entry pair with scale max(1, |A[i,j]|, |A[j,i]|).

§Returns

All real eigenvalues and all eigenvectors of matrix.

§Errors

Returns HermitianEigenError if matrix is not square, is not Hermitian within hermitian_tol, or the backend eigensolver fails.

§Examples

use tensor4all_tensorbackend::{hermitian_eigendecomposition, Matrix};

let matrix = Matrix::from_col_major_vec(2, 2, vec![3.0, 0.0, 0.0, 5.0]);
let decomp = hermitian_eigendecomposition(&matrix, 1.0e-12).unwrap();
assert_eq!(decomp.eigenvalues, vec![3.0, 5.0]);
assert_eq!(decomp.eigenvectors.as_col_major_slice().len(), 4);