|
73 | 73 | DPNPRound, |
74 | 74 | DPNPSinc, |
75 | 75 | DPNPUnaryFunc, |
| 76 | + DPNPUnaryTwoOutputsFunc, |
76 | 77 | acceptance_fn_gcd_lcm, |
77 | 78 | acceptance_fn_negative, |
78 | 79 | acceptance_fn_positive, |
|
112 | 113 | "fmax", |
113 | 114 | "fmin", |
114 | 115 | "fmod", |
| 116 | + "frexp", |
115 | 117 | "gcd", |
116 | 118 | "gradient", |
117 | 119 | "heaviside", |
@@ -2342,6 +2344,77 @@ def ediff1d(ary, to_end=None, to_begin=None): |
2342 | 2344 | mkl_impl_fn="_fmod", |
2343 | 2345 | ) |
2344 | 2346 |
|
| 2347 | + |
| 2348 | +_FREXP_DOCSTRING = """ |
| 2349 | +Decompose each element :math:`x_i` of the input array `x` into the mantissa and |
| 2350 | +the twos exponent. |
| 2351 | +
|
| 2352 | +For full documentation refer to :obj:`numpy.frexp`. |
| 2353 | +
|
| 2354 | +Parameters |
| 2355 | +---------- |
| 2356 | +x : {dpnp.ndarray, usm_ndarray} |
| 2357 | + Array of numbers to be decomposed, expected to have a real-valued |
| 2358 | + floating-point data type. |
| 2359 | +out1 : {None, dpnp.ndarray, usm_ndarray}, optional |
| 2360 | + Output array for the mantissa to populate. Array must have the same shape |
| 2361 | + as `x` and the expected data type. |
| 2362 | +
|
| 2363 | + Default: ``None``. |
| 2364 | +out2 : {None, dpnp.ndarray, usm_ndarray}, optional |
| 2365 | + Output array for the exponent to populate. Array must have the same shape |
| 2366 | + as `x` and the expected data type. |
| 2367 | +
|
| 2368 | + Default: ``None``. |
| 2369 | +order : {None, "C", "F", "A", "K"}, optional |
| 2370 | + Memory layout of the newly output array, if parameter `out` is ``None``. |
| 2371 | +
|
| 2372 | + Default: ``"K"``. |
| 2373 | +
|
| 2374 | +Returns |
| 2375 | +------- |
| 2376 | +mantissa : dpnp.ndarray |
| 2377 | + Floating values between -1 and 1. |
| 2378 | +exponent : dpnp.ndarray |
| 2379 | + Integer exponents of 2. |
| 2380 | +
|
| 2381 | +Limitations |
| 2382 | +----------- |
| 2383 | +Parameters `where` and `subok` are supported with their default values. |
| 2384 | +Keyword argument `kwargs` is currently unsupported. |
| 2385 | +Otherwise ``NotImplementedError`` exception will be raised. |
| 2386 | +
|
| 2387 | +See Also |
| 2388 | +-------- |
| 2389 | +:obj:`dpnp.ldexp` : Compute :math:`y = x1 * 2^{x2}`, inverse to |
| 2390 | + :obj:`dpnp.frexp`. |
| 2391 | +
|
| 2392 | +Notes |
| 2393 | +----- |
| 2394 | +Complex dtypes are not supported, they will raise a ``TypeError``. |
| 2395 | +
|
| 2396 | +Examples |
| 2397 | +-------- |
| 2398 | +>>> import dpnp as np |
| 2399 | +>>> x = np.arange(9) |
| 2400 | +>>> y1, y2 = np.frexp(x) |
| 2401 | +>>> y1 |
| 2402 | +array([0. , 0.5 , 0.5 , 0.75 , 0.5 , 0.625, 0.75 , 0.875, 0.5 ]) |
| 2403 | +>>> y2 |
| 2404 | +array([0, 1, 2, 2, 3, 3, 3, 3, 4], dtype=int32) |
| 2405 | +>>> y1 * 2**y2 |
| 2406 | +array([0., 1., 2., 3., 4., 5., 6., 7., 8.]) |
| 2407 | +
|
| 2408 | +""" |
| 2409 | + |
| 2410 | +frexp = DPNPUnaryTwoOutputsFunc( |
| 2411 | + "_frexp", |
| 2412 | + ufi._frexp_result_type, |
| 2413 | + ufi._frexp, |
| 2414 | + _FREXP_DOCSTRING, |
| 2415 | +) |
| 2416 | + |
| 2417 | + |
2345 | 2418 | _GCD_DOCSTRING = r""" |
2346 | 2419 | Returns the greatest common divisor of :math:`\abs{x1}` and :math:`\abs{x2}`. |
2347 | 2420 |
|
|
0 commit comments