Skip to content

Add element-wise comparison APIs #28

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

Merged
merged 1 commit into from
Sep 8, 2020
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
144 changes: 144 additions & 0 deletions spec/API_specification/elementwise_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ Calculates the division for each element `x1_i` of the input array `x1` with the

#### Returns

- **out**: _<array>_

- an array containing the element-wise results.

### <a name="equal" href="#equal">#</a> equal(x1, x2, /, *, out=None)

Computes the truth value of `x1_i == x2_i` for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.

#### Parameters

- **x1**: _&lt;array&gt;_

- first input array.

- **x2**: _&lt;array&gt;_

- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).

- **out**: _Optional\[ &lt;array&gt; ]_

- output array. If provided, the output array must be compatible with the provided input arrays (see :ref:`broadcasting`). If not provided or is `None`, an uninitialized return array, whose underlying data type is `bool`, must be created and then filled with the result of each element-wise computation. Default: `None`.

#### Returns

- **out**: _&lt;array&gt;_

- an array containing the element-wise results.
Expand Down Expand Up @@ -368,6 +392,102 @@ Rounds each element `x_i` of the input array `x` to the greatest (i.e., closest

- an array containing the rounded result for each element in `x`.

### <a name="greater" href="#greater">#</a> greater(x1, x2, /, *, out=None)

Computes the truth value of `x1_i > x2_i` for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.

#### Parameters

- **x1**: _&lt;array&gt;_

- first input array.

- **x2**: _&lt;array&gt;_

- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).

- **out**: _Optional\[ &lt;array&gt; ]_

- output array. If provided, the output array must be compatible with the provided input arrays (see :ref:`broadcasting`). If not provided or is `None`, an uninitialized return array, whose underlying data type is `bool`, must be created and then filled with the result of each element-wise computation. Default: `None`.

#### Returns

- **out**: _&lt;array&gt;_

- an array containing the element-wise results.

### <a name="greater_equal" href="#greater_equal">#</a> greater_equal(x1, x2, /, *, out=None)

Computes the truth value of `x1_i >= x2_i` for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.

#### Parameters

- **x1**: _&lt;array&gt;_

- first input array.

- **x2**: _&lt;array&gt;_

- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).

- **out**: _Optional\[ &lt;array&gt; ]_

- output array. If provided, the output array must be compatible with the provided input arrays (see :ref:`broadcasting`). If not provided or is `None`, an uninitialized return array, whose underlying data type is `bool`, must be created and then filled with the result of each element-wise computation. Default: `None`.

#### Returns

- **out**: _&lt;array&gt;_

- an array containing the element-wise results.

### <a name="less" href="#less">#</a> less(x1, x2, /, *, out=None)

Computes the truth value of `x1_i < x2_i` for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.

#### Parameters

- **x1**: _&lt;array&gt;_

- first input array.

- **x2**: _&lt;array&gt;_

- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).

- **out**: _Optional\[ &lt;array&gt; ]_

- output array. If provided, the output array must be compatible with the provided input arrays (see :ref:`broadcasting`). If not provided or is `None`, an uninitialized return array, whose underlying data type is `bool`, must be created and then filled with the result of each element-wise computation. Default: `None`.

#### Returns

- **out**: _&lt;array&gt;_

- an array containing the element-wise results.

### <a name="less_equal" href="#less_equal">#</a> less_equal(x1, x2, /, *, out=None)

Computes the truth value of `x1_i <= x2_i` for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.

#### Parameters

- **x1**: _&lt;array&gt;_

- first input array.

- **x2**: _&lt;array&gt;_

- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).

- **out**: _Optional\[ &lt;array&gt; ]_

- output array. If provided, the output array must be compatible with the provided input arrays (see :ref:`broadcasting`). If not provided or is `None`, an uninitialized return array, whose underlying data type is `bool`, must be created and then filled with the result of each element-wise computation. Default: `None`.

#### Returns

- **out**: _&lt;array&gt;_

- an array containing the element-wise results.

### <a name="log" href="#log">#</a> log(x, /, *, out=None)

Calculates an implementation-dependent approximation to the natural (base `e`) logarithm, having domain `[0, +infinity]` and codomain `[-infinity, +infinity]`, for each element `x_i` of the input array `x`.
Expand Down Expand Up @@ -420,6 +540,30 @@ Calculates the product for each element `x1_i` of the input array `x1` with the

- an array containing the element-wise products.

### <a name="not_equal" href="#not_equal">#</a> not_equal(x1, x2, /, *, out=None)

Computes the truth value of `x1_i != x2_i` for each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`.

#### Parameters

- **x1**: _&lt;array&gt;_

- first input array.

- **x2**: _&lt;array&gt;_

- second input array. Must be compatible with `x1` (see :ref:`broadcasting`).

- **out**: _Optional\[ &lt;array&gt; ]_

- output array. If provided, the output array must be compatible with the provided input arrays (see :ref:`broadcasting`). If not provided or is `None`, an uninitialized return array, whose underlying data type is `bool`, must be created and then filled with the result of each element-wise computation. Default: `None`.

#### Returns

- **out**: _&lt;array&gt;_

- an array containing the element-wise results.

### <a name="round" href="#round">#</a> round(x, /, *, out=None)

Rounds each element `x_i` of the input array `x` to the nearest integer-valued number.
Expand Down