From 73331de0c360f726766b7687bb57c36cf5f8b3e4 Mon Sep 17 00:00:00 2001 From: jverzani Date: Wed, 22 Dec 2021 15:15:15 -0500 Subject: [PATCH 1/2] conversion from ChebyshevT; close issue #372 --- Project.toml | 2 +- src/polynomials/ChebyshevT.jl | 3 ++- test/ChebyshevT.jl | 10 ++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 555ba30a..9bfadb73 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "Polynomials" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" license = "MIT" author = "JuliaMath" -version = "2.0.19" +version = "2.0.20" [deps] Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5" diff --git a/src/polynomials/ChebyshevT.jl b/src/polynomials/ChebyshevT.jl index d5c6d7d7..d215a820 100644 --- a/src/polynomials/ChebyshevT.jl +++ b/src/polynomials/ChebyshevT.jl @@ -57,7 +57,8 @@ end @register ChebyshevT function Base.convert(P::Type{<:Polynomial}, ch::ChebyshevT) - T = eltype(P) + + T = _eltype(P,ch) X = indeterminate(P,ch) Q = ⟒(P){T,X} diff --git a/test/ChebyshevT.jl b/test/ChebyshevT.jl index 6dad84bd..00fa3228 100644 --- a/test/ChebyshevT.jl +++ b/test/ChebyshevT.jl @@ -166,7 +166,7 @@ end # issue 326 evaluate outside of domain @test Polynomials.evalpoly(2, c1, false) ≈ fn(2) @test Polynomials.evalpoly(3, c1, false) ≈ fn(3) - + # GCD c1 = ChebyshevT([1, 2, 3]) c2 = ChebyshevT([3, 2, 1]) @@ -221,6 +221,12 @@ end # issue #295 x = BigFloat[-2/3, -1/3, 1/3, 2/4] y = BigFloat[1, 2, 3, 4] - fit(ChebyshevT, x, y, 1) + fit(ChebyshevT, x, y, 1) + + # issue #372 + xs = [0,0,1] + @test eltype(convert(Polynomial, ChebyshevT{Float64}(xs))) == Float64 + @test eltype(convert(Polynomial, ChebyshevT{BigFloat}(xs))) == BigFloat + @test eltype(convert(Polynomial{BigFloat}, ChebyshevT(xs))) == BigFloat end From 157f13f5d2dac9104ed53bbb8eea70bdfedfefe0 Mon Sep 17 00:00:00 2001 From: jverzani Date: Wed, 22 Dec 2021 21:02:59 -0500 Subject: [PATCH 2/2] doctest fix --- docs/src/polynomials/chebyshev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/polynomials/chebyshev.md b/docs/src/polynomials/chebyshev.md index e711a9fb..38d79854 100644 --- a/docs/src/polynomials/chebyshev.md +++ b/docs/src/polynomials/chebyshev.md @@ -31,7 +31,7 @@ ChebyshevT(1⋅T_0(x) + 3⋅T_2(x) + 4⋅T_3(x)) julia> p = convert(Polynomial, c) -Polynomial(-2.0 - 12.0*x + 6.0*x^2 + 16.0*x^3) +Polynomial(-2 - 12*x + 6*x^2 + 16*x^3) julia> convert(ChebyshevT, p) ChebyshevT(1.0⋅T_0(x) + 3.0⋅T_2(x) + 4.0⋅T_3(x))