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

Implement eigenvalue and eigenvector computation #589

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

squaaawk
Copy link

A first implementation of eigenvalue computation in glam. Closes #321.

I intend to add eigenvector computation as well, but I would like some feedback on how to integrate this with glam first. This is a draft PR for two reasons:

  1. The question of how to return complex values. Eigenvalues (and eigenvectors) can be complex, which glam does not support (and a full implementation of is beyond scope). Right now, I provide two methods for each matrix type: a general case eigenvalue function, which returns two-dimensional vectors storing the real and imaginary components, and a specialized eigenvalue function for symmetric matrices, where all eigenvalues are real. This storage of complex eigenvalues is not ideal, and would be more awkward for returning complex eigenvectors.

  2. The question of where to integrate the code with glam's types. The computation of eigenvectors, which has not been implemented yet, shares most of the work with the computation of eigenvalues. As such, the simple implementation of a .eigenvalues() and a .eigenvectors() method on each matrix type would be computationally inefficient. One option is to have one method which returns both, but eigenvalue computation can be more efficient if eigenvectors are not requested.

I have not looked too far into performance optimizations, just primarily correctness. There may be edge cases the current algorithm fails on I haven't encountered yet.

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

Successfully merging this pull request may close these issues.

eigenvalues and eigenvectors
1 participant