You are viewing an older version (2.4.3).Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / linalg / matrix_norm

_ArrayFunctionDispatcher

numpy.linalg:matrix_norm

source: /numpy/linalg/_linalg.py:3446

Signature

def matrix_norm(x, /, keepdims = False, ord = fro)

Summary

Computes the matrix norm of a matrix (or a stack of matrices) x.

Extended Summary

This function is Array API compatible.

Parameters

x : array_like

Input array having shape (..., M, N) and whose two innermost dimensions form MxN matrices.

keepdims : bool, optional

If this is set to True, the axes which are normed over are left in the result as dimensions with size one. Default: False.

ord : {1, -1, 2, -2, inf, -inf, 'fro', 'nuc'}, optional

The order of the norm. For details see the table under Notes in numpy.linalg.norm.

Examples

from numpy import linalg as LA
a = np.arange(9) - 4
a
b = a.reshape((3, 3))
b
✓
array([[-4, -3, -2],
       [-1,  0,  1],
       [ 2,  3,  4]])
LA.matrix_norm(b)
LA.matrix_norm(b, ord='fro')
LA.matrix_norm(b, ord=np.inf)
LA.matrix_norm(b, ord=-np.inf)
✗
np.float64(2.0)
LA.matrix_norm(b, ord=1)
LA.matrix_norm(b, ord=-1)
LA.matrix_norm(b, ord=2)
LA.matrix_norm(b, ord=-2)
✗
np.float64(3.757577037301703e-16)

See also

numpy.linalg.norm

Generic norm function

Aliases

  • numpy.linalg.matrix_norm