Skip to content

Commit

Permalink
Fix promotion of complex polys (#1588)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Nov 27, 2023
1 parent 9c780a4 commit c0dbc33
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/arb/ComplexPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/arb/acb_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/arb/ComplexPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions test/arb/acb_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c0dbc33

Please sign in to comment.