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
Evaluates ``self_i // other_i`` for each element of an array instance with the respective element of the array ``other``.
1211
+
1212
+
.. note::
1213
+
For input arrays which promote to an integer data type, the result of division by zero is unspecified and thus implementation-defined.
1214
+
1215
+
Parameters
1216
+
----------
1217
+
self
1218
+
array instance. Should have a real-valued data type.
1219
+
other: Union[int, float, array]
1220
+
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a real-valued data type.
1221
+
1222
+
Returns
1223
+
-------
1224
+
out: array
1225
+
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
1226
+
1227
+
1228
+
.. note::
1229
+
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.floor_divide`.
1230
+
1231
+
"""
1232
+
...
1233
+
1234
+
def __rlshift__(self, other: int | Self, /) -> Self:
1235
+
"""
1236
+
Evaluates ``self_i << other_i`` for each element of an array instance with the respective element of the array ``other``.
1237
+
1238
+
Parameters
1239
+
----------
1240
+
self
1241
+
array instance. Should have an integer data type.
1242
+
other: Union[int, array]
1243
+
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have an integer data type. Each element must be greater than or equal to ``0``.
1244
+
1245
+
Returns
1246
+
-------
1247
+
out: array
1248
+
an array containing the element-wise results. The returned array must have the same data type as ``self``.
1249
+
1250
+
1251
+
.. note::
1252
+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_left_shift`.
1253
+
1254
+
"""
1255
+
...
1256
+
1257
+
def __rmatmul__(self, other: Self, /) -> Self:
1258
+
"""
1259
+
Computes the matrix product.
1260
+
1261
+
.. note::
1262
+
The ``matmul`` function must implement the same semantics as the built-in ``@`` operator (see `PEP 465 <https://www.python.org/dev/peps/pep-0465>`_).
1263
+
1264
+
Parameters
1265
+
----------
1266
+
self
1267
+
array instance. Should have a numeric data type. Must have at least one dimension. If ``self`` is one-dimensional having shape ``(M,)`` and ``other`` has more than one dimension, ``self`` must be promoted to a two-dimensional array by prepending ``1`` to its dimensions (i.e., must have shape ``(1, M)``). After matrix multiplication, the prepended dimensions in the returned array must be removed. If ``self`` has more than one dimension (including after vector-to-matrix promotion), ``shape(self)[:-2]`` must be compatible with ``shape(other)[:-2]`` (after vector-to-matrix promotion) (see :ref:`broadcasting`). If ``self`` has shape ``(..., M, K)``, the innermost two dimensions form matrices on which to perform matrix multiplication.
1268
+
other: array
1269
+
other array. Should have a numeric data type. Must have at least one dimension. If ``other`` is one-dimensional having shape ``(N,)`` and ``self`` has more than one dimension, ``other`` must be promoted to a two-dimensional array by appending ``1`` to its dimensions (i.e., must have shape ``(N, 1)``). After matrix multiplication, the appended dimensions in the returned array must be removed. If ``other`` has more than one dimension (including after vector-to-matrix promotion), ``shape(other)[:-2]`` must be compatible with ``shape(self)[:-2]`` (after vector-to-matrix promotion) (see :ref:`broadcasting`). If ``other`` has shape ``(..., K, N)``, the innermost two dimensions form matrices on which to perform matrix multiplication.
1270
+
1271
+
1272
+
.. note::
1273
+
If either ``x1`` or ``x2`` has a complex floating-point data type, neither argument must be complex-conjugated or transposed. If conjugation and/or transposition is desired, these operations should be explicitly performed prior to computing the matrix product.
1274
+
1275
+
Returns
1276
+
-------
1277
+
out: array
1278
+
- if both ``self`` and ``other`` are one-dimensional arrays having shape ``(N,)``, a zero-dimensional array containing the inner product as its only element.
1279
+
- if ``self`` is a two-dimensional array having shape ``(M, K)`` and ``other`` is a two-dimensional array having shape ``(K, N)``, a two-dimensional array containing the `conventional matrix product <https://en.wikipedia.org/wiki/Matrix_multiplication>`_ and having shape ``(M, N)``.
1280
+
- if ``self`` is a one-dimensional array having shape ``(K,)`` and ``other`` is an array having shape ``(..., K, N)``, an array having shape ``(..., N)`` (i.e., prepended dimensions during vector-to-matrix promotion must be removed) and containing the `conventional matrix product <https://en.wikipedia.org/wiki/Matrix_multiplication>`_.
1281
+
- if ``self`` is an array having shape ``(..., M, K)`` and ``other`` is a one-dimensional array having shape ``(K,)``, an array having shape ``(..., M)`` (i.e., appended dimensions during vector-to-matrix promotion must be removed) and containing the `conventional matrix product <https://en.wikipedia.org/wiki/Matrix_multiplication>`_.
1282
+
- if ``self`` is a two-dimensional array having shape ``(M, K)`` and ``other`` is an array having shape ``(..., K, N)``, an array having shape ``(..., M, N)`` and containing the `conventional matrix product <https://en.wikipedia.org/wiki/Matrix_multiplication>`_ for each stacked matrix.
1283
+
- if ``self`` is an array having shape ``(..., M, K)`` and ``other`` is a two-dimensional array having shape ``(K, N)``, an array having shape ``(..., M, N)`` and containing the `conventional matrix product <https://en.wikipedia.org/wiki/Matrix_multiplication>`_ for each stacked matrix.
1284
+
- if either ``self`` or ``other`` has more than two dimensions, an array having a shape determined by :ref:`broadcasting` ``shape(self)[:-2]`` against ``shape(other)[:-2]`` and containing the `conventional matrix product <https://en.wikipedia.org/wiki/Matrix_multiplication>`_ for each stacked matrix.
1285
+
- The returned array must have a data type determined by :ref:`type-promotion`.
1286
+
1287
+
Notes
1288
+
-----
1289
+
1290
+
.. note::
1291
+
Results must equal the results returned by the equivalent function :func:`~array_api.matmul`.
1292
+
1293
+
**Raises**
1294
+
1295
+
- if either ``self`` or ``other`` is a zero-dimensional array.
1296
+
- if ``self`` is a one-dimensional array having shape ``(K,)``, ``other`` is a one-dimensional array having shape ``(L,)``, and ``K != L``.
1297
+
- if ``self`` is a one-dimensional array having shape ``(K,)``, ``other`` is an array having shape ``(..., L, N)``, and ``K != L``.
1298
+
- if ``self`` is an array having shape ``(..., M, K)``, ``other`` is a one-dimensional array having shape ``(L,)``, and ``K != L``.
1299
+
- if ``self`` is an array having shape ``(..., M, K)``, ``other`` is an array having shape ``(..., L, N)``, and ``K != L``.
Evaluates ``self_i % other_i`` for each element of an array instance with the respective element of the array ``other``.
1310
+
1311
+
.. note::
1312
+
For input arrays which promote to an integer data type, the result of division by zero is unspecified and thus implementation-defined.
1313
+
1314
+
Parameters
1315
+
----------
1316
+
self
1317
+
array instance. Should have a real-valued data type.
1318
+
other: Union[int, float, array]
1319
+
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a real-valued data type.
1320
+
1321
+
Returns
1322
+
-------
1323
+
out: array
1324
+
an array containing the element-wise results. Each element-wise result must have the same sign as the respective element ``other_i``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1325
+
1326
+
1327
+
.. note::
1328
+
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.remainder`.
Calculates an implementation-dependent approximation of exponentiation by raising each element (the base) of an array instance to the power of ``other_i`` (the exponent), where ``other_i`` is the corresponding element of the array ``other``.
1392
+
1393
+
.. note::
1394
+
If both ``self`` and ``other`` have integer data types, the result of ``__pow__`` when `other_i` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
1395
+
1396
+
If ``self`` has an integer data type and ``other`` has a floating-point data type, behavior is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
1397
+
1398
+
Parameters
1399
+
----------
1400
+
self
1401
+
array instance whose elements correspond to the exponentiation base. Should have a numeric data type.
1402
+
other: Union[int, float, complex, array]
1403
+
other array whose elements correspond to the exponentiation exponent. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
1404
+
1405
+
Returns
1406
+
-------
1407
+
out: array
1408
+
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
1409
+
1410
+
Notes
1411
+
-----
1412
+
1413
+
.. note::
1414
+
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.pow`.
1415
+
1416
+
.. versionchanged:: 2022.12
1417
+
Added complex data type support.
1418
+
1419
+
"""
1420
+
...
1421
+
1422
+
def __rrshift__(self, other: int | Self, /) -> Self:
1423
+
"""
1424
+
Evaluates ``self_i >> other_i`` for each element of an array instance with the respective element of the array ``other``.
1425
+
1426
+
Parameters
1427
+
----------
1428
+
self
1429
+
array instance. Should have an integer data type.
1430
+
other: Union[int, array]
1431
+
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have an integer data type. Each element must be greater than or equal to ``0``.
1432
+
1433
+
Returns
1434
+
-------
1435
+
out: array
1436
+
an array containing the element-wise results. The returned array must have the same data type as ``self``.
1437
+
1438
+
1439
+
.. note::
1440
+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.bitwise_right_shift`.
Calculates the difference for each element of an array instance with the respective element of the array ``other``.
1448
+
1449
+
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__`).
1450
+
1451
+
Parameters
1452
+
----------
1453
+
self
1454
+
array instance (minuend array). Should have a numeric data type.
1455
+
other: Union[int, float, complex, array]
1456
+
subtrahend array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
1457
+
1458
+
Returns
1459
+
-------
1460
+
out: array
1461
+
an array containing the element-wise differences. The returned array must have a data type determined by :ref:`type-promotion`.
1462
+
1463
+
Notes
1464
+
-----
1465
+
1466
+
.. note::
1467
+
Element-wise results must equal the results returned by the equivalent element-wise function :func:`~array_api.subtract`.
Evaluates ``self_i / other_i`` for each element of an array instance with the respective element of the array ``other``.
1478
+
1479
+
.. note::
1480
+
If one or both of ``self`` and ``other`` have integer data types, the result is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
1481
+
1482
+
Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, the array must have a real-valued floating-point data type.
1483
+
1484
+
Parameters
1485
+
----------
1486
+
self
1487
+
array instance. Should have a numeric data type.
1488
+
other: Union[int, float, complex, array]
1489
+
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
1490
+
1491
+
Returns
1492
+
-------
1493
+
out: array
1494
+
an array containing the element-wise results. The returned array should have a floating-point data type determined by :ref:`type-promotion`.
1495
+
1496
+
Notes
1497
+
-----
1498
+
1499
+
.. note::
1500
+
Element-wise results, including special cases, must equal the results returned by the equivalent element-wise function :func:`~array_api.divide`.
0 commit comments