# Get an eigvec by eigval, using eigvecs, only allow SymTridiagonal?

**URL:** <https://discourse.julialang.org/t/get-an-eigvec-by-eigval-using-eigvecs-only-allow-symtridiagonal/127408>\
**Category:** New to Julia\
**Tags:** question, linearalgebra\
**Created:** [March 27, 2025, 11:14am UTC](https://discourse.julialang.org/t/get-an-eigvec-by-eigval-using-eigvecs-only-allow-symtridiagonal/127408 "2025-03-27T11:14:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [March 27, 2025, 1:12pm UTC](https://discourse.julialang.org/t/get-an-eigvec-by-eigval-using-eigvecs-only-allow-symtridiagonal/127408/2 "2025-03-27T13:12:07Z")

</div>

The `eigvecs(A, λ)` method is currently only implemented for `SymTridiagonal` matrices. For other matrix types there is currently only `eigvecs(A)`.

In principle, we could easily extend this to real-symmetric/Hermitian matrices, since they can be transformed into real `SymTridiagonal` matrices by the Hessenberg factorization. This should work:

```julia
using LinearAlgebra
import LinearAlgebra: eigvecs, RealHermSymComplexHerm

function eigvecs(A::RealHermSymComplexHerm, λ::AbstractVector{<:Real})
    F = hessenberg(A) # transform to SymTridiagonal form
    X = eigvecs(F.H, λ)
    return F.Q * X # transform eigvecs of F.H back to eigvecs of A
end

```

For only computing a small subset of the eigenvectors, it seems to be a couple times faster than `eigvecs`, especially if you don’t count the cost of the eigenvalues (e.g. you already have them for some other reason).

Might be worth putting together a PR to [LinearAlgebra.jl](https://github.com/JuliaLang/LinearAlgebra.jl) if you are interested in this functionality? [eigvecs(A::Hermitian, eigvals) method? · Issue #1248 · JuliaLang/LinearAlgebra.jl · GitHub](https://github.com/JuliaLang/LinearAlgebra.jl/issues/1248)

> [@WalterMadelim](#):
>
> Should I use the following method instead? Is this the correct usage?

No. `nullspace` employs an SVD, which is as costly as computing all the eigenvectors and eigenvalues with `eigen`. (In fact, the SVD calls `eigen` for Hermitian matrices.)

---

_[View the full topic](https://discourse.julialang.org/t/get-an-eigvec-by-eigval-using-eigvecs-only-allow-symtridiagonal/127408)._
