dpnp.linalg.solve

dpnp.linalg.solve(a, b)[source]

Solve a linear matrix equation, or system of linear scalar equations.

For full documentation refer to numpy.linalg.solve.

Parameters:
  • a ((..., M, M) {dpnp.ndarray, usm_ndarray}) -- Coefficient matrix.

  • b ({(M,), (..., M, K)} {dpnp.ndarray, usm_ndarray}) -- Ordinate or "dependent variable" values.

Returns:

out -- Solution to the system ax = b. Returned shape is identical to b.

Return type:

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

See also

dpnp.dot

Returns the dot product of two arrays.

Notes

The b array is only treated as a shape (M,) column vector if it is exactly 1-dimensional. In all other instances it is treated as a stack of (M, K) matrices.

Examples

>>> import dpnp as dp
>>> a = dp.array([[1, 2], [3, 5]])
>>> b = dp.array([1, 2])
>>> x = dp.linalg.solve(a, b)
>>> x
array([-1.,  1.])

Check that the solution is correct:

>>> dp.allclose(dp.dot(a, x), b)
array([ True])