Skip to content

Commit

Permalink
add tests for other univariate transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp committed Jun 17, 2024
1 parent eb6f2f5 commit 2d3c0ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/transformations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ function transform_to(domain::PM1, t::InfRational, y::𝑑Expansion{Dp1}) where
(; A, L) = t
(; coefficients) = y
x0 = transform_to(domain, t, coefficients[1])
N == 1 && return Coefficients(SVector(x0))
Dp1 == 1 && return Coefficients(SVector(x0))
# based on Boyd (2001), Table E.5
Q = 1 - abs2(x0)
sQ = Q
x1 = (coefficients[2] * Q * sQ) / L
N == 2 && return 𝑑Expansion(SVector(x0, x1))
error("$(N-1)th derivative not implemented yet, open an issue.")
Dp1 == 2 && return 𝑑Expansion(SVector(x0, x1))
error("$(Dp1-1)th derivative not implemented yet, open an issue.")
end

domain(::InfRational) = UnivariateDomain(-Inf, Inf)
9 changes: 5 additions & 4 deletions test/test_chebyshev.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ end

@testset "univariate derivatives" begin
basis = Chebyshev(InteriorGrid(), 5)
N = 5
D = 𝑑^Val(N)
for transformation in (BoundedLinear(-2, 3), )
for (transformation, N) in ((BoundedLinear(-2, 3), 5),
(SemiInfRational(0.7, 0.3), 1),
(InfRational(0.4, 0.9), 1))
D = 𝑑^Val(N)
transformed_basis = basis transformation
f = linear_combination(transformed_basis, randn(dimension(transformed_basis)))
for _ in 1:100
for _ in 1:50
x = transform_from(basis, transformation, rand_pm1())
y = f(D(x))
for i in 0:N
Expand Down

0 comments on commit 2d3c0ac

Please sign in to comment.