\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 = 
  <float>  - size: [2 3]
 
Columns 1 to 3
 -1.04076362  -1.61856449   0.55819988  
  0.24222484  -1.26936078  -2.91016126  
--> [U,S,V] = svd(A)
U = 
  <float>  - size: [2 2]
 
Columns 1 to 2
  0.029025719   0.999578655  
  0.999578655  -0.029025720  
S = 
  <float>  - size: [2 3]
 
Columns 1 to 3
 3.1849895  0.0000000  0.0000000  
 0.0000000  2.0023384  0.0000000  
V = 
  <float>  - size: [3 3]
 
Columns 1 to 3
  0.06653523  -0.52306640   0.84969091  
 -0.41312730  -0.78959608  -0.45372224  
 -0.90823942   0.32084200   0.26862893  
--> U*S*V'
ans = 
  <float>  - size: [2 3]
 
Columns 1 to 3
 -1.04076362  -1.61856461   0.55819988  
  0.24222496  -1.26936090  -2.91016126  
--> svd(A)
ans = 
  <float>  - size: [2 1]
 
Columns 1 to 1
 3.1849895  
 2.0023384  

\end{verbatim}
