diff --git a/src/flint/fmpz_poly.jl b/src/flint/fmpz_poly.jl index 9a985140d..6156832ad 100644 --- a/src/flint/fmpz_poly.jl +++ b/src/flint/fmpz_poly.jl @@ -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""" @@ -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""" @@ -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""" @@ -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""" @@ -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 ############################################################################### diff --git a/src/polysubst.jl b/src/polysubst.jl index ed0c87548..48e7079e3 100644 --- a/src/polysubst.jl +++ b/src/polysubst.jl @@ -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) diff --git a/test/flint/fmpz_poly-test.jl b/test/flint/fmpz_poly-test.jl index 97c720e61..2b749b79b 100644 --- a/test/flint/fmpz_poly-test.jl +++ b/test/flint/fmpz_poly-test.jl @@ -320,6 +320,7 @@ end @test f(ZZRingElem(10)) == 121 + @test x(x) == x end @testset "ZZPolyRingElem.composition" begin @@ -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