You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calculates the difference for each element of an array instance with the respective element of the array ``other``.
1115
+
Calculates the difference for each element of an array instance with the respective element of the array ``other``.
1116
1116
1117
-
Parameters
1118
-
----------
1119
-
self: array
1120
-
array instance (minuend array). Should have a numeric data type.
1121
-
other: Union[int, float, array]
1122
-
subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
1117
+
Parameters
1118
+
----------
1119
+
self: array
1120
+
array instance (minuend array). Should have a numeric data type.
1121
+
other: Union[int, float, array]
1122
+
subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
1123
1123
1124
-
Returns
1125
-
-------
1126
-
out: array
1127
-
an array containing the element-wise differences. The returned array must have a data type determined by :ref:`type-promotion`.
1124
+
Returns
1125
+
-------
1126
+
out: array
1127
+
an array containing the element-wise differences. The returned array must have a data type determined by :ref:`type-promotion`.
1128
1128
1129
-
Notes
1130
-
-----
1129
+
Notes
1130
+
-----
1131
1131
1132
1132
- Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.subtract`.
1133
1133
- 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 an implementation-dependent approximation of exponentiation by raising each element ``x1_i`` (the base) of the input array ``x1`` to the power of ``x2_i`` (the exponent), where ``x2_i`` is the corresponding element of the input array ``x2``.
2274
+
Calculates an implementation-dependent approximation of exponentiation by raising each element ``x1_i`` (the base) of the input array ``x1`` to the power of ``x2_i`` (the exponent), where ``x2_i`` is the corresponding element of the input array ``x2``.
2275
2275
2276
-
Parameters
2277
-
----------
2278
-
x1: Union[array, int, float, complex]
2279
-
first input array whose elements correspond to the exponentiation base. Should have a numeric data type.
2280
-
x2: Union[array, int, float, complex]
2281
-
second input array whose elements correspond to the exponentiation exponent. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a numeric data type.
2276
+
Parameters
2277
+
----------
2278
+
x1: Union[array, int, float, complex]
2279
+
first input array whose elements correspond to the exponentiation base. Should have a numeric data type.
2280
+
x2: Union[array, int, float, complex]
2281
+
second input array whose elements correspond to the exponentiation exponent. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a numeric data type.
2282
2282
2283
-
Returns
2284
-
-------
2285
-
out: array
2286
-
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
2283
+
Returns
2284
+
-------
2285
+
out: array
2286
+
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
2287
2287
2288
-
Notes
2289
-
-----
2288
+
Notes
2289
+
-----
2290
2290
2291
-
- At least one of ``x1`` or ``x2`` must be an array.
2291
+
- At least one of ``x1`` or ``x2`` must be an array.
2292
2292
2293
-
- If both ``x1`` and ``x2`` have integer data types, the result of ``pow`` when ``x2_i`` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
2293
+
- If both ``x1`` and ``x2`` have integer data types, the result of ``pow`` when ``x2_i`` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
2294
2294
2295
-
- If ``x1`` has an integer data type and ``x2`` has a floating-point data type, behavior is implementation-dependent (type promotion between data type "kinds" (integer versus floating-point) is unspecified).
2295
+
- If ``x1`` has an integer data type and ``x2`` has a floating-point data type, behavior is implementation-dependent (type promotion between data type "kinds" (integer versus floating-point) is unspecified).
2296
2296
2297
2297
- By convention, the branch cut of the natural logarithm is the negative real axis :math:`(-\infty, 0)`.
2298
2298
2299
2299
The natural logarithm is a continuous function from above the branch cut, taking into account the sign of the imaginary component. As special cases involving complex floating-point operands should be handled according to ``exp(x2*log(x1))``, exponentiation has the same branch cut for ``x1`` as the natural logarithm (see :func:`~array_api.log`).
2300
2300
2301
2301
*Note: branch cuts follow C99 and have provisional status* (see :ref:`branch-cuts`).
2302
2302
2303
-
**Special cases**
2304
-
2305
-
For real-valued floating-point operands,
2306
-
2307
-
- If ``x1_i`` is not equal to ``1`` and ``x2_i`` is ``NaN``, the result is ``NaN``.
2308
-
- If ``x2_i`` is ``+0``, the result is ``1``, even if ``x1_i`` is ``NaN``.
2309
-
- If ``x2_i`` is ``-0``, the result is ``1``, even if ``x1_i`` is ``NaN``.
2310
-
- If ``x1_i`` is ``NaN`` and ``x2_i`` is not equal to ``0``, the result is ``NaN``.
2311
-
- If ``abs(x1_i)`` is greater than ``1`` and ``x2_i`` is ``+infinity``, the result is ``+infinity``.
2312
-
- If ``abs(x1_i)`` is greater than ``1`` and ``x2_i`` is ``-infinity``, the result is ``+0``.
2313
-
- If ``abs(x1_i)`` is ``1`` and ``x2_i`` is ``+infinity``, the result is ``1``.
2314
-
- If ``abs(x1_i)`` is ``1`` and ``x2_i`` is ``-infinity``, the result is ``1``.
2315
-
- If ``x1_i`` is ``1`` and ``x2_i`` is not ``NaN``, the result is ``1``.
2316
-
- If ``abs(x1_i)`` is less than ``1`` and ``x2_i`` is ``+infinity``, the result is ``+0``.
2317
-
- If ``abs(x1_i)`` is less than ``1`` and ``x2_i`` is ``-infinity``, the result is ``+infinity``.
2318
-
- If ``x1_i`` is ``+infinity`` and ``x2_i`` is greater than ``0``, the result is ``+infinity``.
2319
-
- If ``x1_i`` is ``+infinity`` and ``x2_i`` is less than ``0``, the result is ``+0``.
2320
-
- If ``x1_i`` is ``-infinity``, ``x2_i`` is greater than ``0``, and ``x2_i`` is an odd integer value, the result is ``-infinity``.
2321
-
- If ``x1_i`` is ``-infinity``, ``x2_i`` is greater than ``0``, and ``x2_i`` is not an odd integer value, the result is ``+infinity``.
2322
-
- If ``x1_i`` is ``-infinity``, ``x2_i`` is less than ``0``, and ``x2_i`` is an odd integer value, the result is ``-0``.
2323
-
- If ``x1_i`` is ``-infinity``, ``x2_i`` is less than ``0``, and ``x2_i`` is not an odd integer value, the result is ``+0``.
2324
-
- If ``x1_i`` is ``+0`` and ``x2_i`` is greater than ``0``, the result is ``+0``.
2325
-
- If ``x1_i`` is ``+0`` and ``x2_i`` is less than ``0``, the result is ``+infinity``.
2326
-
- If ``x1_i`` is ``-0``, ``x2_i`` is greater than ``0``, and ``x2_i`` is an odd integer value, the result is ``-0``.
2327
-
- If ``x1_i`` is ``-0``, ``x2_i`` is greater than ``0``, and ``x2_i`` is not an odd integer value, the result is ``+0``.
2328
-
- If ``x1_i`` is ``-0``, ``x2_i`` is less than ``0``, and ``x2_i`` is an odd integer value, the result is ``-infinity``.
2329
-
- If ``x1_i`` is ``-0``, ``x2_i`` is less than ``0``, and ``x2_i`` is not an odd integer value, the result is ``+infinity``.
2330
-
- If ``x1_i`` is less than ``0``, ``x1_i`` is a finite number, ``x2_i`` is a finite number, and ``x2_i`` is not an integer value, the result is ``NaN``.
2331
-
2332
-
For complex floating-point operands, special cases should be handled as if the operation is implemented as ``exp(x2*log(x1))``.
2333
-
2334
-
.. note::
2335
-
Conforming implementations are allowed to treat special cases involving complex floating-point operands more carefully than as described in this specification.
2336
-
2337
-
.. versionchanged:: 2022.12
2338
-
Added complex data type support.
2303
+
**Special cases**
2304
+
2305
+
For real-valued floating-point operands,
2306
+
2307
+
- If ``x1_i`` is not equal to ``1`` and ``x2_i`` is ``NaN``, the result is ``NaN``.
2308
+
- If ``x2_i`` is ``+0``, the result is ``1``, even if ``x1_i`` is ``NaN``.
2309
+
- If ``x2_i`` is ``-0``, the result is ``1``, even if ``x1_i`` is ``NaN``.
2310
+
- If ``x1_i`` is ``NaN`` and ``x2_i`` is not equal to ``0``, the result is ``NaN``.
2311
+
- If ``abs(x1_i)`` is greater than ``1`` and ``x2_i`` is ``+infinity``, the result is ``+infinity``.
2312
+
- If ``abs(x1_i)`` is greater than ``1`` and ``x2_i`` is ``-infinity``, the result is ``+0``.
2313
+
- If ``abs(x1_i)`` is ``1`` and ``x2_i`` is ``+infinity``, the result is ``1``.
2314
+
- If ``abs(x1_i)`` is ``1`` and ``x2_i`` is ``-infinity``, the result is ``1``.
2315
+
- If ``x1_i`` is ``1`` and ``x2_i`` is not ``NaN``, the result is ``1``.
2316
+
- If ``abs(x1_i)`` is less than ``1`` and ``x2_i`` is ``+infinity``, the result is ``+0``.
2317
+
- If ``abs(x1_i)`` is less than ``1`` and ``x2_i`` is ``-infinity``, the result is ``+infinity``.
2318
+
- If ``x1_i`` is ``+infinity`` and ``x2_i`` is greater than ``0``, the result is ``+infinity``.
2319
+
- If ``x1_i`` is ``+infinity`` and ``x2_i`` is less than ``0``, the result is ``+0``.
2320
+
- If ``x1_i`` is ``-infinity``, ``x2_i`` is greater than ``0``, and ``x2_i`` is an odd integer value, the result is ``-infinity``.
2321
+
- If ``x1_i`` is ``-infinity``, ``x2_i`` is greater than ``0``, and ``x2_i`` is not an odd integer value, the result is ``+infinity``.
2322
+
- If ``x1_i`` is ``-infinity``, ``x2_i`` is less than ``0``, and ``x2_i`` is an odd integer value, the result is ``-0``.
2323
+
- If ``x1_i`` is ``-infinity``, ``x2_i`` is less than ``0``, and ``x2_i`` is not an odd integer value, the result is ``+0``.
2324
+
- If ``x1_i`` is ``+0`` and ``x2_i`` is greater than ``0``, the result is ``+0``.
2325
+
- If ``x1_i`` is ``+0`` and ``x2_i`` is less than ``0``, the result is ``+infinity``.
2326
+
- If ``x1_i`` is ``-0``, ``x2_i`` is greater than ``0``, and ``x2_i`` is an odd integer value, the result is ``-0``.
2327
+
- If ``x1_i`` is ``-0``, ``x2_i`` is greater than ``0``, and ``x2_i`` is not an odd integer value, the result is ``+0``.
2328
+
- If ``x1_i`` is ``-0``, ``x2_i`` is less than ``0``, and ``x2_i`` is an odd integer value, the result is ``-infinity``.
2329
+
- If ``x1_i`` is ``-0``, ``x2_i`` is less than ``0``, and ``x2_i`` is not an odd integer value, the result is ``+infinity``.
2330
+
- If ``x1_i`` is less than ``0``, ``x1_i`` is a finite number, ``x2_i`` is a finite number, and ``x2_i`` is not an integer value, the result is ``NaN``.
2331
+
2332
+
For complex floating-point operands, special cases should be handled as if the operation is implemented as ``exp(x2*log(x1))``.
2333
+
2334
+
.. note::
2335
+
Conforming implementations are allowed to treat special cases involving complex floating-point operands more carefully than as described in this specification.
0 commit comments