dpnp.linalg.matrix_norm
- dpnp.linalg.matrix_norm(x, /, *, keepdims=False, ord='fro')[source]
Computes the matrix norm of a matrix (or a stack of matrices) x.
This function is Array API compatible.
For full documentation refer to
numpy.linalg.matrix_norm.- Parameters:
x ({dpnp.ndarray, usm_ndarray}) -- Input array having shape (..., M, N) and whose two innermost dimensions form
MxNmatrices.keepdims ({None, bool}, optional) --
If this is set to
True, the axes which are normed over are left in the result as dimensions with size one. With this option the result will broadcast correctly against the original x.Default:
False.ord ({None, 1, -1, 2, -2, dpnp.inf, -dpnp.inf, 'fro', 'nuc'}, optional) --
The order of the norm. For details see the table under
Notessection indpnp.linalg.norm.Default:
"fro".
- Returns:
out -- Norm of the matrix.
- Return type:
dpnp.ndarray
See also
dpnp.linalg.normGeneric norm function.
Examples
>>> import dpnp as np >>> a = np.arange(9) - 4 >>> a array([-4, -3, -2, -1, 0, 1, 2, 3, 4]) >>> b = a.reshape((3, 3)) >>> b array([[-4, -3, -2], [-1, 0, 1], [ 2, 3, 4]])
>>> np.linalg.matrix_norm(b) array(7.74596669) >>> np.linalg.matrix_norm(b, ord='fro') array(7.74596669) >>> np.linalg.matrix_norm(b, ord=np.inf) array(9.) >>> np.linalg.matrix_norm(b, ord=-np.inf) array(2.)
>>> np.linalg.matrix_norm(b, ord=1) array(7.) >>> np.linalg.matrix_norm(b, ord=-1) array(6.) >>> np.linalg.matrix_norm(b, ord=2) array(7.34846923) >>> np.linalg.matrix_norm(b, ord=-2) array(4.35106603e-18) # may vary