cho_solve¶
- sksparse.cholmod.cho_solve(A, b, *, lower=False, order='default')[source]¶
Solve the linear system A x = b for x, using the Cholesky factorization.
The matrix A is factorized using the same parameters as in
cho_factor(), and subject to the same positive definiteness requirements.- 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
Amatrix. The number of rows inbmust be equal to the size of theAmatrix.lower (bool, optional) – If True, use only the lower triangular part of
A, otherwise use the upper triangular part.order (None or str in {{“default”, “best”, “natural”, “metis”, “nesdis”, “amd”, “colamd”, “postordered”}}, optional) – The permutation algorithm to use for the factorization. Options are:
default: Use the default method, which first tries AMD, then METIS.best: Automatically select the best ordering based on the input.metis: Use the METIS library for graph partitioning.nesdis: Use the NESDIS library for nested dissection.amd: Use the Approximate Minimum Degree (AMD) algorithm.colamd: Use the Approximate Minimum Degree (AMD) algorithm for thesymmetric case, or the COLAMD algorithm for the unsymmetric case (\(A A^{{\top}}\) or \(A^{{\top}} A\)).
postordered: Use natural ordering followed by postordering.naturalorNone: No permutation is applied (identity permutation).
By default, methods other than
naturalwill also be postordered.Warning
The ordering method
bestmay be quite slow for large matrices, but if the factorization is reused many times, it can be worth it.
- 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
Ais 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
orderwas notnaturalwhen 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
lowerwas True when the factorization was computed, the system solved is:\[P^{\top} L 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].Added in version 0.5.0.
References