spqr_solve

sksparse.spqr.spqr_solve(A, b, *, transpose=False, min2norm=True, rhs_batch_size=100)[source]

Solve a linear system using the SPQR factorization.

Solve 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

\[A^{\top} x = b.\]
Parameters:
  • A ((M, N) array_like or sparse array) – An array convertible to a sparse matrix.

  • b ((M,) or (M, K) numpy.ndarray) – The right-hand side vector or matrix. M should be the number of rows in A if transpose=False, otherwise the number of columns.

  • transpose (bool, optional) – Whether to solve the transposed system. Default is False.

  • min2norm (bool, optional) – If True, compute the minimum 2-norm solution when A is underdetermined. transpose is ignored in this case. Default is True. If False, the solution of an underdetermined system is not guaranteed to be the minimum 2-norm solution.

  • 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. N is the number of columns in A if transpose=False, otherwise the number of rows.

Notes

Part of an interface to the SuiteSparse SPQR library [1].

Added in version 0.5.0.

References