[Numpy-discussion] confusion about eigenvector

Arnar Flatberg arnar.flatberg@gmail....
Thu Feb 28 09:17:15 CST 2008


On Thu, Feb 28, 2008 at 3:41 PM, devnew@gmail.com <devnew@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@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