Skip to content

Commit ac7ef85

Browse files
authored
DOC: linalg.norm/vector_norm: note other supported values of ord (numpy#27714)
* DOC: linalg.norm/vector_norm: note other supported values of `ord` * DOC: add example of `ord=0` to `vector_norm`
1 parent cf67a4c commit ac7ef85

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

numpy/linalg/_linalg.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,8 +2587,9 @@ def norm(x, ord=None, axis=None, keepdims=False):
25872587
Input array. If `axis` is None, `x` must be 1-D or 2-D, unless `ord`
25882588
is None. If both `axis` and `ord` are None, the 2-norm of
25892589
``x.ravel`` will be returned.
2590-
ord : {non-zero int, inf, -inf, 'fro', 'nuc'}, optional
2591-
Order of the norm (see table under ``Notes``). inf means numpy's
2590+
ord : {int, float, inf, -inf, 'fro', 'nuc'}, optional
2591+
Order of the norm (see table under ``Notes`` for what values are
2592+
supported for matrices and vectors respectively). inf means numpy's
25922593
`inf` object. The default is None.
25932594
axis : {None, int, 2-tuple of ints}, optional.
25942595
If `axis` is an integer, it specifies the axis of `x` along which to
@@ -3498,7 +3499,7 @@ def vector_norm(x, /, *, axis=None, keepdims=False, ord=2):
34983499
keepdims : bool, optional
34993500
If this is set to True, the axes which are normed over are left in
35003501
the result as dimensions with size one. Default: False.
3501-
ord : {1, -1, 2, -2, inf, -inf, 'fro', 'nuc'}, optional
3502+
ord : {int, float, inf, -inf}, optional
35023503
The order of the norm. For details see the table under ``Notes``
35033504
in `numpy.linalg.norm`.
35043505
@@ -3525,6 +3526,8 @@ def vector_norm(x, /, *, axis=None, keepdims=False, ord=2):
35253526
>>> LA.vector_norm(b, ord=-np.inf)
35263527
1.0
35273528
3529+
>>> LA.vector_norm(b, ord=0)
3530+
9.0
35283531
>>> LA.vector_norm(b, ord=1)
35293532
45.0
35303533
>>> LA.vector_norm(b, ord=-1)

0 commit comments

Comments
 (0)