dpnp.scipy.linalg.lu_solve

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

Solve a linear system, \(a x = b\), given the LU factorization of a.

For full documentation refer to scipy.linalg.lu_solve.

Parameters:
lu, piv{tuple of dpnp.ndarrays or usm_ndarrays}

LU factorization of matrix a (..., M, M) together with pivot indices.

b{(M,), (..., M, K)} {dpnp.ndarray, usm_ndarray}

Right-hand side.

trans{0, 1, 2} , optional

Type of system to solve:

trans

system

0

\(a x = b\)

1

\(a^T x = b\)

2

\(a^H x = b\)

Default: 0.

overwrite_bbool, optional

Whether to overwrite data in b (may increase performance).

Default: False.

check_finitebool, optional

Whether to check that the input matrix contains 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.

Default: True.

Returns:
x{(M,), (..., M, K)} dpnp.ndarray

Solution to the system

Warning

This function synchronizes in order to validate array elements when check_finite=True.

See also

dpnp.scipy.linalg.lu_factor()

LU factorize a matrix.

Examples

>>> import dpnp as np
>>> 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 = np.scipy.linalg.lu_factor(A)
>>> x = np.scipy.linalg.lu_solve((lu, piv), b)
>>> np.allclose(A @ x - b, np.zeros((4,)))
array(True)