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 support for complex number subtraction #526

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions spec/API_specification/array_api/array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,14 +914,16 @@ def __setitem__(self: array, key: Union[int, slice, ellipsis, Tuple[Union[int, s

def __sub__(self: array, other: Union[int, float, array], /) -> array:
"""
Calculates the difference for each element of an array instance with the respective element of the array ``other``. The result of ``self_i - other_i`` must be the same as ``self_i + (-other_i)`` and must be governed by the same floating-point rules as addition (see :meth:`array.__add__`).
Calculates the difference for each element of an array instance with the respective element of the array ``other``.

The result of ``self_i - other_i`` must be the same as ``self_i + (-other_i)`` and must be governed by the same floating-point rules as addition (see :meth:`array.__add__`).

Parameters
----------
self: array
array instance (minuend array). Should have a real-valued data type.
array instance (minuend array). Should have a numeric data type.
other: Union[int, float, array]
subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a real-valued data type.
subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.

Returns
-------
Expand Down
8 changes: 5 additions & 3 deletions spec/API_specification/array_api/elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,14 +1535,16 @@ def sqrt(x: array, /) -> array:

def subtract(x1: array, x2: array, /) -> array:
"""
Calculates the difference for each element ``x1_i`` of the input array ``x1`` with the respective element ``x2_i`` of the input array ``x2``. The result of ``x1_i - x2_i`` must be the same as ``x1_i + (-x2_i)`` and must be governed by the same floating-point rules as addition (see :meth:`add`).
Calculates the difference for each element ``x1_i`` of the input array ``x1`` with the respective element ``x2_i`` of the input array ``x2``.

The result of ``x1_i - x2_i`` must be the same as ``x1_i + (-x2_i)`` and must be governed by the same floating-point rules as addition (see :meth:`add`).

Parameters
----------
x1: array
first input array. Should have a real-valued data type.
first input array. Should have a numeric data type.
x2: array
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type.
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a numeric data type.

Returns
-------
Expand Down