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 an implementation-dependent approximation to the base ``2`` logarithm, having domain ``[0, +infinity]`` and codomain ``[-infinity, +infinity]``, for each element ``x_i`` of the input array ``x``.
1326
+
r"""
1327
+
Calculates an implementation-dependent approximation to the base ``2`` logarithm for each element ``x_i`` of the input array ``x``.
1328
1328
1329
1329
**Special cases**
1330
1330
1331
-
For floating-point operands,
1331
+
For real-valued floating-point operands,
1332
1332
1333
1333
- If ``x_i`` is ``NaN``, the result is ``NaN``.
1334
1334
- If ``x_i`` is less than ``0``, the result is ``NaN``.
1335
1335
- If ``x_i`` is either ``+0`` or ``-0``, the result is ``-infinity``.
1336
1336
- If ``x_i`` is ``1``, the result is ``+0``.
1337
1337
- If ``x_i`` is ``+infinity``, the result is ``+infinity``.
1338
1338
1339
+
For complex floating-point operands, special cases must be handled as if the operation is implemented using the standard change of base formula
1340
+
1341
+
.. math::
1342
+
\log_{2} x = \frac{\log_{e} x}{\log_{e} 2}
1343
+
1344
+
where :math:`\log_{e}` is the natural logarithm, as implemented by :func:`~array_api.log`.
1345
+
1346
+
.. note::
1347
+
For complex floating-point operands, ``log2(conj(x))`` must equal ``conj(log2(x))``.
1348
+
1339
1349
Parameters
1340
1350
----------
1341
1351
x: array
1342
-
input array. Should have a real-valued floating-point data type.
1352
+
input array. Should have a floating-point data type.
1343
1353
1344
1354
Returns
1345
1355
-------
1346
1356
out: array
1347
-
an array containing the evaluated base ``2`` logarithm for each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1357
+
an array containing the evaluated base ``2`` logarithm for each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
0 commit comments