solve

CholeskyFactor.solve(b, system='A')[source]

Solve the linear system \(A x = b\) for x, using the factorization.

Parameters:
  • b ((N,) or (N, K) ndarray or sparse matrix) – The right-hand side vector or matrix. Must be a type that can be safely cast to the data type of the factor. The number of rows in b must be equal to the size of the factor.

  • system (str in {‘A’, ‘LDLt’, ‘LD’, ‘DLt’, ‘L’, ‘Lt’, ‘D’}, optional) – The system to solve. Options are:

    • A: Solve \(A x = b\).

    • LDLt: Solve \(L D L^{\top} x = b\).

    • LD: Solve \(L D x = b\).

    • DLt: Solve \(D L^{\top} x = b\).

    • L: Solve \(L x = b\).

    • Lt: Solve \(L^{\top} x = b\).

    • D: Solve \(D x = b\).

    Here, L and D are the factors from the LDL factorization of the matrix.

    Note

    Only the A system accounts for the permutation used in the factorization. The other systems solve the equations using the factors directly, without applying the permutation.

Returns:

x ((N,) or (N, K) ndarray or sparse matrix) – The solution vector or matrix, returned in the same format as b.

Raises:

CholmodNotPositiveDefiniteError – If the matrix A is exactly singular, or singular to working precision.

Notes

This function solves the linear system:

\[R^{\top} R x = b,\]

where R is the upper triangular factor from the Cholesky factorization of A. The input b is either dense or sparse, vector or matrix.

If order was not natural when the factorization was computed, solve the system:

\[P^{\top} R^{\top} R P x = b\]

where P is the permutation matrix corresponding to the permutation vector. Similarly, if lower was True when the factorization was computed, the system solved is:

\[P^{\top} L L^{\top} P x = b.\]

If the factorization is in LDL form, the system solved is:

\[P^{\top} L D L^{\top} P x = b.\]

This function uses the CHOLMOD library to solve the linear system. It is intended to combine the MATLAB interfaces cholmod2.m [1], and ldlsolve.m [2].

Added in version 0.5.0.

References