#9011: the numpy SVD decomposition docstring is wrong
------------------------------+---------------------------------------------
   Reporter:  was             |       Owner:  jason, was
       Type:  defect          |      Status:  new       
   Priority:  minor           |   Milestone:  sage-4.4.3
  Component:  linear algebra  |    Keywords:            
     Author:                  |    Upstream:  N/A       
   Reviewer:                  |      Merged:            
Work_issues:                  |  
------------------------------+---------------------------------------------
 I decided to actually look at the numpy SVD decomposition in preparation
 for my class today, and quickly found that it is wrong.

 {{{
 sage: import numpy
 sage: numpy.linalg.svd?
 ---
 Definition: numpy.linalg.svd(a, full_matrices=1, compute_uv=1)

 Docstring:

     Singular Value Decomposition.

     Factorizes the matrix `a` into two unitary matrices, ``U`` and ``Vh``,
     and a 1-dimensional array of singular values, ``s`` (real, non-
 negative),
     such that ``a == U S Vh``, where ``S`` is the diagonal
     matrix ``np.diag(s)``.
 ----
 }}}

 The statement that S is the diagonal matrix np.diag(s) is just totally
 false if the input matrix a is nonsquare, since S is also non square.

 The best fix I could find is to replace np.diag(s) by
 {{{
 S = numpy.zeros( a )
 S[:len(s),:len(s)] = numpy.diag(s)
 }}}

 Obviously, this should really be reported and patched upstream.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9011>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to