Skip to content

Commit

Permalink
triangular stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch committed Feb 19, 2022
1 parent 1aa995c commit 2943b4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/ToeplitzMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ convert(::Type{Toeplitz{T}}, A::Toeplitz) where {T} = Toeplitz(convert(Vector{T}
convert(Vector{T}, A.vr))

adjoint(A::Toeplitz) = Toeplitz(conj(A.vr), conj(A.vc))
adjoint(A::Toeplitz{<:Real}) = transpose(A)
transpose(A::Toeplitz) = Toeplitz(A.vr, A.vc)

# Size of a general Toeplitz matrix
Expand Down Expand Up @@ -585,10 +584,8 @@ function (*)(A::TriangularToeplitz, B::TriangularToeplitz)
return A * Matrix(B)
end

function Base.:*(A::Adjoint{<:Any,<:TriangularToeplitz}, b::AbstractVector)
M = parent(A)
return TriangularToeplitz{eltype(M)}(M.ve, M.uplo) * b
end
adjoint(A::TriangularToeplitz) = TriangularToeplitz(conj(A.ve), A.uplo == 'U' ? (:L) : (:U))
transpose(A::TriangularToeplitz) = TriangularToeplitz(A.ve, A.uplo == 'U' ? (:L) : (:U))

# NB! only valid for lower triangular
function smallinv(A::TriangularToeplitz{T}) where T
Expand Down
9 changes: 7 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,22 @@ end
for T in (TU, TL)
@test inv(T)::TriangularToeplitz inv(Matrix(T))
end
A = randn(ComplexF64, 3, 3)
T = Toeplitz(A)
TU = triu(T)
@test TU isa TriangularToeplitz
@test istriu(TU)
@test TU == Toeplitz(triu(A))
@test TU'ones(2) == Matrix(TU)'ones(2)
@test TU'ones(3) == Matrix(TU)'ones(3)
@test transpose(TU)*ones(3) == transpose(Matrix(TU))*ones(3)
@test triu(T, 1)::TriangularToeplitz == triu(Matrix(T), 1)
TL = tril(T)
@test TL isa TriangularToeplitz
@test istril(TL)
@test TL == Toeplitz(tril(A))
@test TL'ones(2) == Matrix(TL)'ones(2)
@test TL'ones(3) == Matrix(TL)'ones(3)
@test transpose(TL)*ones(3) == transpose(Matrix(TL))*ones(3)
@test tril(T, -1)::TriangularToeplitz == tril(Matrix(T), -1)
for n in (65, 128)
A = randn(n, n)
TU = TriangularToeplitz(A, :U)
Expand Down

0 comments on commit 2943b4f

Please sign in to comment.