Use python to calculate the N smallest eigenvalues of a tridiagonal matrix
## module eigenvals3 ''' lam = eigenvals3(d,c,N). Returns the N smallest eigenvalues of a tridiagonal matrix [A] = [c\d\c]. ''' from lamRange import * from ridder import * from sturmSeq import sturmSeq from numpy import zeros def eigenvals3(d,c,N): def f(x): # f(x) = |[A] - x[I]| p = sturmSeq(d,c,x) return p[len(p)-1] lam = zeros(N) r = lamRange(d,c,N) # Bracket eigenvalues for i in range(N): # Solve by Brent's method lam[i] = ridder(f,r[i],r[i+1]) return lam