From c0dbc3389058aa24f2d672965b6acaec68bbe3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Mon, 27 Nov 2023 17:22:07 +0100 Subject: [PATCH] Fix promotion of complex polys (#1588) --- src/arb/ComplexPoly.jl | 2 ++ src/arb/acb_poly.jl | 2 ++ test/arb/ComplexPoly-test.jl | 8 ++++++++ test/arb/acb_poly-test.jl | 8 ++++++++ 4 files changed, 20 insertions(+) diff --git a/src/arb/ComplexPoly.jl b/src/arb/ComplexPoly.jl index da0b9b5f35..5d95ba8f42 100644 --- a/src/arb/ComplexPoly.jl +++ b/src/arb/ComplexPoly.jl @@ -777,6 +777,8 @@ promote_rule(::Type{ComplexPoly}, ::Type{QQPolyRingElem}) = ComplexPoly promote_rule(::Type{ComplexPoly}, ::Type{arb_poly}) = ComplexPoly +promote_rule(::Type{ComplexPoly}, ::Type{ComplexPoly}) = ComplexPoly + function promote_rule(::Type{ComplexPoly}, ::Type{T}) where {T} return promote_rule(ComplexFieldElem, T) === ComplexFieldElem ? ComplexPoly : Union{} end diff --git a/src/arb/acb_poly.jl b/src/arb/acb_poly.jl index 0a8c8f6c86..79e375b571 100644 --- a/src/arb/acb_poly.jl +++ b/src/arb/acb_poly.jl @@ -774,6 +774,8 @@ promote_rule(::Type{acb_poly}, ::Type{QQPolyRingElem}) = acb_poly promote_rule(::Type{acb_poly}, ::Type{arb_poly}) = acb_poly +promote_rule(::Type{acb_poly}, ::Type{acb_poly}) = acb_poly + function promote_rule(::Type{acb_poly}, ::Type{T}) where {T} return promote_rule(acb, T) === acb ? acb_poly : Union{} end diff --git a/test/arb/ComplexPoly-test.jl b/test/arb/ComplexPoly-test.jl index 6ebe5d9d99..8ea810689e 100644 --- a/test/arb/ComplexPoly-test.jl +++ b/test/arb/ComplexPoly-test.jl @@ -386,3 +386,11 @@ end @test all([ abs(z[i] + onei(CC)) <= b for i in 1:r]) end end + +@testset "Issue #1587" begin + CC = ComplexField() + R, t = polynomial_ring(CC, "t") + D, Dt = polynomial_ring(R, "Dt") + A_scalarform = t^3 * (32 * t^2 - 1) * (32 * t^2 + 1) * Dt^4 + 2 * t^2 * (7168 * t^4 - 3) * Dt^3 + t * (55296 * t^4 - 7) * Dt^2 + (61440 * t^4 - 1) * Dt + 12288 * t^3 + @test A_scalarform isa PolyRingElem{ComplexPoly} +end diff --git a/test/arb/acb_poly-test.jl b/test/arb/acb_poly-test.jl index 6c523ef3b7..6f1cc06a52 100644 --- a/test/arb/acb_poly-test.jl +++ b/test/arb/acb_poly-test.jl @@ -386,3 +386,11 @@ end @test all([ abs(z[i] + onei(CC)) <= b for i in 1:r]) end end + +@testset "Issue #1587" begin + CC = AcbField(32) + R, t = polynomial_ring(CC, "t") + D, Dt = polynomial_ring(R, "Dt") + A_scalarform = t^3 * (32 * t^2 - 1) * (32 * t^2 + 1) * Dt^4 + 2 * t^2 * (7168 * t^4 - 3) * Dt^3 + t * (55296 * t^4 - 7) * Dt^2 + (61440 * t^4 - 1) * Dt + 12288 * t^3 + @test A_scalarform isa PolyRingElem{acb_poly} +end