Skip to content

Commit afda756

Browse files
committed
Add python implementation
1 parent 5fa19f2 commit afda756

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

doc/reference/special.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ Error function and Fresnel integrals
1515
erf
1616
erfc
1717
erfcx
18-
erfi
1918
erfinv
2019
erfcinv

dpnp/special/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@
4242
from ._erf import (
4343
erf,
4444
erfc,
45+
erfcx,
4546
)
4647

4748
__all__ = [
4849
"erf",
4950
"erfc",
51+
"erfcx",
5052
]

dpnp/special/_erf.py

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import dpnp.backend.extensions.ufunc._ufunc_impl as ufi
4343
from dpnp.dpnp_algo.dpnp_elementwise_common import DPNPUnaryFunc
4444

45-
__all__ = ["erf", "erfc"]
45+
__all__ = ["erf", "erfc", "erfcx"]
4646

4747

4848
# pylint: disable=too-few-public-methods
@@ -96,7 +96,6 @@ def __call__(self, x, out=None): # pylint: disable=signature-differs
9696
:obj:`dpnp.special.erfinv` : Inverse of the error function.
9797
:obj:`dpnp.special.erfcinv` : Inverse of the complementary error function.
9898
:obj:`dpnp.special.erfcx` : Scaled complementary error function.
99-
:obj:`dpnp.special.erfi` : Imaginary error function.
10099
101100
Notes
102101
-----
@@ -152,7 +151,6 @@ def __call__(self, x, out=None): # pylint: disable=signature-differs
152151
:obj:`dpnp.special.erfinv` : Inverse of the error function.
153152
:obj:`dpnp.special.erfcinv` : Inverse of the complementary error function.
154153
:obj:`dpnp.special.erfcx` : Scaled complementary error function.
155-
:obj:`dpnp.special.erfi` : Imaginary error function.
156154
157155
Examples
158156
--------
@@ -171,3 +169,48 @@ def __call__(self, x, out=None): # pylint: disable=signature-differs
171169
mkl_fn_to_call="_mkl_erf_to_call",
172170
mkl_impl_fn="_erfc",
173171
)
172+
173+
_ERFCX_DOCSTRING = r"""
174+
Calculates the scaled complementary error function of a given input array.
175+
176+
It is defined as :math:`\exp(x^2) * \operatorname{erfc}(x)`.
177+
178+
For full documentation refer to :obj:`scipy.special.erfcx`.
179+
180+
Parameters
181+
----------
182+
x : {dpnp.ndarray, usm_ndarray}
183+
Input array, expected to have a real-valued floating-point data type.
184+
out : {dpnp.ndarray, usm_ndarray}, optional
185+
Optional output array for the function values.
186+
187+
Returns
188+
-------
189+
out : dpnp.ndarray
190+
The values of the scaled complementary error function at the given points
191+
`x`.
192+
193+
See Also
194+
--------
195+
:obj:`dpnp.special.erf` : Gauss error function.
196+
:obj:`dpnp.special.erfc` : Complementary error function.
197+
:obj:`dpnp.special.erfinv` : Inverse of the error function.
198+
:obj:`dpnp.special.erfcinv` : Inverse of the complementary error function.
199+
200+
Examples
201+
--------
202+
>>> import dpnp as np
203+
>>> x = np.linspace(-3, 3, num=4)
204+
>>> np.special.erfcx(x)
205+
array([1.62059889e+04, 5.00898008e+00, 4.27583576e-01, 1.79001151e-01])
206+
207+
"""
208+
209+
erfcx = DPNPErf(
210+
"erfcx",
211+
ufi._erf_result_type,
212+
ufi._erfcx,
213+
_ERFCX_DOCSTRING,
214+
mkl_fn_to_call="_mkl_erf_to_call",
215+
mkl_impl_fn="_erfcx",
216+
)

0 commit comments

Comments
 (0)