[Numpy-discussion] svd headers and diagonals

Matthieu Brucher matthieu.brucher at gmail.com
Sun May 6 08:45:29 EDT 2007


Don't forget that '*' is element-wise for arrays, use dot instead ;)

Matthieu

2007/5/6, dpn <davidnovakovic at gmail.com>:
>
> Hi,
>
> i have two questions, both loosely related to SVD.
> I've seen this post:
> http://thread.gmane.org/gmane.comp.python.numeric.general/4575
>
> >>> u,s,v = numpy.linalg.svd(numpy.array([[4,2],[2,4]])) # symmetric
> matrix u == v
> >>> u
> array([[-0.70710678, -0.70710678],
>        [-0.70710678,  0.70710678]])
> >>> v
> array([[-0.70710678, -0.70710678],
>        [-0.70710678,  0.70710678]])
> >>> s.shape
> (2,)
>
> since my data matrix is symmetrical, i'd expect USV = X, but I don't get
> that:
> >>> u * s * v
> array([[ 3.,  1.],
>        [ 3.,  1.]])
>
> matrixmultiply doesnt help either
> >>> from numpy.core import matrixmultiply as mm
> >>> mm(u,mm(s,v))
> array([ 6.,  2.])
>
> Question 2.
>
> I'm relativly new to linealg, so i could be way off here.
> In applications such as LSA, the dimensions of a matrix are either
> documents or term identifiers, I noticed in PDL ( http://pdl.perl.org/
> ), you can set the headers of row or columns.
>
> I havent found a way to do this in numpy, which means when the
> dimensions get sorted by their singular value, I lose the ordering I
> may have recorded externally.
>
> I there a way to store row and column headers?
>
> Cheers
>
> David Novakovic
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070506/e2a02247/attachment.html>


More information about the NumPy-Discussion mailing list