Skip to content

Commit 775dc7a

Browse files
authored
Add complex number support for linalg.inv (#547)
1 parent e2eb28f commit 775dc7a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

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

+16-3
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,31 @@ def eigvalsh(x: array, /) -> array:
169169
"""
170170

171171
def inv(x: array, /) -> array:
172-
"""
172+
r"""
173173
Returns the multiplicative inverse of a square matrix (or a stack of square matrices) ``x``.
174174
175+
If ``x`` is real-valued, let :math:`\mathbb{K}` be the set of real numbers :math:`\mathbb{R}`, and, if ``x`` is complex-valued, let :math:`\mathbb{K}` be the set of complex numbers :math:`\mathbb{C}`.
176+
177+
The **inverse matrix** :math:`x^{-1} \in\ \mathbb{K}^{n \times n}` of a square matrix :math:`x \in\ \mathbb{K}^{n \times n}` is defined as
178+
179+
.. math::
180+
x^{-1}x = xx^{-1} = I_n
181+
182+
where :math:`I_n` is the *n*-dimensional identity matrix.
183+
184+
The inverse matrix exists if and only if ``x`` is invertible. When ``x`` is invertible, the inverse is unique.
185+
186+
When ``x`` is a stack of matrices, the function must compute the inverse for each matrix in the stack.
187+
175188
Parameters
176189
----------
177190
x: array
178-
input array having shape ``(..., M, M)`` and whose innermost two dimensions form square matrices. Should have a real-valued floating-point data type.
191+
input array having shape ``(..., M, M)`` and whose innermost two dimensions form square matrices. Should have a floating-point data type.
179192
180193
Returns
181194
-------
182195
out: array
183-
an array containing the multiplicative inverses. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion` and must have the same shape as ``x``.
196+
an array containing the multiplicative inverses. The returned array must have a floating-point data type determined by :ref:`type-promotion` and must have the same shape as ``x``.
184197
"""
185198

186199
def matmul(x1: array, x2: array, /) -> array:

0 commit comments

Comments
 (0)