Skip to content

Commit 91656a7

Browse files
authored
Add complex number support to prod (#553)
1 parent 31b3df8 commit 91656a7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Diff for: spec/API_specification/array_api/statistical_functions.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,20 @@ def prod(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, dty
101101
102102
- If ``N`` is ``0``, the product is `1` (i.e., the empty product).
103103
104-
For floating-point operands,
105-
106-
- If ``x_i`` is ``NaN``, the product is ``NaN`` (i.e., ``NaN`` values propagate).
104+
For both real-valued and complex floating-point operands, special cases must be handled as if the operation is implemented by successive application of :func:`~array_api.multiply`.
107105
108106
Parameters
109107
----------
110108
x: array
111-
input array. Should have a real-valued data type.
109+
input array. Should have a numeric data type.
112110
axis: Optional[Union[int, Tuple[int, ...]]]
113111
axis or axes along which products must be computed. By default, the product must be computed over the entire array. If a tuple of integers, products must be computed over multiple axes. Default: ``None``.
114112
dtype: Optional[dtype]
115113
data type of the returned array. If ``None``,
116114
117-
- if the default data type corresponding to the data type "kind" (integer or floating-point) of ``x`` has a smaller range of values than the data type of ``x`` (e.g., ``x`` has data type ``int64`` and the default data type is ``int32``, or ``x`` has data type ``uint64`` and the default data type is ``int64``), the returned array must have the same data type as ``x``.
115+
- if the default data type corresponding to the data type "kind" (integer, real-valued floating-point, or complex floating-point) of ``x`` has a smaller range of values than the data type of ``x`` (e.g., ``x`` has data type ``int64`` and the default data type is ``int32``, or ``x`` has data type ``uint64`` and the default data type is ``int64``), the returned array must have the same data type as ``x``.
118116
- if ``x`` has a real-valued floating-point data type, the returned array must have the default real-valued floating-point data type.
117+
- if ``x`` has a complex floating-point data type, the returned array must have the default complex floating-point data type.
119118
- if ``x`` has a signed integer data type (e.g., ``int16``), the returned array must have the default integer data type.
120119
- if ``x`` has an unsigned integer data type (e.g., ``uint16``), the returned array must have an unsigned integer data type having the same number of bits as the default integer data type (e.g., if the default integer data type is ``int32``, the returned array must have a ``uint32`` data type).
121120

0 commit comments

Comments
 (0)