\section{SVD Singular Value Decomposition of a Matrix}

\subsection{Usage}

Computes the singular value decomposition (SVD) of a matrix.  The 
\verb|svd| function has three forms.  The first returns only the singular
values of the matrix:
\begin{verbatim}
  s = svd(A)
\end{verbatim}
The second form returns both the singular values in a diagonal
matrix \verb|S|, as well as the left and right eigenvectors.
\begin{verbatim}
  [U,S,V] = svd(A)
\end{verbatim}
The third form returns a more compact decomposition, with the
left and right singular vectors corresponding to zero singular
values being eliminated.  The syntax is
\begin{verbatim}
  [U,S,V] = svd(A,0)
\end{verbatim}
\subsection{Function Internals}

Recall that \verb|sigma_i| is a singular value of an \verb|M x N|
matrix \verb|A| if there exists two vectors \verb|u_i, v_i| where \verb|u_i| is
of length \verb|M|, and \verb|v_i| is of length \verb|u_i| and
\[
  A v_i = \sigma_i u_i
\]
and generally
\[
  A = \sum_{i=1}^{K} \sigma_i u_i*v_i',
\]
where \verb|K| is the rank of \verb|A|.  In matrix form, the left singular
vectors \verb|u_i| are stored in the matrix \verb|U| as
\[
  U = [u_1,\ldots,u_m], V = [v_1,\ldots,v_n]
\]
The matrix \verb|S| is then of size \verb|M x N| with the singular
values along the diagonal.  The SVD is computed using the 
\verb|LAPACK| class of functions \verb|GESDD|.
\subsection{Examples}

Here is an example of a partial and complete singular value
decomposition.
\begin{verbatim}
--> A = float(randn(2,3))

A = 

    0.8958    0.6486   -1.7291 
   -0.4528   -0.4949   -1.3478 

--> [U,S,V] = svd(A)
U = 

   -0.8714   -0.4906 
   -0.4906    0.8714 

S = 

    2.2618         0         0 
         0    1.1678         0 

V = 

   -0.2469   -0.7142    0.6550 
   -0.1425   -0.6418   -0.7535 
    0.9585   -0.2794    0.0567 

--> U*S*V'

ans = 

    0.8958    0.6486   -1.7291 
   -0.4528   -0.4949   -1.3478 

--> svd(A)

ans = 

    2.2618 
    1.1678 


\end{verbatim}
