Skip to content

Commit 28e6041

Browse files
authored
Add complex number support to log10 (#536)
1 parent 971c06a commit 28e6041

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

spec/API_specification/array_api/elementwise_functions.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,28 +1348,38 @@ def log2(x: array, /) -> array:
13481348
"""
13491349

13501350
def log10(x: array, /) -> array:
1351-
"""
1352-
Calculates an implementation-dependent approximation to the base ``10`` logarithm, having domain ``[0, +infinity]`` and codomain ``[-infinity, +infinity]``, for each element ``x_i`` of the input array ``x``.
1351+
r"""
1352+
Calculates an implementation-dependent approximation to the base ``10`` logarithm for each element ``x_i`` of the input array ``x``.
13531353
13541354
**Special cases**
13551355
1356-
For floating-point operands,
1356+
For real-valued floating-point operands,
13571357
13581358
- If ``x_i`` is ``NaN``, the result is ``NaN``.
13591359
- If ``x_i`` is less than ``0``, the result is ``NaN``.
13601360
- If ``x_i`` is either ``+0`` or ``-0``, the result is ``-infinity``.
13611361
- If ``x_i`` is ``1``, the result is ``+0``.
13621362
- If ``x_i`` is ``+infinity``, the result is ``+infinity``.
13631363
1364+
For complex floating-point operands, special cases must be handled as if the operation is implemented using the standard change of base formula
1365+
1366+
.. math::
1367+
\log_{10} x = \frac{\log_{e} x}{\log_{e} 10}
1368+
1369+
where :math:`\log_{e}` is the natural logarithm, as implemented by :func:`~array_api.log`.
1370+
1371+
.. note::
1372+
For complex floating-point operands, ``log10(conj(x))`` must equal ``conj(log10(x))``.
1373+
13641374
Parameters
13651375
----------
13661376
x: array
1367-
input array. Should have a real-valued floating-point data type.
1377+
input array. Should have a floating-point data type.
13681378
13691379
Returns
13701380
-------
13711381
out: array
1372-
an array containing the evaluated base ``10`` logarithm for each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1382+
an array containing the evaluated base ``10`` logarithm for each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
13731383
"""
13741384

13751385
def logaddexp(x1: array, x2: array, /) -> array:

0 commit comments

Comments
 (0)