# matrix_norm¶

matrix_norm(x: array, /, *, keepdims: bool = False, ord: int | float | ~typing.Literal[inf, -inf, 'fro', 'nuc'] | None = 'fro') array

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

Parameters:
• x (array) – input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices. Should have a floating-point data type.

• keepdims (bool) – If `True`, the last two axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see Broadcasting). Otherwise, if `False`, the last two axes (dimensions) must not be included in the result. Default: `False`.

• ord (Optional[Union[int, float, Literal[inf, -inf, 'fro', 'nuc']]]) –

order of the norm. The following mathematical norms must be supported:

ord

description

’fro’

Frobenius norm

’nuc’

nuclear norm

1

max(sum(abs(x), axis=0))

2

largest singular value

inf

max(sum(abs(x), axis=1))

The following non-mathematical “norms” must be supported:

ord

description

-1

min(sum(abs(x), axis=0))

-2

smallest singular value

-inf

min(sum(abs(x), axis=1))

If `ord=1`, the norm corresponds to the induced matrix norm where `p=1` (i.e., the maximum absolute value column sum).

If `ord=2`, the norm corresponds to the induced matrix norm where `p=inf` (i.e., the maximum absolute value row sum).

If `ord=inf`, the norm corresponds to the induced matrix norm where `p=2` (i.e., the largest singular value).

Default: `'fro'`.

Returns:

out (array) – an array containing the norms for each `MxN` matrix. If `keepdims` is `False`, the returned array must have a rank which is two less than the rank of `x`. If `x` has a real-valued data type, the returned array must have a real-valued floating-point data type determined by Type Promotion Rules. If `x` has a complex-valued data type, the returned array must have a real-valued floating-point data type whose precision matches the precision of `x` (e.g., if `x` is `complex128`, then the returned array must have a `float64` data type).

Notes

Changed in version 2022.12: Added complex data type support.