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 b is 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 b is a 1D array, then x is returned as a 1D array. If b is a 2D array with K columns, then x is returned as a 2D array with K columns. If b is a sparse array, then x is also returned as a sparse array.