Skip to content

Commit 35cbf3d

Browse files
authored
Add complex number support to linalg.trace (#541)
1 parent 0e89b5f commit 35cbf3d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

spec/API_specification/array_api/linalg.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,12 @@ def trace(x: array, /, *, offset: int = 0, dtype: Optional[dtype] = None) -> arr
447447
448448
- If ``N`` is ``0``, the sum is ``0`` (i.e., the empty sum).
449449
450-
For floating-point operands,
451-
452-
- If ``x_i`` is ``NaN``, the sum is ``NaN`` (i.e., ``NaN`` values propagate).
450+
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.add`.
453451
454452
Parameters
455453
----------
456454
x: array
457-
input array having shape ``(..., M, N)`` and whose innermost two dimensions form ``MxN`` matrices. Should have a real-valued data type.
455+
input array having shape ``(..., M, N)`` and whose innermost two dimensions form ``MxN`` matrices. Should have a numeric data type.
458456
offset: int
459457
offset specifying the off-diagonal relative to the main diagonal.
460458
@@ -466,8 +464,9 @@ def trace(x: array, /, *, offset: int = 0, dtype: Optional[dtype] = None) -> arr
466464
dtype: Optional[dtype]
467465
data type of the returned array. If ``None``,
468466
469-
- 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``.
467+
- 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``.
470468
- if ``x`` has a real-valued floating-point data type, the returned array must have the default real-valued floating-point data type.
469+
- if ``x`` has a complex floating-point data type, the returned array must have the default complex floating-point data type.
471470
- if ``x`` has a signed integer data type (e.g., ``int16``), the returned array must have the default integer data type.
472471
- 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).
473472

0 commit comments

Comments
 (0)