Skip to content

eigs

eigs(A, k=5, M=None)

Computes Generalized Eigenvalues and Eigenvectors of sparse non-definite matrix A, with massmatrix M

Parameters:

Name Type Description Default
A (n, n) float sparse matrix

Indefinite sparse matrix

required
k int

Number of eigenvectors/values to solve for (default=5)

5
M (n, n) float sparse matrix

Indefinite mass matrix

None

Returns:

Name Type Description
D (k, 1) float numpy array

Eigenvalues

B (n, k) float numpy array

Eigenvectors

Source code in src\fast_cody\eigs.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def eigs(A, k=5, M=None):
    """
    Computes Generalized Eigenvalues and Eigenvectors of sparse non-definite matrix A, with massmatrix M

    Parameters
    ----------
    A : (n, n) float sparse matrix
        Indefinite sparse matrix
    k : int
        Number of eigenvectors/values to solve for (default=5)
    M : (n, n) float sparse matrix
        Indefinite mass matrix

    Returns
    --------
    D : (k, 1) float numpy array
        Eigenvalues
    B : (n, k) float numpy array
        Eigenvectors

    """
    if M is None:
        M = sp.sparse.identity(A.shape[0])

    try:
        OpInv = umfpack_LU_LinearOperator(A)
        # MInv = umfpack_LU_LinearOperator(M)
        [D, B] = sp.sparse.linalg.eigs(A, M=M, k=k, sigma=0,
                                  which='LM', OPinv=OpInv)
    except:
        print("UMFPACK LU Factorization Failed, Trying Scipy LU")
        [D, B] = sp.sparse.linalg.eigs(A, M=M, k=k, sigma=0,which='LM')
    return D, B