mojolearn.lu_solve#

mojolearn.lu_solve(lu_and_piv, b, *, trans=0, numeric_mode=None)#

Solve a linear system from an LU factorization.

Follows scipy.linalg.lu_solve: solves A x = b (trans=0) or A.T x = b (trans=1 or 2; the same for a real matrix) with the pair returned by lu_factor(). A zero pivot gives 0 in that component of x, never infinity or NaN.

Parameters:
  • lu_and_piv (tuple (lu, piv)) – The output of lu_factor().

  • b (array-like of shape (n,) or (n, nrhs)) – Right-hand side.

  • trans ({0, 1, 2}, default 0) – Which system to solve.

  • numeric_mode ({“identical”, “fast”} or None, default None) – Numeric mode for this call. None uses the package default ("identical" unless changed). In identical mode, mojolearn returns the same bits on Apple, NVIDIA and AMD GPUs. "fast" is available on Apple GPUs only.

Returns:

x (ndarray of shape (n,) or (n, nrhs), float32) – Same shape as b.

Raises:

ValueError – If trans is not 0, 1 or 2, piv holds an index outside [0, n), b has the wrong number of rows, or b is not finite.