# Economy-sized eigendecomposition?

**URL:** <https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037>\
**Category:** General Usage\
**Tags:** eigenvalues, eigenvectors\
**Created:** [January 21, 2025, 6:09pm UTC](https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037 "2025-01-21T18:09:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benninkrs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benninkrs/32/3191_2.png) [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Post date:** [January 21, 2025, 6:09pm UTC](https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037/1 "2025-01-21T18:09:44Z")

</div>

Perhaps I’ve missed it, but is there a way to obtain the “economy” eigendecomposition of a matrix whose rank is less than the dimension? That is, if `A` is size `n` and rank `r < n`, I would like to store just `r` eigenvalues and `r` eigenvectors. But `eigen` seems to always return all `n` eigenvalues and eigenvectors.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 21, 2025, 6:43pm UTC](https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037/2 "2025-01-21T18:43:27Z")

</div>

In practice, because of floating-point roundoff errors, it’s pretty much impossible to distinguish eigenvalues that are zero from eigenvalues that are just very small. (For the same reason, numerical libraries don’t generally compute the “compact” SVD.)

Of course, you can compute all of the eigenvectors and eigenvalues and then discard those for which |\lambda| / \max |\lambda| falls below some tolerance. In principle, I could imagine an algorithm that does this automatically, but I’m not aware of an existing library routine for this.

---

<div class="post-metadata">

**Author:** ![benninkrs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benninkrs/32/3191_2.png) [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Post date:** [January 21, 2025, 7:11pm UTC](https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037/3 "2025-01-21T19:11:50Z")

</div>

Yes, some thresholding would be needed. The `rank` function already does this, so presumably the same strategy could be used in `eigen`. I think it would be a nice option to have when working with matrices whose dimension is much greater than their rank.

My deeper interest here is knowing whether the `LinearAlgebra` package (and perhaps even broader ecosystem) is set up to work with rank-deficient eigendecompositions, since I am developing my own methods to obtain such a representation as part of a larger algorithm. I found that the `Eigen` type _can_ be constructed with `r < n` eigenvalues/vectors, but I do not know whether existing methods assume a full representation. I suppose it wouldn’t be too hard to just try.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 25, 2025, 12:21am UTC](https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037/5 "2025-01-25T00:21:27Z")

</div>

> [@benninkrs](#):
>
> I think it would be a nice option to have when working with matrices whose dimension is much greater than their rank.

If the matrix is extremely low rank, you are in a somewhat different regime than the dense linear algebra of LAPACK that is in the LinearAlgebra stdlib — you are may be more in the regime of randomized sketching and similar (ala LowRankApprox.jl).

Indeed, LowRankApprox.jl implements a partial Hermitian eigendecomposition. (If your matrix is _not_ Hermitian, you should be cautious about using eigenvectors at all.)

---

<div class="post-metadata">

**Author:** ![benninkrs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benninkrs/32/3191_2.png) [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Post date:** [January 25, 2025, 3:29pm UTC](https://discourse.julialang.org/t/economy-sized-eigendecomposition/125037/6 "2025-01-25T15:29:55Z")

</div>

Thanks.

I see that [LowRankApprox](https://github.com/JuliaLinearAlgebra/LowRankApprox.jl) uses its own datatype for storing the thin factorizations rather than using the `Eigen` type from `LinearAlgebra`. I initially thought it would be nice to coopt `Eigen` for this, but upon further investigation tjhat doesn’t seem quite so useful. In `Base` there are only 9 methods that take an `Eigen` and they are all trivial, so it’s not as if there’s a large codebase to take advantage of. And some of these methods (e.g .`inv`) are only useful if the rank is maximal anyway.
