Skip to content

Commit c7329f1

Browse files
committed
Revert "Revert "add Jacobi matrices for RectPolynomial""
This reverts commit 3a563d5.
1 parent 3a563d5 commit c7329f1

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/rect.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ function getindex(P::RectPolynomial, xy::StaticVector{2}, JR::BlockOneTo)
3636
N = size(JR,1)
3737
DiagTrav(A[x,OneTo(N)] .* B[y,OneTo(N)]')
3838
end
39+
# Actually Jxᵀ
40+
function jacobimatrix(::Val{1}, P::RectPolynomial)
41+
A,B = P.args
42+
X = jacobimatrix(A)
43+
P * KronTrav(Eye{eltype(X)}(∞), X)
44+
end
45+
# Actually Jyᵀ
46+
function jacobimatrix(::Val{2}, P::RectPolynomial)
47+
A,B = P.args
48+
Y = jacobimatrix(B)
49+
P * KronTrav(Y, Eye{eltype(Y)}(∞))
50+
end
3951
@simplify function *(Dx::PartialDerivative{1}, P::RectPolynomial)
4052
A,B = P.args
4153
U,M = (Derivative(axes(A,1))*A).args
@@ -150,4 +162,4 @@ function transform_ldiv(K::KronPolynomial{d,V,<:Fill{<:Legendre}}, f::Union{Abst
150162
T = KronPolynomial{d}(Fill(ChebyshevT{V}(), size(K.args)...))
151163
dat = (T \ f).array
152164
DiagTrav(pad(FastTransforms.th_cheb2leg(paddeddata(dat)), axes(dat)...))
153-
end
165+
end

test/test_rect.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ using ContinuumArrays: plotgridvalues
4343
@test f[SVector(0.1,0.2)] exp(0.1*cos(0.1))
4444
end
4545

46+
@testset "Jacobi matrices" begin
47+
T = ChebyshevT()
48+
U = ChebyshevU()
49+
TU = RectPolynomial(T, U)
50+
X = jacobimatrix(Val{1}(), TU)
51+
Y = jacobimatrix(Val{2}(), TU)
52+
𝐱 = axes(TU, 1)
53+
x, y = first.(𝐱), last.(𝐱)
54+
@test_broken TU \ (x .* TU) # Should create X, but it fails
55+
@test_broken TU \ (y .* TU) # Should create Y, but it fails
56+
f = expand(TU, splat((x,y) -> exp(x*cos(y-0.1))))
57+
g = expand(TU, splat((x,y) -> x*exp(x*cos(y-0.1))))
58+
h = expand(TU, splat((x,y) -> y*exp(x*cos(y-0.1))))
59+
N = 10
60+
@test (TU \ (X * (TU \ f)))[Block.(1:N)] (TU \ g)[Block.(1:N)]
61+
@test (TU \ (Y * (TU \ f)))[Block.(1:N)] (TU \ h)[Block.(1:N)]
62+
end
63+
4664
@testset "Conversion" begin
4765
T = ChebyshevT()
4866
U = ChebyshevU()
@@ -119,4 +137,4 @@ using ContinuumArrays: plotgridvalues
119137
@test x == SVector.(ChebyshevGrid{2}(40), ChebyshevGrid{2}(40)')
120138
@test F == ones(40,40)
121139
end
122-
end
140+
end

0 commit comments

Comments
 (0)