inplace_decrement#
- ivy.inplace_decrement(x, val)[source]#
Perform in-place decrement for the input array.
- Parameters:
- Return type:
- Returns:
ret – The array following the in-place decrement.
Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts
ivy.Container
instances in place of any of the arguments.Examples
With
ivy.Array
input:>>> x = ivy.array([[5.3, 7., 0.],[6.8, 8, 3.9],[0., 10., 6.3]]) >>> y = ivy.inplace_decrement(x, 1.25) >>> print(y) ivy.array([[ 4.05, 5.75, -1.25], [ 5.55, 6.75, 2.65], [-1.25, 8.75, 5.05]])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([0.5, -5., 30.]), b=ivy.array([0., -25., 50.])) >>> y = ivy.inplace_decrement(x, 1.5) >>> print(y) { a: ivy.array([-1., -6.5, 28.5]), b: ivy.array([-1.5, -26.5, 48.5]) }
>>> x = ivy.Container(a=ivy.array([0., 15., 30.]), b=ivy.array([0., 25., 50.])) >>> y = ivy.Container(a=ivy.array([0., 15., 30.]), b=ivy.array([0., 25., 50.])) >>> z = ivy.inplace_decrement(x, y) >>> print(z) { a: ivy.array([0., 0., 0.]), b: ivy.array([0., 0., 0.]) }
>>> x = ivy.Container(a=ivy.array([3., 7., 10.]), b=ivy.array([0., 75., 5.5])) >>> y = ivy.Container(a=ivy.array([2., 5.5, 7.]), b=ivy.array([0., 25., 2.])) >>> z = ivy.inplace_decrement(x, y) >>> print(z) { a: ivy.array([1., 1.5, 3.]), b: ivy.array([0., 50., 3.5]) }
- Array.inplace_decrement(self, val)[source]#
ivy.Array instance method variant of ivy.inplace_decrement. This method simply wraps the function, and so the docstring for ivy.inplace_decrement also applies to this method with minimal changes.
- Parameters:
self (
Union
[Array
,NativeArray
]) – The input array to be decremented by the defined value.val (
Union
[Array
,NativeArray
]) – The value of decrement.
- Return type:
Array
- Returns:
ret – The array following an in-place decrement.
Examples
With
ivy.Array
instance methods:>>> x = ivy.array([5.7, 4.3, 2.5, 1.9]) >>> y = x.inplace_decrement(1) >>> print(y) ivy.array([4.7, 3.3, 1.5, 0.9])
>>> x = ivy.asarray([4., 5., 6.]) >>> y = x.inplace_decrement(2.5) >>> print(y) ivy.array([1.5, 2.5, 3.5])
- Container.inplace_decrement(self, val, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#
ivy.Container instance method variant of ivy.inplace_decrement. This method simply wraps the function, and so the docstring for ivy.inplace_decrement also applies to this method with minimal changes.
- Parameters:
self (
Container
) – Input container to apply an in-place decrement.val (
Union
[Array
,NativeArray
,Container
]) – The value of decrement.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.
- Return type:
Container
- Returns:
ret – A container with the array following the in-place decrement.
Examples
Using
ivy.Container
instance method: >>> x = ivy.Container(a=ivy.array([-6.7, 2.4, -8.5]), … b=ivy.array([1.5, -0.3, 0]), … c=ivy.array([-4.7, -5.4, 7.5])) >>> y = x.inplace_decrement(2) >>> print(y) {a: ivy.array([-8.7, 0.4, -10.5]), b: ivy.array([-0.5, -2.3, -2]), c: ivy.array([-6.7, -7.4, 5.5])
}