Skip to content

Commit

Permalink
feat(docs): add example to clip_vector_norm doc (#26657)
Browse files Browse the repository at this point in the history
Co-authored-by: ivy-branch <ivy.branch@lets-unify.ai>
  • Loading branch information
monsterdevgit and ivy-branch authored Oct 14, 2023
1 parent 6256fc4 commit 971bafe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ivy/functional/ivy/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,18 @@ def clip_vector_norm(
a: ivy.array([0., 0.894, 1.79]),
b: ivy.array([0.849, 1.13, 1.41])
}
With multiple :class:`ivy.Container` inputs:
>>> x = ivy.Container(a=ivy.array([0., 1., 2.]),
... b=ivy.array([3., 4., 5.]))
>>> max_norm = ivy.Container(a=2, b=3)
>>> y = ivy.clip_vector_norm(x, max_norm)
>>> print(y)
{
a: ivy.array([0., 0.894, 1.79]),
b: ivy.array([2.449, 2.65, 2.83])
}
"""
norm = ivy.vector_norm(x, keepdims=True, ord=p)
ratio = ivy.stable_divide(max_norm, norm)
Expand Down

0 comments on commit 971bafe

Please sign in to comment.