Skip to content

Commit da4eb89

Browse files
authored
Conversions from Polynomials.ChebyshevT (#305)
* Conversions from Polynomials.ChebyshevT * Conversion from Fun to ChebyshevT
1 parent b13bf09 commit da4eb89

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

Project.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721"
1515
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
1616
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1717
OddEvenIntegers = "8d37c425-f37a-4ca2-9b9d-a61bc06559d2"
18+
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
1819
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1920
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2021
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
2122
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
2223

2324
[weakdeps]
25+
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
2426
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
2527

2628
[extensions]
29+
ApproxFunOrthogonalPolynomialsPolynomialsExt = "Polynomials"
2730
ApproxFunOrthogonalPolynomialsStaticExt = "Static"
2831

2932
[compat]
@@ -42,6 +45,7 @@ HalfIntegers = "1.5"
4245
IntervalSets = "0.5, 0.6, 0.7"
4346
LazyArrays = "0.22, 1"
4447
OddEvenIntegers = "0.1.8"
48+
Polynomials = "2, 3, 4"
4549
Reexport = "0.2, 1"
4650
SpecialFunctions = "0.10, 1.0, 2"
4751
Static = "0.8"
@@ -53,9 +57,10 @@ ApproxFunBaseTest = "a931bfaf-0cfd-4a5c-b69c-bf2eed002b43"
5357
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
5458
DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"
5559
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
60+
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
5661
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
5762
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
5863
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5964

6065
[targets]
61-
test = ["ApproxFunBaseTest", "Aqua", "DualNumbers", "Test", "Static", "StaticArrays", "LazyArrays"]
66+
test = ["ApproxFunBaseTest", "Aqua", "DualNumbers", "Test", "Static", "StaticArrays", "LazyArrays", "Polynomials"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module ApproxFunOrthogonalPolynomialsPolynomialsExt
2+
3+
using ApproxFunOrthogonalPolynomials
4+
import Polynomials
5+
import ApproxFunBase: Fun
6+
7+
Fun(C::Polynomials.ChebyshevT, s::Chebyshev{<:ChebyshevInterval}) =
8+
Fun(s, float.(Polynomials.coeffs(C)))
9+
10+
Polynomials.ChebyshevT(f::Fun{<:Chebyshev{<:ChebyshevInterval}}) =
11+
Polynomials.ChebyshevT(copy(coefficients(f)))
12+
13+
end

src/ApproxFunOrthogonalPolynomials.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ include("show.jl")
183183

184184
if !isdefined(Base, :get_extension)
185185
include("../ext/ApproxFunOrthogonalPolynomialsStaticExt.jl")
186+
include("../ext/ApproxFunOrthogonalPolynomialsPolynomialsExt.jl")
186187
end
187188

188189
end

test/ChebyshevTest.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ using Test
88
using ApproxFunBase: transform!, itransform!
99
using ApproxFunBaseTest: testspace
1010
using ApproxFunOrthogonalPolynomials: forwardrecurrence
11+
import Polynomials
1112

1213
include("testutils.jl")
1314

@@ -482,6 +483,15 @@ include("testutils.jl")
482483

483484
@test normalizedspace(NS) == NS
484485
end
486+
487+
@testset "Polynomials" begin
488+
C = Polynomials.ChebyshevT(Float64[1,2,3])
489+
f = Fun(C, Chebyshev())
490+
@test Polynomials.coeffs(C) == coefficients(f)
491+
@test C(0.2) f(0.2)
492+
C2 = Polynomials.ChebyshevT(f)
493+
@test C == C2
494+
end
485495
end
486496

487497
end # module

0 commit comments

Comments
 (0)