From 94db1780077b337e4d0c45ab32b18b68040c189e Mon Sep 17 00:00:00 2001 From: Lucas Aschenbach <37406743+LucasAschenbach@users.noreply.github.com> Date: Thu, 17 Aug 2023 16:37:09 +0200 Subject: [PATCH] Add inverse chebyshev transform plan for Dual (#904) * Add inverse chebyshev transform plan for Dual * Test inverse Chebyshev transform for dual numbers * Version bump to v0.13.23 --- Project.toml | 2 +- ext/ApproxFunDualNumbersExt.jl | 7 ++++--- test/ExtrasTest.jl | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 68fb7b89d..71ea7e3b1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ApproxFun" uuid = "28f2ccd6-bb30-5033-b560-165f7b14dc2f" -version = "0.13.22" +version = "0.13.23" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" diff --git a/ext/ApproxFunDualNumbersExt.jl b/ext/ApproxFunDualNumbersExt.jl index a5aad7ef9..1a59853b2 100644 --- a/ext/ApproxFunDualNumbersExt.jl +++ b/ext/ApproxFunDualNumbersExt.jl @@ -5,9 +5,9 @@ using ApproxFun using ApproxFun: TransformPlan, ITransformPlan import ApproxFunBase: valsdomain_type_promote using DomainSets -import FastTransforms: ChebyshevTransformPlan, plan_chebyshevtransform, - plan_chebyshevtransform!, plan_ichebyshevtransform, - plan_ichebyshevtransform! +import FastTransforms: ChebyshevTransformPlan, IChebyshevTransformPlan, + plan_chebyshevtransform, plan_chebyshevtransform!, + plan_ichebyshevtransform, plan_ichebyshevtransform! # Dual number support. Should there be realpart and dualpart of Space and Domain? DualNumbers.realpart(f::Fun{S,T}) where {S,T<:Dual} = Fun(space(f),realpart.(coefficients(f))) @@ -45,6 +45,7 @@ plan_ichebyshevtransform(v::AbstractVector{D}, ::Val{kind}) where {D<:Dual,kind} Base.:(*)(P::ChebyshevTransformPlan,v::AbstractVector{<:Dual}) = dual.(P*realpart.(v),P*dualpart.(v)) +Base.:(*)(P::IChebyshevTransformPlan,v::AbstractVector{<:Dual}) = dual.(P*realpart.(v),P*dualpart.(v)) #TODO: Hardy{false} for (OP,TransPlan) in ((:plan_transform,:TransformPlan),(:plan_itransform,:ITransformPlan)), diff --git a/test/ExtrasTest.jl b/test/ExtrasTest.jl index 5c150cc74..858087e20 100644 --- a/test/ExtrasTest.jl +++ b/test/ExtrasTest.jl @@ -56,6 +56,9 @@ include(joinpath(@__DIR__, "testutils.jl")) f=Fun(x->exp(dual(x,1)),-1..1) @test coefficients(realpart(f)) == realpart.(coefficients(f)) @test coefficients(dualpart(f)) == dualpart.(coefficients(f)) + + # Test inverse Chebyshev transform for dual numbers + @test all(absdual.(transform(space(f),values(f)) - coefficients(f)) .< 10eps()) end @testset "Eig test #336" begin