bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / linalg / vector_norm
_ArrayFunctionDispatcher
numpy.linalg:vector_norm
source: build-install/usr/lib/python3.14/site-packages/numpy/linalg/_linalg.py :3509
Signature
def vector_norm ( x , / , axis = None , keepdims = False , ord = 2 ) Summary
Computes the vector norm of a vector (or batch of vectors) x.
Extended Summary
This function is Array API compatible.
Parameters
x: array_likeInput array.
axis: {None, int, 2-tuple of ints}, optionalIf an integer,
axisspecifies the axis (dimension) along which to compute vector norms. If an n-tuple,axisspecifies the axes (dimensions) along which to compute batched vector norms. IfNone, the vector norm must be computed over all array values (i.e., equivalent to computing the vector norm of a flattened array). Default:None.keepdims: bool, optionalIf this is set to True, the axes which are normed over are left in the result as dimensions with size one. Default: False.
ord: {int, float, inf, -inf}, optionalThe order of the norm. For details see the table under
Notesin numpy.linalg.norm.
Examples
from numpy import linalg as LA a = np.arange(9) + 1 a b = a.reshape((3, 3)) b✓
LA.vector_norm(b) LA.vector_norm(b, ord=np.inf) LA.vector_norm(b, ord=-np.inf)✗
LA.vector_norm(b, ord=0) LA.vector_norm(b, ord=1) LA.vector_norm(b, ord=-1) LA.vector_norm(b, ord=2) LA.vector_norm(b, ord=-2)✗
See also
- numpy.linalg.norm
Generic norm function
Aliases
-
numpy.linalg.vector_norm