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
Machine limits for real-valued floating-point data types.
49
+
Machine limits for floating-point data types.
50
50
51
51
Parameters
52
52
----------
53
53
type: Union[dtype, array]
54
-
the kind of real-valued floating-point data-type about which to get information.
54
+
the kind of floating-point data-type about which to get information. If complex, the information is about its component data type.
55
+
56
+
.. note::
57
+
Complex floating-point data types are specified to always use the same precision for both its real and imaginary components, so the information should be true for either component.
an array containing the element-wise results. The returned array must have a data type determined by :ref:`type-promotion`.
1182
1210
"""
1183
1211
1212
+
defreal(x: array, /) ->array:
1213
+
"""
1214
+
Returns the real component of a complex number for each element ``x_i`` of the input array ``x``.
1215
+
1216
+
Parameters
1217
+
----------
1218
+
x: array
1219
+
input array. Should have a complex floating-point data type.
1220
+
1221
+
Returns
1222
+
-------
1223
+
out: array
1224
+
an array containing the element-wise results. The returned array must have a floating-point data type with the same floating-point precision as ``x`` (e.g., if ``x`` is ``complex64``, the returned array must have the floating-point data type ``float32``).
1225
+
"""
1226
+
1184
1227
defremainder(x1: array, x2: array, /) ->array:
1185
1228
"""
1186
1229
Returns the remainder of division for each element ``x1_i`` of the input array ``x1`` and the respective element ``x2_i`` of the input array ``x2``.
Calculates an implementation-dependent approximation to the tangent, having domain ``(-infinity, +infinity)`` and codomain ``(-infinity, +infinity)``, for each element ``x_i`` of the input array ``x``. Each element ``x_i`` is assumed to be expressed in radians.
1488
+
r"""
1489
+
Calculates an implementation-dependent approximation to the tangent for each element ``x_i`` of the input array ``x``.
1490
+
1491
+
Each element ``x_i`` is assumed to be expressed in radians.
1447
1492
1448
1493
**Special cases**
1449
1494
1450
-
For floating-point operands,
1495
+
For real-valued floating-point operands,
1451
1496
1452
1497
- If ``x_i`` is ``NaN``, the result is ``NaN``.
1453
1498
- If ``x_i`` is ``+0``, the result is ``+0``.
1454
1499
- If ``x_i`` is ``-0``, the result is ``-0``.
1455
1500
- If ``x_i`` is either ``+infinity`` or ``-infinity``, the result is ``NaN``.
1456
1501
1502
+
For complex floating-point operands, special cases must be handled as if the operation is implemented as ``-1j * tanh(x*1j)``.
1503
+
1504
+
.. note::
1505
+
Tangent is an analytical function on the complex plane and has no branch cuts. The function is periodic, with period :math:`\pi j`, with respect to the real component and has first order poles along the real line at coordinates :math:`(\pi (\frac{1}{2} + n), 0)`. However, IEEE 754 binary floating-point representation cannot represent the value :math:`\pi / 2` exactly, and, thus, no argument value is possible for which a pole error occurs.
1506
+
1507
+
.. note::
1508
+
For complex arguments, the mathematical definition of tangent is
where :math:`\operatorname{tanh}` is the hyperbolic tangent.
1514
+
1457
1515
Parameters
1458
1516
----------
1459
1517
x: array
1460
-
input array whose elements are expressed in radians. Should have a real-valued floating-point data type.
1518
+
input array whose elements are expressed in radians. Should have a floating-point data type.
1461
1519
1462
1520
Returns
1463
1521
-------
1464
1522
out: array
1465
-
an array containing the tangent of each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1523
+
an array containing the tangent of each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
1466
1524
"""
1467
1525
1468
1526
deftanh(x: array, /) ->array:
1469
-
"""
1470
-
Calculates an implementation-dependent approximation to the hyperbolic tangent, having domain ``[-infinity, +infinity]`` and codomain ``[-1, +1]``, for each element ``x_i`` of the input array ``x``.
1527
+
r"""
1528
+
Calculates an implementation-dependent approximation to the hyperbolic tangent for each element ``x_i`` of the input array ``x``.
1529
+
1530
+
The mathematical definition of the hyperbolic tangent is
where :math:`\operatorname{sinh}(x)` is the hyperbolic sine and :math:`\operatorname{cosh}(x)` is the hyperbolic cosine.
1471
1536
1472
1537
**Special cases**
1473
1538
1474
-
For floating-point operands,
1539
+
.. note::
1540
+
For all operands, ``tanh(-x)`` must equal ``-tanh(x)``.
1541
+
1542
+
For real-valued floating-point operands,
1475
1543
1476
1544
- If ``x_i`` is ``NaN``, the result is ``NaN``.
1477
1545
- If ``x_i`` is ``+0``, the result is ``+0``.
1478
1546
- If ``x_i`` is ``-0``, the result is ``-0``.
1479
1547
- If ``x_i`` is ``+infinity``, the result is ``+1``.
1480
1548
- If ``x_i`` is ``-infinity``, the result is ``-1``.
1481
1549
1550
+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
1551
+
1552
+
.. note::
1553
+
For complex floating-point operands, ``tanh(conj(x))`` must equal ``conj(tanh(x))``.
1554
+
1555
+
- If ``a`` is ``+0`` and ``b`` is ``+0``, the result is ``+0 + 0j``.
1556
+
- If ``a`` is a nonzero finite number and ``b`` is ``+infinity``, the result is ``NaN + NaN j``.
1557
+
- If ``a`` is ``+0`` and ``b`` is ``+infinity``, the result is ``+0 + NaN j``.
1558
+
- If ``a`` is a nonzero finite number and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1559
+
- If ``a`` is ``+0`` and ``b`` is ``NaN``, the result is ``+0 + NaN j``.
1560
+
- If ``a`` is ``+infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``1 + 0j``.
1561
+
- If ``a`` is ``+infinity`` and ``b`` is ``+infinity``, the result is ``1 + 0j`` (sign of the imaginary component is unspecified).
1562
+
- If ``a`` is ``+infinity`` and ``b`` is ``NaN``, the result is ``1 + 0j`` (sign of the imaginary component is unspecified).
1563
+
- If ``a`` is ``NaN`` and ``b`` is ``+0``, the result is ``NaN + 0j``.
1564
+
- If ``a`` is ``NaN`` and ``b`` is a nonzero number, the result is ``NaN + NaN j``.
1565
+
- If ``a`` is ``NaN`` and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1566
+
1567
+
.. warning::
1568
+
For historical reasons stemming from the C standard, array libraries may not return the expected result when ``a`` is ``+0`` and ``b`` is either ``+infinity`` or ``NaN``. The result should be ``+0 + NaN j`` in both cases; however, for libraries compiled against older C versions, the result may be ``NaN + NaN j``.
1569
+
1570
+
Array libraries are not required to patch these older C versions, and, thus, users are advised that results may vary across array library implementations for these special cases.
1571
+
1572
+
.. note::
1573
+
The hyperbolic tangent is an analytical function on the complex plane and has no branch cuts. The function is periodic, with period :math:`\pi j`, with respect to the imaginary component and has first order poles along the imaginary line at coordinates :math:`(0, \pi (\frac{1}{2} + n))`. However, IEEE 754 binary floating-point representation cannot represent :math:`\pi / 2` exactly, and, thus, no argument value is possible such that a pole error occurs.
1574
+
1482
1575
Parameters
1483
1576
----------
1484
1577
x: array
1485
-
input array whose elements each represent a hyperbolic angle. Should have a real-valued floating-point data type.
1578
+
input array whose elements each represent a hyperbolic angle. Should have a floating-point data type.
1486
1579
1487
1580
Returns
1488
1581
-------
1489
1582
out: array
1490
-
an array containing the hyperbolic tangent of each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1583
+
an array containing the hyperbolic tangent of each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
Returns the cross product of 3-element vectors. If ``x1`` and ``x2`` are multi-dimensional arrays (i.e., both have a rank greater than ``1``), then the cross-product of each pair of corresponding 3-element vectors is independently computed.
44
+
Returns the cross product of 3-element vectors.
45
+
46
+
If ``x1`` and/or ``x2`` are multi-dimensional arrays (i.e., the broadcasted result has a rank greater than ``1``), then the cross-product of each pair of corresponding 3-element vectors is independently computed.
45
47
46
48
Parameters
47
49
----------
48
50
x1: array
49
51
first input array. Should have a real-valued data type.
50
52
x2: array
51
-
second input array. Must have the same shape as ``x1``. Should have a real-valued data type.
53
+
second input array. Must be compatible with ``x1`` for all non-compute axes (see :ref:`broadcasting`). The size of the axis over which to compute the cross product must be the same size as the respective axis in ``x1``. Should have a real-valued data type.
54
+
55
+
.. note::
56
+
The compute axis (dimension) must not be broadcasted.
57
+
52
58
axis: int
53
-
the axis (dimension) of ``x1`` and ``x2`` containing the vectors for which to compute the cross product. If set to ``-1``, the function computes the cross product for vectors defined by the last axis (dimension). Default: ``-1``.
59
+
the axis (dimension) of ``x1`` and ``x2`` containing the vectors for which to compute the cross product. Must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of the shape determined according to :ref:`broadcasting`. If specified as a negative integer, the function must determine the axis along which to compute the cross product by counting backward from the last dimension (where ``-1`` refers to the last dimension). By default, the function must compute the cross product over the last axis. Default: ``-1``.
54
60
55
61
Returns
56
62
-------
57
63
out: array
58
64
an array containing the cross products. The returned array must have a data type determined by :ref:`type-promotion`.
65
+
66
+
67
+
**Raises**
68
+
69
+
- if provided an invalid ``axis``.
70
+
- if the size of the axis over which to compute the cross product is not equal to ``3``.
71
+
- if the size of the axis over which to compute the cross product is not the same (before broadcasting) for both ``x1`` and ``x2``.
first input array. Should have a real-valued data type.
94
94
x2: array
95
-
second input array. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type.
96
-
axis:int
95
+
second input array. Must be compatible with ``x1`` for all non-contracted axes (see :ref:`broadcasting`). The size of the axis over which to compute the dot product must be the same size as the respective axis in ``x1``. Should have a real-valued data type.
96
+
97
+
.. note::
98
+
The contracted axis (dimension) must not be broadcasted.
99
+
100
+
axis: int
97
101
axis over which to compute the dot product. Must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of the shape determined according to :ref:`broadcasting`. If specified as a negative integer, the function must determine the axis along which to compute the dot product by counting backward from the last dimension (where ``-1`` refers to the last dimension). By default, the function must compute the dot product over the last axis. Default: ``-1``.
98
102
99
103
Returns
100
104
-------
101
105
out: array
102
-
if ``x1`` and ``x2`` are both one-dimensional arrays, a zero-dimensional containing the dot product; otherwise, a non-zero-dimensional array containing the dot products and having rank ``N-1``, where ``N`` is the rank (number of dimensions) of the shape determined according to :ref:`broadcasting`. The returned array must have a data type determined by :ref:`type-promotion`.
106
+
if ``x1`` and ``x2`` are both one-dimensional arrays, a zero-dimensional containing the dot product; otherwise, a non-zero-dimensional array containing the dot products and having rank ``N-1``, where ``N`` is the rank (number of dimensions) of the shape determined according to :ref:`broadcasting` along the non-contracted axes. The returned array must have a data type determined by :ref:`type-promotion`.
103
107
104
108
105
109
**Raises**
106
110
107
111
- if provided an invalid ``axis``.
108
-
- if the size of the axis over which to compute the dot product is not the same for both ``x1`` and ``x2``.
112
+
- if the size of the axis over which to compute the dot product is not the same (before broadcasting) for both ``x1`` and ``x2``.
0 commit comments