Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add complex number support to square #552

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions spec/API_specification/array_api/elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1713,13 +1713,22 @@ def sinh(x: array, /) -> array:
"""

def square(x: array, /) -> array:
"""
Squares (``x_i * x_i``) each element ``x_i`` of the input array ``x``.
r"""
Squares each element ``x_i`` of the input array ``x``.

The square of a number ``x_i`` is defined as

.. math::
x_i^2 = x_i \cdot x_i

**Special cases**

For floating-point operands, special cases must be handled as if the operation is implemented as ``x * x`` (see :func:`~array_api.multiply`).

Parameters
----------
x: array
input array. Should have a real-valued data type.
input array. Should have a numeric data type.

Returns
-------
Expand Down