Closed JeffreySarnoff closed 4 years ago
In principle there is an arbitrary scale factor for eigenvectors, and the LinearAlgebra developers didn't document the selection criterion, but consistency would be preferable. I should have followed the LAPACK convention for normalization (unit Euclidean norm), since that is inherited by Julia for BLAS types. I'll plan on doing that in an upcoming release. Note that an ambiguity of phase factor will likely perdure. Thanks for bringing it to my attention.
Not normalizing eigenvectors results in breakdown of the relation
E,Q = svd(A)
A \approx E*Q*E'
It is a serious bug.
Can you clarify? I'm not aware of a version of svd
which would invoke methods in this package.
But
E,Q = eigen(A)
A \approx Q*Diagonal(E)*inv(Q)
should work with the existing (lack of) normalization, as long as Q
is reasonably well-conditioned.
(I don't mean to be dismissive; I do intend to standardize the normalization.)
Sorry, svd() was a typo.
Note, that in your version you use inv(Q), because the Q is not orthogonal. It is generally expected that the eigenmatrx is orthogonal. Also, if that expression used in program, inv() is going to call eigen() or svd().
That's not a "choice of normalization", it's a serious bug unfixed for a year that broke my program and cost a good part of day to track down.
Leading with ignorance and hoping to provide a coherent way forward ... Here is an answer to how matlab normalizes eigenvectors.
Matlab relies on LAPACK for most of its linear algebra, so it is not surprising that it normalizes the eigenvectors the same way. So does scipy/numpy. Mpmath (python arbitrary precision library) does not use LAPACK, but also normalizes the eigenvectors to unity.
Normalize usually implies to unity
for this class of numerical algorithms.
And that's what Matlab's eig() does. In case of generalized eigenvalue problem it uses non-euclidean norm.
can you make a PR to help, so we resolve this?
I am insufficiently familiar with GenericSchur internals, sorry. In my own program I just normalize them myself
for k = 1:size(Q)[2]
Q[:, k] /= norm(Q[:, k])
end
That will grow superfluous once the eigenvalue normalization is fixed.
The requested normalization convention is in v0.4.0, and is now documented and tested.
(thanks Ralph -- its a hit, a long ball .. and the crowd goes wild!
)
Thank you, Ralph, that is very helpful!