symjax.tensor.linalg.lu_solve

symjax.tensor.linalg.lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True)[source]

Solve an equation system, a x = b, given the LU factorization of a

LAX-backend implementation of lu_solve(). Original docstring below.

Parameters:
  • b (array) – Right-hand side
  • trans ({0, 1, 2}, optional) – Type of system to solve:
  • overwrite_b (bool, optional) – Whether to overwrite data in b (may increase performance)
  • check_finite (bool, optional) – Whether to check that the input matrices contain only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.
Returns:

x – Solution to the system

Return type:

array

See also

lu_factor()
LU factorize a matrix

Examples

>>> from scipy.linalg import lu_factor, lu_solve
>>> A = np.array([[2, 5, 8, 7], [5, 2, 2, 8], [7, 5, 6, 6], [5, 4, 4, 8]])
>>> b = np.array([1, 1, 1, 1])
>>> lu, piv = lu_factor(A)
>>> x = lu_solve((lu, piv), b)
>>> np.allclose(A @ x - b, np.zeros((4,)))
True