Heads up, we changed the behaviour of linalg.eig and linalg.eigvals to
always return complex ndarrays. If this causes inconvenience that
cannot be mitigated, please open an issue.

>From the release note of a recently merged PR:

* `linalg.eig` and `linalg.eigvals` always return complex arrays.
Previously, the return
   values depended on whether the eigenvalues happen to lie on the
real line (which, for
   a general, non-symmetric matrix, is not guaranteed).

   The user change depends on your usage:

   - to retain the previous behavior, do

   ```
   w = eigvals(a)
   if w.imag == 0:    # this is what NumPy used to do
   w = w.real
   ```

   - if your matrix is symmetrix/hermitian, use `eigh` and `eigvalsh`
instead of `eig` and `eigvals`:
     these are guaranteed to return real values. (A common case is
covariance matrices, which are
     symmetric and positive definite by construction)

Thanks Evgeni for the PR.
Matti
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]

Reply via email to