\section{EIGS Sparse Matrix Eigendecomposition}

\subsection{Usage}

Computes the eigendecomsition of a sparse square matrix.  The
\verb|eigs| function has several forms.  The most general form is
\begin{verbatim}
  [V,D] = eigs(A,k,sigma)
\end{verbatim}
where \verb|A| is the matrix to analyze, \verb|k| is the number of
eigenvalues to compute and \verb|sigma| determines which eigenvallues
to solve for.  Valid values for \verb|sigma| are
   'lm' - largest magnitude 
   'sm' - smallest magnitude
   'la' - largest algebraic (for real symmetric problems)
   'sa' - smallest algebraic (for real symmetric problems)
   'be' - both ends (for real symmetric problems)
   'lr' - largest real part 
   'sr' - smallest real part
   'li' - largest imaginary part
   'si' - smallest imaginary part
 scalar - find the eigenvalues closest to \verb|sigma|.
The returned matrix \verb|V| contains the eigenvectors, and \verb|D|
stores the eigenvalues.  The related form
\begin{verbatim}
   d = eigs(A,k,sigma)
\end{verbatim}
computes only the eigenvalues and not the eigenvectors.  If \verb|sigma|
is omitted, as in the forms
\begin{verbatim}
  [V,D] = eigs(A,k)
\end{verbatim}
and
\begin{verbatim}
  d = eigs(A,k)
\end{verbatim}
then \verb|eigs| returns the largest magnitude eigenvalues (and optionally
the associated eigenvectors).  As an even simpler form, the forms
\begin{verbatim}
  [V,D] = eigs(A)
\end{verbatim}
and
\begin{verbatim}
  d = eigs(A)
\end{verbatim}
then \verb|eigs| returns the six largest magnitude eigenvalues of \verb|A| and
optionally the eigenvectors.  The \verb|eigs| function uses ARPACK to
compute the eigenvectors and/or eigenvalues.  Note that due to a 
limitation in the interface into ARPACK from FreeMat, the number of
eigenvalues that are to be computed must be strictly smaller than the
number of columns (or rows) in the matrix.
\subsection{Example}

Here is an example of using \verb|eigs| to calculate eigenvalues
of a matrix, and a comparison of the results with \verb|eig|
\begin{verbatim}
--> a = sparse(rand(9))

a = 
	Matrix is sparse with 81 nonzeros
--> eigs(a)

ans = 

    4.6829 +  0.0000i 
    0.1461 -  0.8635i 
    0.1461 +  0.8635i 
   -0.5896 -  0.2277i 
   -0.5896 +  0.2277i 
    0.5487 +  0.1436i 

--> eig(full(a))

ans = 

    4.6829 +  0.0000i 
    0.1461 +  0.8635i 
    0.1461 -  0.8635i 
    0.5487 +  0.1436i 
    0.5487 -  0.1436i 
   -0.5896 +  0.2277i 
   -0.5896 -  0.2277i 
   -0.1536 +  0.2692i 
   -0.1536 -  0.2692i 


\end{verbatim}
Next, we exercise some of the variants of \verb|eigs|:
\begin{verbatim}
--> eigs(a,4,'sm')

ans = 

   -0.1536 -  0.2692i 
   -0.1536 +  0.2692i 
    0.5487 -  0.1436i 
    0.5487 +  0.1436i 

--> eigs(a,4,'lr')

ans = 

    4.6829 +  0.0000i 
    0.5487 -  0.1436i 
    0.5487 +  0.1436i 
    0.1461 -  0.8635i 

--> eigs(a,4,'sr')

ans = 

   -0.5896 -  0.2277i 
   -0.5896 +  0.2277i 
   -0.1536 -  0.2692i 
   -0.1536 +  0.2692i 


\end{verbatim}
