|
63 | 63 | "dpnp_floor_divide", |
64 | 64 | "dpnp_greater", |
65 | 65 | "dpnp_greater_equal", |
| 66 | + "dpnp_imag", |
66 | 67 | "dpnp_invert", |
67 | 68 | "dpnp_isfinite", |
68 | 69 | "dpnp_isinf", |
|
80 | 81 | "dpnp_not_equal", |
81 | 82 | "dpnp_power", |
82 | 83 | "dpnp_proj", |
| 84 | + "dpnp_real", |
83 | 85 | "dpnp_remainder", |
84 | 86 | "dpnp_right_shift", |
85 | 87 | "dpnp_round", |
@@ -1259,6 +1261,46 @@ def dpnp_greater_equal(x1, x2, out=None, order="K"): |
1259 | 1261 | return dpnp_array._create_from_usm_ndarray(res_usm) |
1260 | 1262 |
|
1261 | 1263 |
|
| 1264 | +_imag_docstring = """ |
| 1265 | +imag(x, out=None, order="K") |
| 1266 | +
|
| 1267 | +Computes imaginary part of each element `x_i` for input array `x`. |
| 1268 | +
|
| 1269 | +Args: |
| 1270 | + x (dpnp.ndarray): |
| 1271 | + Input array, expected to have numeric data type. |
| 1272 | + out ({None, dpnp.ndarray}, optional): |
| 1273 | + Output array to populate. |
| 1274 | + Array have the correct shape and the expected data type. |
| 1275 | + order ("C","F","A","K", optional): |
| 1276 | + Memory layout of the newly output array, if parameter `out` is `None`. |
| 1277 | + Default: "K". |
| 1278 | +Returns: |
| 1279 | + dpnp.ndarray: |
| 1280 | + An array containing the element-wise imaginary component of input. |
| 1281 | + If the input is a real-valued data type, the returned array has |
| 1282 | + the same datat type. If the input is a complex floating-point |
| 1283 | + data type, the returned array has a floating-point data type |
| 1284 | + with the same floating-point precision as complex input. |
| 1285 | +""" |
| 1286 | + |
| 1287 | + |
| 1288 | +imag_func = UnaryElementwiseFunc( |
| 1289 | + "imag", ti._imag_result_type, ti._imag, _imag_docstring |
| 1290 | +) |
| 1291 | + |
| 1292 | + |
| 1293 | +def dpnp_imag(x, out=None, order="K"): |
| 1294 | + """Invokes imag() from dpctl.tensor implementation for imag() function.""" |
| 1295 | + |
| 1296 | + # dpctl.tensor only works with usm_ndarray |
| 1297 | + x1_usm = dpnp.get_usm_ndarray(x) |
| 1298 | + out_usm = None if out is None else dpnp.get_usm_ndarray(out) |
| 1299 | + |
| 1300 | + res_usm = imag_func(x1_usm, out=out_usm, order=order) |
| 1301 | + return dpnp_array._create_from_usm_ndarray(res_usm) |
| 1302 | + |
| 1303 | + |
1262 | 1304 | _invert_docstring = """ |
1263 | 1305 | invert(x, out=None, order='K') |
1264 | 1306 |
|
@@ -2021,6 +2063,46 @@ def dpnp_proj(x, out=None, order="K"): |
2021 | 2063 | return dpnp_array._create_from_usm_ndarray(res_usm) |
2022 | 2064 |
|
2023 | 2065 |
|
| 2066 | +_real_docstring = """ |
| 2067 | +real(x, out=None, order="K") |
| 2068 | +
|
| 2069 | +Computes real part of each element `x_i` for input array `x`. |
| 2070 | +
|
| 2071 | +Args: |
| 2072 | + x (dpnp.ndarray): |
| 2073 | + Input array, expected to have numeric data type. |
| 2074 | + out ({None, dpnp.ndarray}, optional): |
| 2075 | + Output array to populate. |
| 2076 | + Array have the correct shape and the expected data type. |
| 2077 | + order ("C","F","A","K", optional): |
| 2078 | + Memory layout of the newly output array, if parameter `out` is `None`. |
| 2079 | + Default: "K". |
| 2080 | +Returns: |
| 2081 | + dpnp.ndarray: |
| 2082 | + An array containing the element-wise real component of input. |
| 2083 | + If the input is a real-valued data type, the returned array has |
| 2084 | + the same datat type. If the input is a complex floating-point |
| 2085 | + data type, the returned array has a floating-point data type |
| 2086 | + with the same floating-point precision as complex input. |
| 2087 | +""" |
| 2088 | + |
| 2089 | + |
| 2090 | +real_func = UnaryElementwiseFunc( |
| 2091 | + "real", ti._real_result_type, ti._real, _real_docstring |
| 2092 | +) |
| 2093 | + |
| 2094 | + |
| 2095 | +def dpnp_real(x, out=None, order="K"): |
| 2096 | + """Invokes real() from dpctl.tensor implementation for real() function.""" |
| 2097 | + |
| 2098 | + # dpctl.tensor only works with usm_ndarray |
| 2099 | + x1_usm = dpnp.get_usm_ndarray(x) |
| 2100 | + out_usm = None if out is None else dpnp.get_usm_ndarray(out) |
| 2101 | + |
| 2102 | + res_usm = real_func(x1_usm, out=out_usm, order=order) |
| 2103 | + return dpnp_array._create_from_usm_ndarray(res_usm) |
| 2104 | + |
| 2105 | + |
2024 | 2106 | _remainder_docstring_ = """ |
2025 | 2107 | remainder(x1, x2, out=None, order='K') |
2026 | 2108 | Calculates the remainder of division for each element `x1_i` of the input array |
|
0 commit comments