Skip to content

Commit d509f6d

Browse files
Move ti.atan()/atanh() and reuse them
1 parent 4e10a53 commit d509f6d

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

dpctl_ext/tensor/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
angle,
9191
asin,
9292
asinh,
93+
atan,
94+
atanh,
9395
)
9496
from ._reduction import (
9597
argmax,
@@ -129,6 +131,8 @@
129131
"asinh",
130132
"asnumpy",
131133
"astype",
134+
"atan",
135+
"atanh",
132136
"broadcast_arrays",
133137
"broadcast_to",
134138
"can_cast",

dpctl_ext/tensor/_elementwise_funcs.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,64 @@
178178
)
179179
del _asinh_docstring
180180

181+
# U06: ===== ATAN (x)
182+
_atan_docstring = r"""
183+
atan(x, /, \*, out=None, order='K')
184+
185+
Computes inverse tangent for each element `x_i` for input array `x`.
186+
187+
Args:
188+
x (usm_ndarray):
189+
Input array, expected to have a floating-point data type.
190+
out (Union[usm_ndarray, None], optional):
191+
Output array to populate.
192+
Array must have the correct shape and the expected data type.
193+
order ("C","F","A","K", optional):
194+
Memory layout of the new output array, if parameter
195+
`out` is ``None``.
196+
Default: "K".
197+
198+
Returns:
199+
usm_ndarray:
200+
An array containing the element-wise inverse tangent, in radians
201+
and in the closed interval :math:`[-\pi/2, \pi/2]`. The data type
202+
of the returned array is determined by the Type Promotion Rules.
203+
"""
204+
205+
atan = UnaryElementwiseFunc(
206+
"atan", ti._atan_result_type, ti._atan, _atan_docstring
207+
)
208+
del _atan_docstring
209+
210+
# U07: ===== ATANH (x)
211+
_atanh_docstring = r"""
212+
atanh(x, /, \*, out=None, order='K')
213+
214+
Computes hyperbolic inverse tangent for each element `x_i` for input array `x`.
215+
216+
Args:
217+
x (usm_ndarray):
218+
Input array, expected to have a floating-point data type.
219+
out (Union[usm_ndarray, None], optional):
220+
Output array to populate.
221+
Array must have the correct shape and the expected data type.
222+
order ("C","F","A","K", optional):
223+
Memory layout of the new output array, if parameter
224+
`out` is ``None``.
225+
Default: "K".
226+
227+
Returns:
228+
usm_ndarray:
229+
An array containing the element-wise hyperbolic inverse tangent, in
230+
radians. The data type of the returned array is determined by
231+
the Type Promotion Rules.
232+
"""
233+
234+
atanh = UnaryElementwiseFunc(
235+
"atanh", ti._atanh_result_type, ti._atanh, _atanh_docstring
236+
)
237+
del _atanh_docstring
238+
181239
# U43: ==== ANGLE (x)
182240
_angle_docstring = r"""
183241
angle(x, /, \*, out=None, order='K')

dpnp/dpnp_iface_trigonometric.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@ def _get_accumulation_res_dt(a, dtype):
481481

482482
atan = DPNPUnaryFunc(
483483
"atan",
484-
ti._atan_result_type,
485-
ti._atan,
484+
ti_ext._atan_result_type,
485+
ti_ext._atan,
486486
_ATAN_DOCSTRING,
487487
mkl_fn_to_call="_mkl_atan_to_call",
488488
mkl_impl_fn="_atan",
@@ -656,8 +656,8 @@ def _get_accumulation_res_dt(a, dtype):
656656

657657
atanh = DPNPUnaryFunc(
658658
"atanh",
659-
ti._atanh_result_type,
660-
ti._atanh,
659+
ti_ext._atanh_result_type,
660+
ti_ext._atanh,
661661
_ATANH_DOCSTRING,
662662
mkl_fn_to_call="_mkl_atanh_to_call",
663663
mkl_impl_fn="_atanh",

0 commit comments

Comments
 (0)