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 formMxN
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, ifFalse
, 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 wherep=1
(i.e., the maximum absolute value column sum).If
ord=2
, the norm corresponds to the induced matrix norm wherep=inf
(i.e., the maximum absolute value row sum).If
ord=inf
, the norm corresponds to the induced matrix norm wherep=2
(i.e., the largest singular value).Default:
'fro'
.
- Returns:
out (array) – an array containing the norms for each
MxN
matrix. Ifkeepdims
isFalse
, the returned array must have a rank which is two less than the rank ofx
. Ifx
has a real-valued data type, the returned array must have a real-valued floating-point data type determined by Type Promotion Rules. Ifx
has a complex-valued data type, the returned array must have a real-valued floating-point data type whose precision matches the precision ofx
(e.g., ifx
iscomplex128
, then the returned array must have afloat64
data type).
Notes
Changed in version 2022.12: Added complex data type support.