solve¶
- UMFFactor.solve(b, *, trans='N', rhs_batch_size=100)[source]¶
Solve a linear system using the LU factorization.
This method solves one of the following linear systems:
\(A x = b\) (if
trans='N')\(A^{\top} x = b\) (if
trans='T'and \(A\) is real)\(A^{H} x = b\) (if
trans='H'and \(A\) is complex)
- Parameters:
b ((N,) or (N, K) numpy.ndarray or sparse array) – The right-hand side vector or martrix.
trans (str, optional) – The type of system to solve. Possible values are:
N: solve \(A x = b\) (default)T: solve \(A^{\top} x = b\)H: solve \(A^{H} x = b\)
Note
If \(A\) is real, then
TandHare equivalent.rhs_batch_size (int, optional) – If
bis a 2D sparse array, this parameter controls the number of columns to be solved simultaneously. A larger number will increase memory consumption by converting more columns at a time to dense arrays, but may improve runtime.
- Returns:
x ((N,) or (N, K) numpy.ndarray or sparse array) – The solution vector or matrix. If
bis a 1D array, thenxis returned as a 1D array. Ifbis a 2D array withKcolumns, thenxis returned as a 2D array withKcolumns. Ifbis a sparse array, thenxis also returned as a sparse array.- Raises:
UMFPACKSingularMatrixWarning – If the matrix is detected to be singular to working precision. In that case, the solution will have infinite or NaN values, but other entries may still be valid.
Notes
The underlying UMFPACK solver can only handle 1D dense array inputs. If the RHS
bis a 2D array, this method will solve each column independently. Ifbis dense, there is a slight performance gain (~5% in time) by passing it as a Fortran-contiguous array (e.g. by usingnumpy.asfortranarray()), since the columns are then stored contiguously in memory. Otherwise, each column will be copied to a temporary Fortran-contiguous buffer before solving.