solve¶
- KLUFactor.solve(b, *, transpose=False, rhs_batch_size=100)[source]¶
Solve a linear system using the KLU factorization.
This method solves a linear system for \(x\) given the right-hand side \(b\) as either a vector or a matrix with multiple right-hand sides.
If
transpose=False, solve\[A x = b\]or, if
transpose=True, solve\[x A = b \Longleftrightarrow A^{\top} x^{\top} = b^{\top}.\]The method uses the LU factorization of \(A\) previously computed by
factorize().- Parameters:
b ((N,) or (N, K) numpy.ndarray) – The right-hand side vector or matrix.
transpose (bool, optional) – If True, solve \(x A = b\), otherwise, solve \(A x = b\).
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.