Matrix or vector norm.
Parameters: | x : array_like, shape (M,) or (M, N)
ord : {int, 1, -1, 2, -2, inf, -inf, ‘fro’}
|
---|---|
Returns: | n : float
|
Notes
For values ord < 0, the result is, strictly speaking, not a mathematical ‘norm’, but it may still be useful for numerical purposes.
The following norms can be calculated:
ord | norm for matrices | norm for vectors |
---|---|---|
None | Frobenius norm | 2-norm |
‘fro’ | Frobenius norm | – |
inf | max(sum(abs(x), axis=1)) | max(abs(x)) |
-inf | min(sum(abs(x), axis=1)) | min(abs(x)) |
1 | max(sum(abs(x), axis=0)) | as below |
-1 | min(sum(abs(x), axis=0)) | as below |
2 | 2-norm (largest sing. value) | as below |
-2 | smallest singular value | as below |
other | – | sum(abs(x)**ord)**(1./ord) |