Skip to content

Commit 4788fc4

Browse files
committed
Add complex number support to square
1 parent 74eb089 commit 4788fc4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

spec/API_specification/array_api/elementwise_functions.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1713,13 +1713,22 @@ def sinh(x: array, /) -> array:
17131713
"""
17141714

17151715
def square(x: array, /) -> array:
1716-
"""
1717-
Squares (``x_i * x_i``) each element ``x_i`` of the input array ``x``.
1716+
r"""
1717+
Squares each element ``x_i`` of the input array ``x``.
1718+
1719+
The square of a number ``x_i`` is defined as
1720+
1721+
.. math::
1722+
x_i^2 = x_i \cdot x_i
1723+
1724+
**Special cases**
1725+
1726+
For floating-point operands, special cases must be handled as if the operation is implemented as ``x * x`` (see :func:`~array_api.multiply`).
17181727
17191728
Parameters
17201729
----------
17211730
x: array
1722-
input array. Should have a real-valued data type.
1731+
input array. Should have a numeric data type.
17231732
17241733
Returns
17251734
-------

0 commit comments

Comments
 (0)