diff --git a/src/ToeplitzMatrices.jl b/src/ToeplitzMatrices.jl index 6ca3f71..7a774cf 100644 --- a/src/ToeplitzMatrices.jl +++ b/src/ToeplitzMatrices.jl @@ -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 @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 27ec70f..6feaf24 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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]