Computes the vector norm of a vector (or batch of vectors) x
.
x (array) – input array. Should have a floating-point data type.
axis (Optional[Union[int, Tuple[int, ...]]]) – If an integer, axis
specifies the axis (dimension) along which to compute vector norms. If an n-tuple, axis
specifies the axes (dimensions) along which to compute batched vector norms. If None
, the vector norm must be computed over all array values (i.e., equivalent to computing the vector norm of a flattened array). Negative indices must be supported. Default: None
.
keepdims (bool) – If True
, the axes (dimensions) specified by axis
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 axes (dimensions) specified by axis
must not be included in the result. Default: False
.
ord (Union[int, float, Literal[inf, -inf]]) –
order of the norm. The following mathematical norms must be supported:
ord
description
1
L1-norm (Manhattan)
2
L2-norm (Euclidean)
inf
infinity norm
(int,float >= 1)
p-norm
The following non-mathematical “norms” must be supported:
ord
description
0
sum(a != 0)
-1
1./sum(1./abs(a))
-2
1./sqrt(sum(1./abs(a)**2))
-inf
min(abs(a))
(int,float < 1)
sum(abs(a)**ord)**(1./ord)
Default: 2
.
out (array) – an array containing the vector norms. If axis
is None
, the returned array must be a zero-dimensional array containing a vector norm. If axis
is a scalar value (int
or float
), the returned array must have a rank which is one less than the rank of x
. If axis
is a n
-tuple, the returned array must have a rank which is n
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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4