floor_divide#
- ivy.floor_divide(x1, x2, /, *, out=None)[source]#
Round the result of dividing each element x1_i of the input array x1 by the respective element x2_i of the input array x2 to the greatest (i.e., closest to +infinity) integer-value number that is not greater than the division result.
- Parameters:
x1 (
Union
[float
,Array
,NativeArray
]) – first input array. Must have a numeric data type.x2 (
Union
[float
,Array
,NativeArray
]) – second input array. Must be compatible with x1 (with Broadcasting). Must have a numeric data type.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that the (default:None
) inputs broadcast to.
- Return type:
- Returns:
ret – an array containing the element-wise results. The returned array must have a numeric data type.
This function conforms to the Array API Standard. This docstring is an extension of the docstring # noqa in the standard.
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 argumentsExamples
With
ivy.Array
inputs:>>> x1 = ivy.array([13., 7., 8.]) >>> x2 = ivy.array([3., 2., 7.]) >>> y = ivy.floor_divide(x1, x2) >>> print(y) ivy.array([4., 3., 1.])
With mixed
ivy.Array
andivy.NativeArray
inputs:>>> x1 = ivy.array([3., 4., 5.]) >>> x2 = ivy.native_array([5., 2., 1.]) >>> y = ivy.floor_divide(x1, x2) >>> print(y) ivy.array([0., 2., 5.])
With
ivy.Container
inputs:>>> x1 = ivy.Container(a=ivy.array([4., 5., 6.]), b=ivy.array([7., 8., 9.])) >>> x2 = ivy.Container(a=ivy.array([5., 4., 2.5]), b=ivy.array([2.3, 3.7, 5])) >>> y = ivy.floor_divide(x1, x2) >>> print(y) { a: ivy.array([0., 1., 2.]), b: ivy.array([3., 2., 1.]) }
With mixed
ivy.Container
andivy.Array
inputs:>>> x1 = ivy.Container(a=ivy.array([4., 5., 6.]), b=ivy.array([7., 8., 9.])) >>> x2 = ivy.array([2., 2., 2.]) >>> y = ivy.floor_divide(x1, x2) >>> print(y) { a: ivy.array([2., 2., 3.]), b: ivy.array([3., 4., 4.]) }
- Array.floor_divide(self, x2, /, *, out=None)#
ivy.Array instance method variant of ivy.floor_divide. This method simply wraps the function, and so the docstring for ivy.floor_divide also applies to this method with minimal changes.
- Parameters:
self (
Array
) – dividend input array. Should have a real-valued data type.x2 (
Union
[Array
,NativeArray
]) – divisor input array. Must be compatible withself
(see broadcasting). Should have a real-valued data type.out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the element-wise results. The returned array must have a data type determined by type-promotion.
Examples
With
ivy.Array
inputs:>>> x1 = ivy.array([13., 7., 8.]) >>> x2 = ivy.array([3., 2., 7.]) >>> y = x1.floor_divide(x2) >>> print(y) ivy.array([4., 3., 1.])
With mixed
ivy.Array
andivy.NativeArray
inputs:>>> x1 = ivy.array([13., 7., 8.]) >>> x2 = ivy.native_array([3., 2., 7.]) >>> y = x1.floor_divide(x2) >>> print(y) ivy.array([4., 3., 1.])
- Container.floor_divide(self, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
ivy.Container instance method variant of ivy.floor_divide. This method simply wraps the function, and so the docstring for ivy.floor_divide also applies to this method with minimal changes.
- Parameters:
self (
Container
) – dividend input array or container. Should have a real-valued data type.x2 (
Union
[Container
,Array
,NativeArray
]) – divisor input array or container. Must be compatible withx1
(see broadcasting). Should have a real-valued data type.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.out (
Optional
[Container
]) – optional output container, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container containing the element-wise results. The returned container must have a data type determined by type-promotion.
Examples
With
ivy.Container
inputs:>>> x1 = ivy.Container(a=ivy.array([4., 5., 6.]), b=ivy.array([7., 8., 9.])) >>> x2 = ivy.Container(a=ivy.array([5., 4., 2.5]), b=ivy.array([2.3, 3.7, 5])) >>> y = x1.floor_divide(x2) >>> print(y) { a: ivy.array([0., 1., 2.]), b: ivy.array([3., 2., 1.]) }
With mixed
ivy.Container
andivy.Array
inputs:>>> x1 = ivy.Container(a=ivy.array([4., 5., 6.]), b=ivy.array([7., 8., 9.])) >>> x2 = ivy.array([2, 3, 4]) >>> y = x1.floor_divide(x2) >>> print(y) { a: ivy.array([2., 1., 1.]), b: ivy.array([3., 2., 2.]) }