Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Nov 12, 2023
1 parent e3538e1 commit 1e952d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/toeplitzhankel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ for f in (:leg2cheb, :leg2chebu)
TLC = Symbol("_", f, "TH_TLC")
@eval begin
$plan(::Type{S}, mn::NTuple{N,Int}, dims::Int) where {S,N} = ToeplitzHankelPlan($TLC(S, mn, dims)..., dims)
function $plan(::Type{S}, mn::NTuple{N,Int}, dims=ntuple(identity,Val(N))) where {S,N}
function $plan(::Type{S}, mn::NTuple{N,Int}, dims) where {S,N}
TLCs = $TLC.(S, Ref(mn), dims)
ToeplitzHankelPlan{S,N}(map(first, TLCs), map(TLC -> TLC[2], TLCs), map(last, TLCs), dims)
end
Expand Down Expand Up @@ -221,7 +221,7 @@ end

plan_th_cheb2leg!(::Type{S}, mn::NTuple{N,Int}, dims::Int) where {S,N} = ChebyshevToLegendrePlanTH(ToeplitzHankelPlan(_cheb2legTH_TLC(S, mn, dims)..., dims))

function plan_th_cheb2leg!(::Type{S}, mn::NTuple{N,Int}, dims=ntuple(identity,Val(N))) where {S,N}
function plan_th_cheb2leg!(::Type{S}, mn::NTuple{N,Int}, dims) where {S,N}
TLCs = _cheb2legTH_TLC.(S, Ref(mn), dims)
ChebyshevToLegendrePlanTH(ToeplitzHankelPlan{S,N}(map(first, TLCs), map(TLC -> TLC[2], TLCs), map(last, TLCs), dims))
end
Expand Down
57 changes: 28 additions & 29 deletions test/toeplitzhankeltests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,36 +132,35 @@ Random.seed!(0)
end

@testset "tensor" begin
X = randn(5,4,3)
for trans in (th_leg2cheb, th_cheb2leg)
Y = trans(X, 1)
for= 1:size(X,3)
@test Y[:,:,ℓ] trans(X[:,:,ℓ],1)
end
Y = trans(X, 2)
for= 1:size(X,3)
@test Y[:,:,ℓ] trans(X[:,:,ℓ],2)
end
Y = trans(X, 3)
for j = 1:size(X,2)
@test Y[:,j,:] trans(X[:,j,:],2)
end

Y = trans(X, (1,3))
for j = 1:size(X,2)
@test Y[:,j,:] trans(X[:,j,:])
end

Y = trans(X, 1:3)
M = copy(X)
for j = 1:size(X,3)
M[:,:,j] = trans(M[:,:,j])
end
for k = 1:size(X,1), j=1:size(X,2)
M[k,j,:] = trans(M[k,j,:])
end
@test M Y
X = randn(5,4,3)
for trans in (th_leg2cheb, th_cheb2leg)
Y = trans(X, 1)
for= 1:size(X,3)
@test Y[:,:,ℓ] trans(X[:,:,ℓ],1)
end
Y = trans(X, 2)
for= 1:size(X,3)
@test Y[:,:,ℓ] trans(X[:,:,ℓ],2)
end
Y = trans(X, 3)
for j = 1:size(X,2)
@test Y[:,j,:] trans(X[:,j,:],2)
end

Y = trans(X, (1,3))
for j = 1:size(X,2)
@test Y[:,j,:] trans(X[:,j,:])
end

Y = trans(X, 1:3)
M = copy(X)
for j = 1:size(X,3)
M[:,:,j] = trans(M[:,:,j])
end
for k = 1:size(X,1), j=1:size(X,2)
M[k,j,:] = trans(M[k,j,:])
end
@test M Y
end
end
end

0 comments on commit 1e952d3

Please sign in to comment.