Skip to content

Commit

Permalink
Adjust more compose (#1676)
Browse files Browse the repository at this point in the history
* Adjust more `compose`

* add tests and bump version
  • Loading branch information
joschmitt authored Feb 14, 2024
1 parent 89e4f5d commit a0aa32c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/flint/fmpz_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -748,14 +748,14 @@ function chebyshev_t(n::Int, x::ZZPolyRingElem)
z = parent(x)()
ccall((:fmpz_poly_chebyshev_t, libflint), Nothing,
(Ref{ZZPolyRingElem}, Int), z, n)
return is_gen(x) ? z : compose(z, x)
return is_gen(x) ? z : compose(z, x, inner = :second)
end

function chebyshev_u(n::Int, x::ZZPolyRingElem)
z = parent(x)()
ccall((:fmpz_poly_chebyshev_u, libflint), Nothing,
(Ref{ZZPolyRingElem}, Int), z, n)
return is_gen(x) ? z : compose(z, x)
return is_gen(x) ? z : compose(z, x, inner = :second)
end

@doc raw"""
Expand Down Expand Up @@ -786,7 +786,7 @@ function swinnerton_dyer(n::Int, x::ZZPolyRingElem)
z = parent(x)()
ccall((:fmpz_poly_swinnerton_dyer, libflint), Nothing,
(Ref{ZZPolyRingElem}, Int), z, n)
return is_gen(x) ? z : compose(z, x)
return is_gen(x) ? z : compose(z, x, inner = :second)
end

@doc raw"""
Expand All @@ -800,7 +800,7 @@ function cos_minpoly(n::Int, x::ZZPolyRingElem)
z = parent(x)()
ccall((:fmpz_poly_cos_minpoly, libflint), Nothing,
(Ref{ZZPolyRingElem}, Int), z, n)
return is_gen(x) ? z : compose(z, x)
return is_gen(x) ? z : compose(z, x, inner = :second)
end

@doc raw"""
Expand All @@ -814,7 +814,7 @@ function theta_qexp(e::Int, n::Int, x::ZZPolyRingElem)
z = parent(x)()
ccall((:fmpz_poly_theta_qexp, libflint), Nothing,
(Ref{ZZPolyRingElem}, Int, Int), z, e, n)
return is_gen(x) ? z : compose(z, x)
return is_gen(x) ? z : compose(z, x, inner = :second)
end

@doc raw"""
Expand All @@ -832,7 +832,7 @@ function eta_qexp(e::Int, n::Int, x::ZZPolyRingElem)
z = parent(x)()
ccall((:fmpz_poly_eta_qexp, libflint), Nothing,
(Ref{ZZPolyRingElem}, Int, Int), z, e, n)
return is_gen(x) ? z : compose(z, x)
return is_gen(x) ? z : compose(z, x, inner = :second)
end

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/polysubst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ for T in [zzModPolyRingElem, fpPolyRingElem, ZZModPolyRingElem, FpPolyRingElem,
if parent(f) != parent(a)
return subst(f, a)
end
return compose(f, a)
return compose(f, a, inner = :second)
end

(f::T)(a::Integer) = evaluate(f, a)
Expand Down
12 changes: 12 additions & 0 deletions test/flint/fmpz_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ end

@test f(ZZRingElem(10)) == 121

@test x(x) == x
end

@testset "ZZPolyRingElem.composition" begin
Expand Down Expand Up @@ -477,18 +478,29 @@ end

@test chebyshev_t(20, x) == 524288*x^20-2621440*x^18+5570560*x^16-6553600*x^14+4659200*x^12-2050048*x^10+549120*x^8-84480*x^6+6600*x^4-200*x^2+1

@test chebyshev_t(20, -x) == 524288*x^20-2621440*x^18+5570560*x^16-6553600*x^14+4659200*x^12-2050048*x^10+549120*x^8-84480*x^6+6600*x^4-200*x^2+1

@test chebyshev_u(15, x) == 32768*x^15-114688*x^13+159744*x^11-112640*x^9+42240*x^7-8064*x^5+672*x^3-16*x

@test chebyshev_u(15, -x) == -(32768*x^15-114688*x^13+159744*x^11-112640*x^9+42240*x^7-8064*x^5+672*x^3-16*x)

@test cyclotomic(120, x) == x^32+x^28-x^20-x^16-x^12+x^4+1

@test cyclotomic(120, x^2 + 1) == (x^32+x^28-x^20-x^16-x^12+x^4+1)(x^2 + 1)

@test cyclotomic(10, 1+x+x^2) == x^8+4*x^7+9*x^6+13*x^5+14*x^4+11*x^3+6*x^2+2*x+1

@test swinnerton_dyer(5, x) == x^32-448*x^30+84864*x^28-9028096*x^26+602397952*x^24-26625650688*x^22+801918722048*x^20-16665641517056*x^18+239210760462336*x^16-2349014746136576*x^14+15459151516270592*x^12-65892492886671360*x^10+172580952324702208*x^8-255690851718529024*x^6+183876928237731840*x^4-44660812492570624*x^2+2000989041197056

@test swinnerton_dyer(5, x^2) == (x^32-448*x^30+84864*x^28-9028096*x^26+602397952*x^24-26625650688*x^22+801918722048*x^20-16665641517056*x^18+239210760462336*x^16-2349014746136576*x^14+15459151516270592*x^12-65892492886671360*x^10+172580952324702208*x^8-255690851718529024*x^6+183876928237731840*x^4-44660812492570624*x^2+2000989041197056)(x^2)

@test cos_minpoly(30, x) == x^4+x^3-4*x^2-4*x+1
@test cos_minpoly(30, x + 1) == (x^4+x^3-4*x^2-4*x+1)(x + 1)

@test theta_qexp(3, 30, x) == 72*x^29+32*x^27+72*x^26+30*x^25+24*x^24+24*x^22+48*x^21+24*x^20+24*x^19+36*x^18+48*x^17+6*x^16+48*x^14+24*x^13+8*x^12+24*x^11+24*x^10+30*x^9+12*x^8+24*x^6+24*x^5+6*x^4+8*x^3+12*x^2+6*x+1

@test theta_qexp(3, 30, x^2) == (72*x^29+32*x^27+72*x^26+30*x^25+24*x^24+24*x^22+48*x^21+24*x^20+24*x^19+36*x^18+48*x^17+6*x^16+48*x^14+24*x^13+8*x^12+24*x^11+24*x^10+30*x^9+12*x^8+24*x^6+24*x^5+6*x^4+8*x^3+12*x^2+6*x+1)(x^2)

@test eta_qexp(24, 30, x) == -29211840*x^29+128406630*x^28+24647168*x^27-73279080*x^26+13865712*x^25-25499225*x^24+21288960*x^23+18643272*x^22-12830688*x^21-4219488*x^20-7109760*x^19+10661420*x^18+2727432*x^17-6905934*x^16+987136*x^15+1217160*x^14+401856*x^13-577738*x^12-370944*x^11+534612*x^10-115920*x^9-113643*x^8+84480*x^7-16744*x^6-6048*x^5+4830*x^4-1472*x^3+252*x^2-24*x+1
end

Expand Down

2 comments on commit a0aa32c

@thofma
Copy link
Member

@thofma thofma commented on a0aa32c Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Version 0.42.0 already exists

Please sign in to comment.