Skip to main content

lapack_dsyevr

Function lapack_dsyevr 

Source
pub fn lapack_dsyevr(
    a: &Matrix,
    range: &SymmetricRange,
    abstol: f64,
) -> Result<DsyevrResult>
Expand description

Selected eigenvalues and eigenvectors of a real symmetric matrix, with LAPACK’s relatively robust representations algorithm (igraph_lapack_dsyevr). Only the upper triangle of a is used.

abstol is the absolute error tolerance for the eigenvalues: an approximate eigenvalue is accepted when it lies in an interval [a, b] of width at most abstol + eps * max(|a|, |b|).

Binds igraph_lapack_dsyevr. The eigenvector support output of the C function is not exposed.

§Examples

This is igraph’s igraph_lapack_dsyevr.c example: the matrix [[2, -1], [-1, 3]] has eigenvalues (5 ± √5) / 2.

use igraph::{linalg::*, prelude::*};
let a = Matrix::from_rows(&[[2.0, -1.0], [-1.0, 3.0]]).unwrap();
let low = lapack_dsyevr(&a, &SymmetricRange::Select(0..1), 1e-10).unwrap();
assert!((low.values[0] - 1.381966).abs() < 1e-6);
let high = lapack_dsyevr(&a, &SymmetricRange::Interval { low: 3.0, high: 4.0 }, 1e-10).unwrap();
assert!((high.values[0] - 3.618034).abs() < 1e-6);
assert_eq!(high.vectors.shape(), (2, 1));