vector_norm — Python array API standard 2024.12 documentation (original) (raw)

vector_norm(x: array, /, *, axis: int | Tuple[int, ...] | None = None, keepdims: bool = False, ord: int | float | ~typing.Literal[inf, -inf] = 2) → array

Computes the vector norm of a vector (or batch of vectors) x.

Parameters:

Returns:

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.