[Numpy-discussion] confusion about eigenvector

Arnar Flatberg arnar.flatberg at gmail.com
Thu Feb 28 10:17:15 EST 2008


On Thu, Feb 28, 2008 at 3:41 PM, devnew at gmail.com <devnew at gmail.com> wrote:
> > Arnar wrote
>
> > from scipy import linalg
>  > facearray-=facearray.mean(0) #mean centering
>  > u, s, vt = linalg.svd(facearray, 0)
>  > scores = u*s
>  > facespace = vt.T
>
>  hi Arnar
>  when i do this i get these
>  u =< 'numpy.core.defmatrix.matrix'> (4, 4)
>  that matches the eigenvectors matrix in my previous data
>  s=< 'numpy.ndarray'> (4,)
>  and
>  vt=<'numpy.core.defmatrix.matrix'> (4, 12)
>
>  here
>  scores=u*s causes a matrix not aligned error..
>
>  is there something wrong in the calculation?
>
>
> D
>  _______________________________________________
>  Numpy-discussion mailing list
>  Numpy-discussion at scipy.org
>  http://projects.scipy.org/mailman/listinfo/numpy-discussion

This example assumes that facearray is an ndarray.(like you described
in original post ;-) ) It looks like you are using a matrix. (u =<
'numpy.core.defmatrix.matrix'> (4, 4)) . This causes the
u*s-broadcasting to fail. Try again, with:
facearray = numpy.asarray(facearray), before calculation.

Arnar



More information about the NumPy-Discussion mailing list