[Numpy-discussion] confusion in eigenlib code

gordon nodrogbrown@gmail....
Tue Apr 1 10:09:13 CDT 2008

i came across some code for eigenface construction from some
images ,using the old Numeric .
In the eigenlib.py
i  converted the calls to Numeric functions to their numpy equivalents
(to linalg.eigh() and numpy.dot())and ran the code.In this eigenlib.py
i am confused by some parts where they derrive eigenvectors and sort

evalues, evectors = LinearAlgebra.eigenvectors(L)
# sort them by eigenvalue and keep the top M_prime
evs = map(None, evalues, evectors)
evs = evs[0:M_prime]

# write those into the directory
v = map(lambda x: x[1], evs)
self.u = []
for k in range(M_prime):
    print(' ' + str(k+1))
    self.u.append(Numeric.matrixmultiply(v[k], self.Phi))
    #self.vector_to_image(self.u[-1], '%s/eig%03d.gif' % (dir, k))

(Here self.Psi is the average face from a collection of face images
and  self.Phi is obtained by substracting Psi from original image
data ...mean centering i guess)

what i can't understand in the above code is that when evs[0:M_prime]
is taken it takes the rows from evectors.Is not the correct way to
take a column of evectors as an eigenvector? If someone can make this
clear please do

More information about the Numpy-discussion mailing list