# Why isn't SymTridiagonal simply Symmetric(Tridiagonal)

**URL:** <https://discourse.julialang.org/t/why-isnt-symtridiagonal-simply-symmetric-tridiagonal/23698>\
**Category:** General Usage\
**Created:** [April 30, 2019, 2:27pm UTC](https://discourse.julialang.org/t/why-isnt-symtridiagonal-simply-symmetric-tridiagonal/23698 "2019-04-30T14:27:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthieu](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Post date:** [April 30, 2019, 2:27pm UTC](https://discourse.julialang.org/t/why-isnt-symtridiagonal-simply-symmetric-tridiagonal/23698/1 "2019-04-30T14:27:33Z")

</div>

Julia defines not only a Tridiagonal type but also a [SymTridiagonal type](https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/tridiag.jl).  
Why is this type needed compared to `Symmetric(Tridiagonal)`, that could still allow function specialization?

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [April 30, 2019, 2:37pm UTC](https://discourse.julialang.org/t/why-isnt-symtridiagonal-simply-symmetric-tridiagonal/23698/2 "2019-04-30T14:37:33Z")

</div>

Possibly memory savings? `Symmetric{<:Any, <:Tridiagonal}` stores a `Tridiagonal`, which stores both the first superdiagonal and the first subdiagonal, while `SymTridiagonal` only stores one of those. I think very large `SymTridiagonal`s are often used, so memory limitations could be a concern.

---

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [April 30, 2025, 11:57pm UTC](https://discourse.julialang.org/t/why-isnt-symtridiagonal-simply-symmetric-tridiagonal/23698/3 "2025-04-30T23:57:54Z")

</div>

I agree with @matthieu  
I think the type `SymTridiagonal` is to some extent redundant.  
Because the combinations are abundant.  
If we have `SymTridiagonal`, why shouldn’t we also have `SymSparse` etc.?

If we want to save memory, we could simply piggyback on `Bidiagonal`, i.e.

```julia
julia> dv = [1, 2, 3, 4];

julia> ev = [7, 8, 9];

julia> Bu = Bidiagonal(dv, ev, :U)
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1 7 ⋅ ⋅
 ⋅ 2 8 ⋅
 ⋅ ⋅ 3 9
 ⋅ ⋅ ⋅ 4

julia> STD = Symmetric(Bu)
4×4 Symmetric{Int64, Bidiagonal{Int64, Vector{Int64}}}:
 1 7 ⋅ ⋅
 7 2 8 ⋅
 ⋅ 8 3 9
 ⋅ ⋅ 9 4

```

in which way also brings the desired Symmetric Tridiagonal matrix.

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [May 1, 2025, 1:12am UTC](https://discourse.julialang.org/t/why-isnt-symtridiagonal-simply-symmetric-tridiagonal/23698/4 "2025-05-01T01:12:25Z")

</div>

Some necropost!

> [@WalterMadelim](#):
>
> the combinations are abundant

Yes, but it’s hard to make sure the infinitude of combinations all dispatch to the most efficient implementations of every algorithm. LAPACK has especially many specialized routines for real symmetric tridiagonal matrices, because reduction to that structure is an intermediate step in almost anything that involves Hermitian or real symmetric matrices. Hence it’s convenient to have a type for specifically representing such matrices, rather than having to use unintuitive wrapper combinations like `Symmetric{T,Bidiagonal{T}}` and hope that someone added all the necessary overloads to keep you on the fast path.

---

<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:** [May 1, 2025, 1:12am UTC](https://discourse.julialang.org/t/why-isnt-symtridiagonal-simply-symmetric-tridiagonal/23698/5 "2025-05-01T01:12:36Z")

</div>

> [@WalterMadelim](#):
>
> If we have `SymTridiagonal`, why shouldn’t we also have `SymSparse` etc.?

There are extremely specialized algorithms to work with `SymTridiagonal` matrices, e.g. LAPACK provides specialized eigensolvers for this case, and specialized routines to transform any Hermitian matrix into real `SymTridiagonal` form (accessible in Julia via e.g. `hessenberg(Hermitian(...))` — it’s a special case of Hessenberg factorization. Such matrices have a very important role in numerical linear algebra.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [May 1, 2025, 1:47am UTC](https://discourse.julialang.org/t/why-isnt-symtridiagonal-simply-symmetric-tridiagonal/23698/6 "2025-05-01T01:47:24Z")

</div>

I do think that if we were rebuilding LinearAlgebra from scratch today, we would just have `Banded{lo, hi}` and `HermitianBanded{hi}` where `Diagonal` would be `Banded{0, 0}` etc.
