pyyeti.ytools.sturm

pyyeti.ytools.sturm(A, lam)[source]

Count number of eigenvalues <= lam of symmetric matrix A.

Parameters:
  • A (2d ndarray) – Symmetric matrix to do Sturm counting on.

  • lam (float or array of floats) – Eigenvalue cutoff(s).

Returns:

count (1d ndarray) – Contains number of eigenvalues below the cutoff values in lam. That is: count[i] = number of eigenvalues in A below value lam[i].

Notes

Computes the Hessenberg form of A which is tridiagonal if A is symmetric. Then it does a simple Sturm count on the results (code derived from LAPACK routine DLAEBZ).

Examples

Make symmetric matrix, count number of eigenvalues <= 0, and compute them:

>>> from pyyeti import ytools
>>> import numpy as np
>>> import scipy.linalg as la
>>> np.set_printoptions(precision=4, suppress=True)
>>> A = np.array([[  96.,  -67.,   36.,   37.,   93.],
...               [ -67.,   28.,   82.,  -66.,  -19.],
...               [  36.,   82.,  112.,    0.,  -61.],
...               [  37.,  -66.,    0.,  -14.,   47.],
...               [  93.,  -19.,  -61.,   47., -134.]])
>>> w = la.eigh(A, eigvals_only=True)
>>> w
array([-195.1278,  -61.9135,  -10.1794,  146.4542,  208.7664])
>>> ytools.sturm(A, 0)
array([3])
>>> ytools.sturm(A, [-200, -100, -20, 200, 1000])
array([0, 1, 2, 4, 5])