Skip to content

umfpack_lu_solve

umfpack_lu_solve(A, b)

Solves Ax = b using LU factorization with umfpack.

Parameters:

Name Type Description Default
A (n, n) float numpy array

Matrix to solve

required
b (n, ) float numpy array

Right hand side

required

Returns:

Name Type Description
x (n, ) float numpy array

Solution to Ax = b

Source code in src\fast_cody\umfpack_lu_solve.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def umfpack_lu_solve(A, b):
    """
    Solves Ax = b using LU factorization with umfpack.
    Parameters
    ----------
    A : (n, n) float numpy array
        Matrix to solve
    b : (n, ) float numpy array
        Right hand side

    Returns
    -------
    x : (n, ) float numpy array
        Solution to Ax = b
    """
    [I, J] = A.nonzero()
    v = A.data
    Ac= cvxopt.spmatrix(v, I, J, A.shape)
    bc = cvxopt.matrix(b)
    cvxopt.umfpack.linsolve(Ac, bc)
    cnp = np.array(bc)
    return cnp