## EIGS Sparse Matrix Eigendecomposition

Section: Sparse Matrix Support

### Usage

Computes the eigendecomsition of a sparse square matrix. The `eigs` function has several forms. The most general form is

      [V,D] = eigs(A,k,sigma)

where `A` is the matrix to analyze, `k` is the number of eigenvalues to compute and `sigma` determines which eigenvallues to solve for. Valid values for `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 `sigma`. The returned matrix `V` contains the eigenvectors, and `D` stores the eigenvalues. The related form

       d = eigs(A,k,sigma)

computes only the eigenvalues and not the eigenvectors. If `sigma` is omitted, as in the forms

      [V,D] = eigs(A,k)

and

      d = eigs(A,k)

then `eigs` returns the largest magnitude eigenvalues (and optionally the associated eigenvectors). As an even simpler form, the forms

      [V,D] = eigs(A)

and

      d = eigs(A)

then `eigs` returns the six largest magnitude eigenvalues of `A` and optionally the eigenvectors. The `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.

### Example

Here is an example of using `eigs` to calculate eigenvalues of a matrix, and a comparison of the results with `eig`

    --> 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

    -->
    quit

Next, we exercise some of the variants of `eigs`:

    --> 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

    -->
    quit