Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/ToeplitzMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import LinearAlgebra: Cholesky, Factorization
import LinearAlgebra: ldiv!, factorize, lmul!, pinv, eigvals, eigvecs, eigen, Eigen, det
import LinearAlgebra: cholesky!, cholesky, tril!, triu!, checksquare, rmul!, dot, mul!, tril, triu
import LinearAlgebra: istriu, istril, isdiag
import LinearAlgebra: UpperTriangular, LowerTriangular, Symmetric, Adjoint
import LinearAlgebra: UpperTriangular, LowerTriangular, Symmetric, Adjoint, Transpose
import LinearAlgebra: issymmetric, ishermitian
import LinearAlgebra: eigvals, eigvecs, eigen

Expand Down Expand Up @@ -38,6 +38,26 @@ include("iterativeLinearSolvers.jl")
# Abstract
abstract type AbstractToeplitz{T<:Number} <: AbstractMatrix{T} end

function getproperty(A::Transpose{<:Number, <:AbstractToeplitz}, s::Symbol)
if s == :vc
getproperty(parent(A), :vr)
elseif s == :vr
getproperty(parent(A), :vc)
else
getfield(A, s)
end
end

function getproperty(A::Adjoint{<:Number, <:AbstractToeplitz}, s::Symbol)
if s == :vc
vec(adjoint(getproperty(parent(A), :vr)))
elseif s == :vr
vec(adjoint(getproperty(parent(A), :vc)))
else
getfield(A, s)
end
end

size(A::AbstractToeplitz) = (length(A.vc),length(A.vr))
@inline _vr(A::AbstractToeplitz) = A.vr
@inline _vc(A::AbstractToeplitz) = A.vc
Expand Down
22 changes: 22 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ for (As, Al, st) in cases
end
end

@testset "Transpose/Adjoint wrappers" begin
vc, vr = [0,im,0], [0, 2+3im, 0]
@testset "Toeplitz" begin
T = Toeplitz(vc, vr)
@test Transpose(T).vc == vr
@test Transpose(T).vr == vc
@test Adjoint(T).vc == vec(vr')
@test Adjoint(T).vr == vec(vc')
end

@testset for TT in (Circulant,
UpperTriangularToeplitz, LowerTriangularToeplitz,
SymmetricToeplitz)
T = TT(vc)
M = Matrix(T)
@test Transpose(T).vc == ToeplitzMatrices._vr(M)
@test Transpose(T).vr == ToeplitzMatrices._vc(M)
@test Adjoint(T).vc == vec(ToeplitzMatrices._vr(M)')
@test Adjoint(T).vr == vec(ToeplitzMatrices._vc(M)')
end
end

@testset "vector indexing" begin
T = Toeplitz(rand(3,3))
@test T[1:2, 1:2] == Matrix(T)[1:2, 1:2]
Expand Down