[Numpy-discussion] numpy.linalg.svd documentation

josef.pktd at gmail.com josef.pktd at gmail.com
Sat Jan 29 21:46:50 EST 2011

```On Sat, Jan 29, 2011 at 8:58 PM, Jason Grout
<jason-sage at creativetrax.com> wrote:
> The SVD documentation seems a bit misleading.  It says:
>
> Factors the matrix a as u * np.diag(s) * v, where u and v are unitary
> and s is a 1-d array of a‘s singular values.
>
> However, that only is true (i.e., you just have to do np.diag(s) to get
> S) in general if full_matrices is False, which is not the default.
> Otherwise, you have to something like in the first example in the docstring.
>
> I'm not sure what the right fix is here.  Changing the default for
> full_matrices seems too drastic.  But then having u*np.diag(s)*v in the
> first line doesn't work if you have a rectangular matrix.  Perhaps the
> first line could be changed to:
>
> Factors the matrix a as u * S * v, where u and v are unitary and S is a
> matrix with shape (a.shape[0], a.shape[1]) with np.diag(S)=s, where s is
> a 1-d array of a‘s singular values.
>
> It sounds more confusing that way, but at least it's correct.
>
> Maybe even better would be to add a shape option to np.diag, and then
> just make the first line of the svd docstring say
> u*np.diag(s,shape=(a.shape[0],a.shape[1]))*v

or move scipy's diagsvd to numpy

scipy.linalg.diagsvd(s, M, N)

I found the difference between full and not full matrices confusing
when I tried to figure out how svd (in scipy) works. diagsvd was a big
help for me.

I think you could just edit it with the documentation editor. Any
clarification is better even if it sounds a bit complicated.

Josef

>
>
> Jason
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>

```