Comments (6)
What you want is the Schur decomposition yes?
https://docs.rs/nalgebra/latest/nalgebra/base/struct.Matrix.html#method.schur
If this doesn't work and you need the classical eigen decomp then the Lapack version of the crate has:
https://docs.rs/nalgebra-lapack/latest/nalgebra_lapack/struct.Eigen.html
from nalgebra.
How can we implement this in rust though, seems a bit too complex tbh
from nalgebra.
I believe the current implementation of the Schur Decomposition uses an Arnodli iteration so it is already implemented in Nalgebra! This Schur decomposition is a generalization of the Spectral Decomposition.
I believe the Lapack implementation uses Householder transformations? The Lapack API and algorithm is well studied and documented if you want to RWIR. The Nalgebra-Lapack bindings are quite simple to use, though, and works great for integrating Rust code with existing numerical implementations.
I see that @sebcrozet added some tags to this issue, I'm wondering what kind of algorithms or enhancements you would like to see in this area? Maybe a simpler API for generalized eigen problems using the available tools?
from nalgebra.
Nalgebra already has a method to calculate the eigen values of a matrix. Why not use it to find the eigenvalues and then create the diagonal matrix corresponding and return it or there is some problem?
from nalgebra.
I would prefer a pure Rust verrsion for compatibility with Wasm. For now, I'm able to use nalgebra_lapack
but I get slightly different results between nalgebra_lapack
, ndarray-linalg
and custom code to retrieve the vectors. I'm not super familiar with the different algorithms so I'm not sure if those are just precision issues or errors.
from nalgebra.
get slightly different results between nalgebra_lapack, ndarray-linalg
This is likely a difference in implementation and probably isn't a bug, especially if the results are similar. Also note, if you have repeated eigenvalues the decomposition isn't unique, so this could be why you get different results.
There are a lot of things to consider here when choosing an API for your task. For instance, you mention that you want the entire decomposition for a non-symmetric matrix, but not all non-symmetric matrices are diagonalizable unless you allow for the complex values.
Computing eigenvectors for ill-conditioned non-symmetric matrices is a complicated task and there are many specialized algorithms and parameters built into lapack for it, see this and this from the lapack guide.
ndarray-linalg
probably uses _geev
(docs), I don't think there exists a pure rust implementation but the tools to build a naive version definitely exist in these libraries. It would be cool to try and put together an implementation in nalgebra
based off what is documented above. If anyone wants help with that I can help when I have time.
If no one has done it yet, it is likely because generalizations such as the SVD or Schur Decomposition can often be used instead and have consistent, stable, and fast algorithms. If you provide more context for your problem I might be able to suggest a way to use these existing tools instead.
If your matrices are small, do the easy thing taught in into linear by computing the eigenvalues, subtract from diagonal, and then solve for Av=0
. Using the available solve
and eigs
functions you could stay in pure rust this way, just be aware of the footguns like:
- needing complex entries
- could have multiple eigenvectors for an eigenvalue
- if you have repeated eigenvalues then the decomposition is not unique, as any orthogonal basis of the associated eigenspace are valid eigenvectors
from nalgebra.
Related Issues (20)
- Add a way to get a column slice HOT 2
- Missed minor version bump? HOT 2
- Wrong result of min() and max() in nalgebra::base::min_max::Matrix when f64::NAN is included HOT 4
- CUDA target is unmaintained HOT 1
- lapack qr factorization HOT 1
- When using nalgebra_glm, how to call transform_point?
- Planes and Culling Frustums HOT 1
- Unable to multiply complex matrix with complex scalar from the left HOT 2
- Allow bitshifting matricies if they are integers HOT 3
- SymmetricEigen produces wrong sign of eigenvector values on Matrix6 HOT 4
- Wrong eigenvector sorting in nalgebra::SymmetricEigen, while correct in nalgebra_lapack::SymmetricEigen HOT 1
- Make some RealField functions const HOT 1
- `tr_solve_upper_triangular` proptest failure
- Hash for Matrix doesn't match `Borrow<[[T; R]; C]>` semantics
- Cannot compute the SVD of an empty matrix. HOT 2
- Matrix Display output alignment is not Unicode-aware HOT 4
- Multiply matrix by vector row-wise HOT 6
- matrix literals or const constructors HOT 1
- `normalize` docs need expansion HOT 1
- Test flake in `f64::symmetric_eigen`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nalgebra.