[SciPy-user] How can I improve the efficiency linalg.eig with respect to certain properties of the matrices

Nils Wagner nwagner at mecha.uni-stuttgart.de
Wed Jun 11 05:34:03 EDT 2003


Hi all,

I wonder, if I can speed up the computation of a standard/generalized
large scale eigenvalue problem (n>10^3) in scipy.
I guess it should be possible somehow, since linalg.eig ignores the
special structure
(symmetrie, band, definiteness) of the matrix. Are there any efforts in
adapting 
linalg.eig with respect to certain properties of the matrix A in
(Ax=\lambda x) and matrices for (Ax = \lambda Bx) ?


Any comments or suggestions ?

Nils
-------------- next part --------------
from scipy import *           
from IPython import genutils
n = 255

def eberlein():

  tmp=zeros((n,n),Float)
  for k in arange(0,n):
    tmp[k,k] = 1.0+(1.0+(1.0+2.0*(k+1.0)**2-2*(k+1.0))/n-2.0*(k+1))/n
  for k in arange(0,n-1):
    tmp[k,k+1] = (k+1.0)*(n-(k+1.0))/n**2
    tmp[k+1,k] = tmp[k,k+1]

  return tmp
t0 = genutils.clock()
A = eberlein()
w, vr = linalg.eig(A)
t1 = genutils.clock()
print
print 'CPU time',t1-t0
print
print 'Eigenvalues by linalg.eig'
print
print sort(abs(w))
#
# Analytical eigenvalues
#
wa = zeros(n,Float)
for j in arange(0,n):
  wa[j] = 1.0-(j+1.0)*j/n**2
print
print 'Analytical eigenvalues'
print
print sort(wa)
  


More information about the SciPy-User mailing list