Skip to content
Merged
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
14 changes: 13 additions & 1 deletion src/rect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ function getindex(P::RectPolynomial, xy::StaticVector{2}, JR::BlockOneTo)
N = size(JR,1)
DiagTrav(A[x,OneTo(N)] .* B[y,OneTo(N)]')
end
# Actually Jxᵀ
function jacobimatrix(::Val{1}, P::RectPolynomial)
A,B = P.args
X = jacobimatrix(A)
KronTrav(Eye{eltype(X)}(∞), X)
end
# Actually Jyᵀ
function jacobimatrix(::Val{2}, P::RectPolynomial)
A,B = P.args
Y = jacobimatrix(B)
KronTrav(Y, Eye{eltype(Y)}(∞))
end
@simplify function *(Dx::PartialDerivative{1}, P::RectPolynomial)
A,B = P.args
U,M = (Derivative(axes(A,1))*A).args
Expand Down Expand Up @@ -150,4 +162,4 @@ function transform_ldiv(K::KronPolynomial{d,V,<:Fill{<:Legendre}}, f::Union{Abst
T = KronPolynomial{d}(Fill(ChebyshevT{V}(), size(K.args)...))
dat = (T \ f).array
DiagTrav(pad(FastTransforms.th_cheb2leg(paddeddata(dat)), axes(dat)...))
end
end
21 changes: 20 additions & 1 deletion test/test_rect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ using ContinuumArrays: plotgridvalues
@test f[SVector(0.1,0.2)] ≈ exp(0.1*cos(0.1))
end

@testset "Jacobi matrices" begin
T = ChebyshevT()
U = ChebyshevU()
TU = RectPolynomial(T, U)
X = jacobimatrix(Val{1}(), TU)
Y = jacobimatrix(Val{2}(), TU)
𝐱 = axes(TU, 1)
x, y = first.(𝐱), last.(𝐱)
N = 10
KR = Block.(1:N)
@test (TU \ (x .* TU))[KR,KR] == X[KR,KR]
@test (TU \ (y .* TU))[KR,KR] == Y[KR,KR]
f = expand(TU, splat((x,y) -> exp(x*cos(y-0.1))))
g = expand(TU, splat((x,y) -> x*exp(x*cos(y-0.1))))
h = expand(TU, splat((x,y) -> y*exp(x*cos(y-0.1))))
@test (X * (TU \ f))[KR] ≈ (TU \ g)[KR]
@test (Y * (TU \ f))[KR] ≈ (TU \ h)[KR]
end

@testset "Conversion" begin
T = ChebyshevT()
U = ChebyshevU()
Expand Down Expand Up @@ -119,4 +138,4 @@ using ContinuumArrays: plotgridvalues
@test x == SVector.(ChebyshevGrid{2}(40), ChebyshevGrid{2}(40)')
@test F == ones(40,40)
end
end
end