@@ -1390,6 +1390,49 @@ def dpnp_multiply(x1, x2, out=None, order="K"):
1390
1390
return dpnp_array ._create_from_usm_ndarray (res_usm )
1391
1391
1392
1392
1393
+ _negative_docstring = """
1394
+ negative(x, out=None, order="K")
1395
+
1396
+ Computes the numerical negative for each element `x_i` of input array `x`.
1397
+
1398
+ Args:
1399
+ x (dpnp.ndarray):
1400
+ Input array, expected to have numeric data type.
1401
+ out ({None, dpnp.ndarray}, optional):
1402
+ Output array to populate.
1403
+ Array have the correct shape and the expected data type.
1404
+ order ("C","F","A","K", optional):
1405
+ Memory layout of the newly output array, if parameter `out` is `None`.
1406
+ Default: "K".
1407
+ Returns:
1408
+ dpnp.ndarray:
1409
+ An array containing the negative of `x`.
1410
+ """
1411
+
1412
+
1413
+ negative_func = UnaryElementwiseFunc (
1414
+ "negative" , ti ._negative_result_type , ti ._negative , _negative_docstring
1415
+ )
1416
+
1417
+
1418
+ def dpnp_negative (x , out = None , order = "K" ):
1419
+ """Invokes negative() from dpctl.tensor implementation for negative() function."""
1420
+
1421
+ # TODO: discuss with dpctl if the check is needed to be moved there
1422
+ if not dpnp .isscalar (x ) and x .dtype == dpnp .bool :
1423
+ raise TypeError (
1424
+ "DPNP boolean negative, the `-` operator, is not supported, "
1425
+ "use the `~` operator or the logical_not function instead."
1426
+ )
1427
+
1428
+ # dpctl.tensor only works with usm_ndarray
1429
+ x1_usm = dpnp .get_usm_ndarray (x )
1430
+ out_usm = None if out is None else dpnp .get_usm_ndarray (out )
1431
+
1432
+ res_usm = negative_func (x1_usm , out = out_usm , order = order )
1433
+ return dpnp_array ._create_from_usm_ndarray (res_usm )
1434
+
1435
+
1393
1436
_not_equal_docstring_ = """
1394
1437
not_equal(x1, x2, out=None, order="K")
1395
1438
@@ -1525,6 +1568,51 @@ def dpnp_right_shift(x1, x2, out=None, order="K"):
1525
1568
return dpnp_array ._create_from_usm_ndarray (res_usm )
1526
1569
1527
1570
1571
+ _sign_docstring = """
1572
+ sign(x, out=None, order="K")
1573
+
1574
+ Computes an indication of the sign of each element `x_i` of input array `x`
1575
+ using the signum function.
1576
+
1577
+ The signum function returns `-1` if `x_i` is less than `0`,
1578
+ `0` if `x_i` is equal to `0`, and `1` if `x_i` is greater than `0`.
1579
+
1580
+ Args:
1581
+ x (dpnp.ndarray):
1582
+ Input array, expected to have numeric data type.
1583
+ out ({None, dpnp.ndarray}, optional):
1584
+ Output array to populate.
1585
+ Array have the correct shape and the expected data type.
1586
+ order ("C","F","A","K", optional):
1587
+ Memory layout of the newly output array, if parameter `out` is `None`.
1588
+ Default: "K".
1589
+ Returns:
1590
+ dpnp.ndarray:
1591
+ An array containing the element-wise results. The data type of the
1592
+ returned array is determined by the Type Promotion Rules.
1593
+ """
1594
+
1595
+
1596
+ sign_func = UnaryElementwiseFunc (
1597
+ "sign" , ti ._sign_result_type , ti ._sign , _sign_docstring
1598
+ )
1599
+
1600
+
1601
+ def dpnp_sign (x , out = None , order = "K" ):
1602
+ """Invokes sign() from dpctl.tensor implementation for sign() function."""
1603
+
1604
+ # TODO: discuss with dpctl if the check is needed to be moved there
1605
+ if not dpnp .isscalar (x ) and x .dtype == dpnp .bool :
1606
+ raise TypeError ("DPNP boolean sign is not supported." )
1607
+
1608
+ # dpctl.tensor only works with usm_ndarray
1609
+ x1_usm = dpnp .get_usm_ndarray (x )
1610
+ out_usm = None if out is None else dpnp .get_usm_ndarray (out )
1611
+
1612
+ res_usm = sign_func (x1_usm , out = out_usm , order = order )
1613
+ return dpnp_array ._create_from_usm_ndarray (res_usm )
1614
+
1615
+
1528
1616
_sin_docstring = """
1529
1617
sin(x, out=None, order='K')
1530
1618
Computes sine for each element `x_i` of input array `x`.
0 commit comments