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

Matthieu

2007/5/6, dpn <[EMAIL PROTECTED]>:

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
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to