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
Returns an eigendecomposition x = QLQᵀ of a symmetric matrix (or a stack of symmetric matrices) ``x``, where ``Q`` is an orthogonal matrix (or a stack of matrices) and ``L`` is a vector (or a stack of vectors).
113
+
r"""
114
+
Returns an eigenvalue decomposition of a complex Hermitian or real symmetric matrix (or a stack of matrices) ``x``.
115
+
116
+
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}`.
117
+
118
+
The **eigenvalue decomposition** of a complex Hermitian or real symmetric matrix :math:`x \in\ \mathbb{K}^{n \times n}` is defined as
119
+
120
+
.. math::
121
+
x = Q \Lambda Q^H
122
+
123
+
with :math:`Q \in \mathbb{K}^{n \times n}` and :math:`\Lambda \in \mathbb{R}^n` and where :math:`Q^H` is the conjugate transpose when :math:`Q` is complex and the transpose when :math:`Q` is real-valued and :math:`\Lambda` is a diagonal matrix whose diagonal elements are the corresponding eigenvalues. When ``x`` is real-valued, :math:`Q` is orthogonal, and, when ``x`` is complex, :math:`Q` is unitary.
115
124
116
125
.. note::
117
-
The function ``eig`` will be added in a future version of the specification, as it requires complex number support.
126
+
The eigenvalues of a complex Hermitian or real symmetric matrix are always real.
127
+
128
+
.. warning::
129
+
The eigenvectors of a symmetric matrix are not unique and are not continuous with respect to ``x``. Because eigenvectors are not unique, different hardware and software may compute different eigenvectors.
130
+
131
+
Non-uniqueness stems from the fact that multiplying an eigenvector by :math:`-1` when ``x`` is real-valued and by :math:`e^{\phi j}` (:math:`\phi \in \mathbb{R}`) when ``x`` is complex produces another set of valid eigenvectors.
118
132
119
-
..
120
-
NOTE: once complex numbers are supported, each square matrix must be Hermitian.
133
+
.. note::
134
+
Whether an array library explicitly checks whether an input array is Hermitian or a symmetric matrix (or a stack of matrices) is implementation-defined.
121
135
122
136
.. note::
123
-
Whether an array library explicitly checks whether an input array is a symmetric matrix (or a stack of symmetric matrices) is implementation-defined.
137
+
The function ``eig`` will be added in a future version of the specification.
124
138
125
139
Parameters
126
140
----------
127
141
x: array
128
-
input array having shape ``(..., M, M)`` and whose innermost two dimensions form square matrices. Must have a real-valued floating-point data type.
142
+
input array having shape ``(..., M, M)`` and whose innermost two dimensions form square matrices. Must have a floating-point data type.
129
143
130
144
Returns
131
145
-------
132
146
out: Tuple[array]
133
147
a namedtuple (``eigenvalues``, ``eigenvectors``) whose
134
148
135
-
- first element must have the field name ``eigenvalues`` (corresponding to ``L`` above) and must be an array consisting of computed eigenvalues. The array containing the eigenvalues must have shape ``(..., M)``.
136
-
- second element have have the field name ``eigenvectors`` (corresponding to ``Q`` above) and must be an array where the columns of the inner most matrices contain the computed eigenvectors. These matrices must be orthogonal. The array containing the eigenvectors must have shape ``(..., M, M)``.
149
+
- first element must have the field name ``eigenvalues`` (corresponding to :math:`\operatorname{diag}\Lambda` above) and must be an array consisting of computed eigenvalues. The array containing the eigenvalues must have shape ``(..., M)`` and must have a real-valued floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``complex128``, then ``eigenvalues`` must be ``float64``).
150
+
- second element have have the field name ``eigenvectors`` (corresponding to :math:`Q` above) and must be an array where the columns of the inner most matrices contain the computed eigenvectors. These matrices must be orthogonal. The array containing the eigenvectors must have shape ``(..., M, M)`` and must have the same data type as ``x``.
137
151
138
-
Each returned array must have the same real-valued floating-point data type as ``x``.
139
152
140
153
.. note::
141
154
Eigenvalue sort order is left unspecified and is thus implementation-dependent.
142
155
"""
143
156
144
157
defeigvalsh(x: array, /) ->array:
145
-
"""
146
-
Returns the eigenvalues of a symmetric matrix (or a stack of symmetric matrices) ``x``.
158
+
r"""
159
+
Returns the eigenvalues of a complex Hermitian or real symmetric matrix (or a stack of matrices) ``x``.
147
160
148
-
.. note::
149
-
The function ``eigvals`` will be added in a future version of the specification, as it requires complex number support.
161
+
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}`.
162
+
163
+
The **eigenvalues** of a complex Hermitian or real symmetric matrix :math:`x \in\ \mathbb{K}^{n \times n}` are defined as the roots (counted with multiplicity) of the polynomial :math:`p` of degree :math:`n` given by
150
164
151
-
..
152
-
NOTE: once complex numbers are supported, each square matrix must be Hermitian.
165
+
.. math::
166
+
p(\lambda) = \operatorname{det}(x - \lambda I_n)
167
+
168
+
where :math:`\lambda \in \mathbb{R}` and where :math:`I_n` is the *n*-dimensional identity matrix.
169
+
170
+
.. note:;
171
+
The eigenvalues of a complex Hermitian or real symmetric matrix are always real.
153
172
154
173
.. note::
155
-
Whether an array library explicitly checks whether an input array is a symmetric matrix (or a stack of symmetric matrices) is implementation-defined.
174
+
Whether an array library explicitly checks whether an input array is Hermitian or a symmetric matrix (or a stack of matrices) is implementation-defined.
175
+
176
+
.. note::
177
+
The function ``eigvals`` will be added in a future version of the specification.
156
178
157
179
Parameters
158
180
----------
159
181
x: array
160
-
input array having shape ``(..., M, M)`` and whose innermost two dimensions form square matrices. Must have a real-valued floating-point data type.
182
+
input array having shape ``(..., M, M)`` and whose innermost two dimensions form square matrices. Must have a floating-point data type.
161
183
162
184
Returns
163
185
-------
164
186
out: array
165
-
an array containing the computed eigenvalues. The returned array must have shape ``(..., M)`` and have the same data type as ``x``.
187
+
an array containing the computed eigenvalues. The returned array must have shape ``(..., M)`` and have a real-valued floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``complex128``, then must have a ``float64`` data type).
188
+
166
189
167
190
.. note::
168
191
Eigenvalue sort order is left unspecified and is thus implementation-dependent.
0 commit comments