Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinearAlgebra: extend eigen with left eigenvectors and errorbounds #48657

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

KlausC
Copy link
Contributor

@KlausC KlausC commented Feb 12, 2023

This is a remake of #38483, this time with documentation and test cases included.
The changes (added features) are:

  1. struct Eigen and struct GeneralizedEigen have new matrix field vectorsl to keep optional left eigenvectors.
  2. struct Eigen has additional vector fields eerrbd and verrbd to keep optional error bounds for eigenvalues and eigenvectors.
  3. Function eigen has new boolean keyword arguments left, eerror, verror to opt in the calculation of the new output fields.

The data are obtained by use of the existing LAPACK API. See also user's guide

@simonbyrne simonbyrne added the domain:linear algebra Linear algebra label Feb 13, 2023
@KlausC
Copy link
Contributor Author

KlausC commented Feb 13, 2023

Just saw, that this PR #48657 interferes with #48549. It would be easy to merge both.

(The `k`th eigenvector can be obtained from the slice `F.vectors[:, k]`.)

Iterating the decomposition produces the components `F.values` and `F.vectors`.
Iterating the decomposition produces the components `F.values`, `F.vectors`, `F.vectorsl`,
`F.eerrbd`, `F.verrbd`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean that values, vectors = eigen will not work anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - the lhs tuple needs not to be exhaustive. You can even do a, = [1,2,3] to set a to 1.

Iterating the decomposition produces the components `F.values`, `F.vectors`, `F.vectorsl`,
`F.eerrbd`, `F.verrbd`.

The matrix of left eigenvectors is empty, if not opted in by `eigen( ; left=true)`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's annoying. Can we default to inv(Rvectors)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just compute them unconditionally? Are they much more expensive than the right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calculation of left eigenvectors comes with an effort comparable to that of deriving it from the right vectors. That is approximately 10-15% for n in 100-1000 for random matrices. Actually vl = inv(vr)' ./ cn where cn is to normalize the columns.


The matrix of left eigenvectors is empty, if not opted in by `eigen( ; left=true)`.

The error bounds are empty, if not opted in by `eigen( ; eerror=true, verror=true)`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default to Nan?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xerrbd are both vectors. You propose to give them size n. Why not Inf? For me a full vector of NaN or Inf doesn't look good.

Eigen{T,V,S,U}(values::AbstractVector{V}, vectors::AbstractMatrix{T}) where {T,V,S,U} =
new(values, vectors)
vectorsl::S
eerrbd::R
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These names are very cryptic. We're not constrained by Fortran or the need for short identifiers, might as well give them proper names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names are taken from the LAPACK docu. What do you think about valbounds and vecbounds.


# Generalized eigenvalue problem.
"""
GeneralizedEigen <: Factorization

Matrix factorization type of the generalized eigenvalue/spectral decomposition of
Matrix factorization type of the generalized eigenvalue/apply decomposition of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

@KlausC KlausC Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was an edit error, should be unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants