Skip to content

Commit

Permalink
Added modf API in ivy/experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
RakshitKumar04 committed Jun 28, 2023
1 parent 1f51432 commit b729284
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ivy/functional/ivy/experimental/elementwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,3 +1135,39 @@ def frexp(
(ivy.array([0.5, 0.5, 0.75]), ivy.array([1, 2, 2]))
"""
return ivy.current_backend(x).frexp(x, out=out)


@handle_exceptions
@handle_nestable
@handle_array_like_without_promotion
@handle_out_argument
@to_native_arrays_and_back
def modf(
x: Union[ivy.Array, ivy.NativeArray],
/,
*,
out: Optional[Tuple[ivy.Array, ivy.Array]] = None,
) -> Tuple[ivy.Array, ivy.Array]:
"""
Decompose the elements of x into fractional and integral parts.
Parameters
----------
x
Input array.
out
Optional output array for writing the result to.
It must have a shape that the inputs broadcast to.
Returns
-------
ret
A tuple of two arrays, the fractional and integral parts.
Examples
--------
>>> x = ivy.array([1.5, 2.7, 3.9])
>>> ivy.modf(x)
(ivy.array([0.5, 0.7, 0.9]), ivy.array([1, 2, 3]))
"""
return ivy.current_backend(x).modf(x, out=out)

0 comments on commit b729284

Please sign in to comment.