Skip to content

Commit

Permalink
eigen for triangular (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Jan 10, 2024
1 parent 2e3fe7f commit 465d37a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/linearalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,9 @@ function factorize(A::UpperTriangularToeplitz)
dft = plan_fft!(tmp)
return ToeplitzFactorization{T,typeof(A),S,typeof(dft)}(dft * tmp, similar(tmp), dft)
end

# triangular
eigvals(T::TriangularToeplitz) = diag(T)
eigvecs(U::UpperTriangularToeplitz) = eigvecs(UpperTriangular(Matrix(U)))
eigvecs(L::LowerTriangularToeplitz) = eigvecs(LowerTriangular(Matrix(L)))
eigen(U::TriangularToeplitz) = Eigen(eigvals(U), eigvecs(U))
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,16 @@ end
@test_broken inv(TU)::TriangularToeplitz inv(Matrix(TU))
@test inv(TL)::TriangularToeplitz inv(Matrix(TL))
end

@testset "eigen" begin
for T in (UpperTriangularToeplitz, LowerTriangularToeplitz)
for p in ([1:6;], rand(ComplexF64, 5))
M = T(p)
λ, V = eigen(M)
@test M * V V * Diagonal(λ)
end
end
end
end

@testset "Cholesky" begin
Expand Down

0 comments on commit 465d37a

Please sign in to comment.