[Numpy-discussion] SVD problem - matrices are not aligned

Charles R Harris charlesr.harris@gmail....
Sat Oct 23 21:21:47 CDT 2010


On Sat, Oct 23, 2010 at 7:00 PM, Daniel Wagner <daniel.wagner.ml@
googlemail.com> wrote:

> Hi,
>
> I'm a new subscriber of this list. I hope to directly start with a question
> is ok...
>
> My question or problem:
> I've a matrix A which is calculated from the data b. The shapes of these
> matrices are:
> >>>A.shape
> (954, 9)
> >>>b.shape
> (954,)
>
> I calculate the SVD of A:
> >>> U, w, V = numpy.linalg.svd(A, full_matrices="True")
> >>>U.shape
> (954, 954)
>

You want full_matrices set false so that U has shape (954, 9).


> >>>W.diag(w)
> >>>W.shape
> (9,9)
> >>>V.shape
> (9,9)
>
> If I'm doing the check of the SVD results using:
> >>>numpy.allclose(A, numpy.dot(U, numpy.dot(W, V)))
> I get this error:
>

easier, allclose(A, dot(U*w, V) )


"ValueError: matrices are not aligned"
>
>
Mismatched dimensions.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101023/fd180dae/attachment.html 


More information about the NumPy-Discussion mailing list