Skip to content

Commit 3f86479

Browse files
committed
Add fourth argument to setcoeff!
1 parent 6f2d944 commit 3f86479

File tree

9 files changed

+69
-71
lines changed

9 files changed

+69
-71
lines changed

src/flint/FlintTypes.jl

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ mutable struct zzModPolyRingElem <: PolyRingElem{zzModRingElem}
559559

560560
function zzModPolyRingElem(n::UInt, a::Union{Integer,ZZRingElem,zzModRingElem})
561561
z = zzModPolyRingElem(n)
562-
setcoeff!(z, 0, a)
562+
setcoeff!(z, 0, a, n)
563563
return z
564564
end
565565

@@ -568,7 +568,7 @@ mutable struct zzModPolyRingElem <: PolyRingElem{zzModRingElem}
568568
@ccall libflint.nmod_poly_init2(z::Ref{zzModPolyRingElem}, n::UInt, length(a)::Int)::Nothing
569569
finalizer(_nmod_poly_clear_fn, z)
570570
for i in 1:length(a)
571-
setcoeff!(z, i - 1, a[i])
571+
setcoeff!(z, i - 1, a[i], n)
572572
end
573573
return z
574574
end
@@ -653,7 +653,7 @@ mutable struct fpPolyRingElem <: PolyRingElem{fpFieldElem}
653653

654654
function fpPolyRingElem(n::UInt, a::Union{Integer,ZZRingElem,fpFieldElem})
655655
z = fpPolyRingElem(n)
656-
setcoeff!(z, 0, a)
656+
setcoeff!(z, 0, a, n)
657657
return z
658658
end
659659

@@ -662,7 +662,7 @@ mutable struct fpPolyRingElem <: PolyRingElem{fpFieldElem}
662662
@ccall libflint.nmod_poly_init2(z::Ref{fpPolyRingElem}, n::UInt, length(a)::Int)::Nothing
663663
finalizer(_gfp_poly_clear_fn, z)
664664
for i in 1:length(a)
665-
setcoeff!(z, i - 1, a[i])
665+
setcoeff!(z, i - 1, a[i], n)
666666
end
667667
return z
668668
end
@@ -750,7 +750,7 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem}
750750

751751
function ZZModPolyRingElem(n::fmpz_mod_ctx_struct, a::Union{Integer,ZZRingElem,ZZModRingElem})
752752
z = ZZModPolyRingElem(n)
753-
setcoeff!(z, 0, a)
753+
setcoeff!(z, 0, a, n)
754754
return z
755755
end
756756

@@ -759,11 +759,10 @@ mutable struct ZZModPolyRingElem <: PolyRingElem{ZZModRingElem}
759759
end
760760

761761
function ZZModPolyRingElem(n::fmpz_mod_ctx_struct, a::Vector{<:Union{Integer,ZZRingElem,ZZModRingElem}})
762-
length(a) == 0 && error("Array must have length > 0")
763762
z = new()
764763
@ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModPolyRingElem}, length(a)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing
765764
for i in 1:length(a)
766-
setcoeff!(z, i-1, a[i])
765+
setcoeff!(z, i-1, a[i], n)
767766
end
768767
finalizer(_fmpz_mod_poly_clear_fn, z)
769768
return z
@@ -870,7 +869,7 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem}
870869

871870
function FpPolyRingElem(n::fmpz_mod_ctx_struct, a::Union{Integer,ZZRingElem,FpFieldElem})
872871
z = FpPolyRingElem(n)
873-
setcoeff!(z, 0, a)
872+
setcoeff!(z, 0, a, n)
874873
return z
875874
end
876875

@@ -883,11 +882,10 @@ mutable struct FpPolyRingElem <: PolyRingElem{FpFieldElem}
883882
end
884883

885884
function FpPolyRingElem(n::fmpz_mod_ctx_struct, a::Vector{<:Union{Integer,ZZRingElem,FpFieldElem}})
886-
length(a) == 0 && error("Array must have length > 0")
887885
z = new()
888886
@ccall libflint.fmpz_mod_poly_init2(z::Ref{FpPolyRingElem}, length(a)::Int, n::Ref{fmpz_mod_ctx_struct})::Nothing
889887
for i in 1:length(a)
890-
setcoeff!(z, i - 1, a[i])
888+
setcoeff!(z, i - 1, a[i], n)
891889
end
892890
finalizer(_fmpz_mod_poly_clear_fn, z)
893891
return z
@@ -2869,7 +2867,7 @@ mutable struct fpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{fpFieldElem}
28692867
z = new()
28702868
@ccall libflint.nmod_poly_init2(z::Ref{fpRelPowerSeriesRingElem}, p::UInt, len::Int)::Nothing
28712869
for i in 1:len
2872-
setcoeff!(z, i-1, a[i])
2870+
setcoeff!(z, i-1, a[i], p)
28732871
end
28742872
z.prec = prec
28752873
z.val = val
@@ -2936,7 +2934,7 @@ mutable struct zzModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{zzModRingEl
29362934
z = new()
29372935
@ccall libflint.nmod_poly_init2(z::Ref{zzModRelPowerSeriesRingElem}, p::UInt, len::Int)::Nothing
29382936
for i in 1:len
2939-
setcoeff!(z, i-1, a[i])
2937+
setcoeff!(z, i-1, a[i], p)
29402938
end
29412939
z.prec = prec
29422940
z.val = val
@@ -3007,7 +3005,7 @@ mutable struct FpRelPowerSeriesRingElem <: RelPowerSeriesRingElem{FpFieldElem}
30073005
z = new()
30083006
@ccall libflint.fmpz_mod_poly_init2(z::Ref{FpRelPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing
30093007
for i in 1:len
3010-
setcoeff!(z, i-1, a[i])
3008+
setcoeff!(z, i-1, a[i], p)
30113009
end
30123010
z.prec = prec
30133011
z.val = val
@@ -3085,7 +3083,7 @@ mutable struct ZZModRelPowerSeriesRingElem <: RelPowerSeriesRingElem{ZZModRingEl
30853083
z = new()
30863084
@ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModRelPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing
30873085
for i in 1:len
3088-
setcoeff!(z, i-1, a[i])
3086+
setcoeff!(z, i-1, a[i], p)
30893087
end
30903088
z.prec = prec
30913089
z.val = val
@@ -3162,7 +3160,7 @@ mutable struct FpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{FpFieldElem}
31623160
z = new()
31633161
@ccall libflint.fmpz_mod_poly_init2(z::Ref{FpAbsPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing
31643162
for i in 1:len
3165-
setcoeff!(z, i-1, a[i])
3163+
setcoeff!(z, i-1, a[i], p)
31663164
end
31673165
z.prec = prec
31683166
finalizer(_gfp_fmpz_abs_series_clear_fn, z)
@@ -3235,7 +3233,7 @@ mutable struct zzModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{zzModRingEl
32353233
z = new()
32363234
@ccall libflint.nmod_poly_init2(z::Ref{zzModAbsPowerSeriesRingElem}, n::UInt, length(a)::Int)::Nothing
32373235
for i in 1:len
3238-
setcoeff!(z, i-1, a[i])
3236+
setcoeff!(z, i-1, a[i], n)
32393237
end
32403238
z.prec = prec
32413239
finalizer(_nmod_abs_series_clear_fn, z)
@@ -3304,7 +3302,7 @@ mutable struct fpAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{fpFieldElem}
33043302
z = new()
33053303
@ccall libflint.nmod_poly_init2(z::Ref{fpAbsPowerSeriesRingElem}, n::UInt, length(a)::Int)::Nothing
33063304
for i in 1:len
3307-
setcoeff!(z, i-1, a[i])
3305+
setcoeff!(z, i-1, a[i], n)
33083306
end
33093307
z.prec = prec
33103308
finalizer(_gfp_abs_series_clear_fn, z)
@@ -3373,7 +3371,7 @@ mutable struct ZZModAbsPowerSeriesRingElem <: AbsPowerSeriesRingElem{ZZModRingEl
33733371
z = new()
33743372
@ccall libflint.fmpz_mod_poly_init2(z::Ref{ZZModAbsPowerSeriesRingElem}, len::Int, p::Ref{fmpz_mod_ctx_struct})::Nothing
33753373
for i in 1:len
3376-
setcoeff!(z, i-1, a[i])
3374+
setcoeff!(z, i-1, a[i], p)
33773375
end
33783376
z.prec = prec
33793377
finalizer(_fmpz_mod_abs_series_clear_fn, z)

src/flint/fmpz_mod_abs_series.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,23 +496,23 @@ for (etype, rtype, ctype, mtype, brtype) in (
496496
return nothing
497497
end
498498

499-
function setcoeff!(z::($etype), n::Int, x::ZZRingElemOrPtr)
500-
@ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{($etype)}, n::Int, x::Ref{ZZRingElem}, base_ring(z).ninv::Ref{($ctype)})::Nothing
499+
function setcoeff!(z::($etype), i::Int, x::ZZRingElemOrPtr, ctx::($ctype)=base_ring(z).ninv)
500+
@ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{($etype)}, i::Int, x::Ref{ZZRingElem}, ctx::Ref{($ctype)})::Nothing
501501
return z
502502
end
503503

504-
function setcoeff!(z::($etype), n::Int, x::UInt)
505-
@ccall libflint.fmpz_mod_poly_set_coeff_ui(z::Ref{($etype)}, n::Int, x::UInt, base_ring(z).ninv::Ref{($ctype)})::Nothing
504+
function setcoeff!(z::($etype), i::Int, x::UInt, ctx::($ctype)=base_ring(z).ninv)
505+
@ccall libflint.fmpz_mod_poly_set_coeff_ui(z::Ref{($etype)}, i::Int, x::UInt, ctx::Ref{($ctype)})::Nothing
506506
return z
507507
end
508508

509-
function setcoeff!(z::($etype), n::Int, x::Int)
510-
@ccall libflint.fmpz_mod_poly_set_coeff_si(z::Ref{($etype)}, n::Int, x::UInt, base_ring(z).ninv::Ref{($ctype)})::Nothing
509+
function setcoeff!(z::($etype), i::Int, x::Int, ctx::($ctype)=base_ring(z).ninv)
510+
@ccall libflint.fmpz_mod_poly_set_coeff_si(z::Ref{($etype)}, i::Int, x::UInt, ctx::Ref{($ctype)})::Nothing
511511
end
512512

513-
setcoeff!(z::($etype), n::Int, x::Integer) = setcoeff!(z, n, flintify(x))
513+
setcoeff!(z::($etype), i::Int, x::Integer, ctx::($ctype)=base_ring(z).ninv) = setcoeff!(z, i, flintify(x), ctx)
514514

515-
setcoeff!(z::($etype), n::Int, x::($mtype)) = setcoeff!(z, n, data(x))
515+
setcoeff!(z::($etype), i::Int, x::($mtype), ctx::($ctype)=base_ring(z).ninv) = setcoeff!(z, i, data(x), ctx)
516516

517517
function mul!(z::($etype), a::($etype), b::($etype))
518518
lena = length(a)

src/flint/fmpz_mod_poly.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -779,23 +779,23 @@ end
779779

780780
#
781781

782-
function setcoeff!(z::T, n::Int, x::ZZRingElemOrPtr) where T <: Zmodn_fmpz_poly
783-
@ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{T}, n::Int, x::Ref{ZZRingElem}, base_ring(z).ninv::Ref{fmpz_mod_ctx_struct})::Nothing
782+
function setcoeff!(z::T, i::Int, x::ZZRingElemOrPtr, ctx::fmpz_mod_ctx_struct=base_ring(z).ninv) where T <: Zmodn_fmpz_poly
783+
@ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{T}, i::Int, x::Ref{ZZRingElem}, ctx::Ref{fmpz_mod_ctx_struct})::Nothing
784784
return z
785785
end
786786

787-
function setcoeff!(z::T, n::Int, x::UInt) where T <: Zmodn_fmpz_poly
788-
@ccall libflint.fmpz_mod_poly_set_coeff_ui(z::Ref{T}, n::Int, x::UInt, base_ring(z).ninv::Ref{fmpz_mod_ctx_struct})::Nothing
787+
function setcoeff!(z::T, i::Int, x::UInt, ctx::fmpz_mod_ctx_struct=base_ring(z).ninv) where T <: Zmodn_fmpz_poly
788+
@ccall libflint.fmpz_mod_poly_set_coeff_ui(z::Ref{T}, i::Int, x::UInt, ctx::Ref{fmpz_mod_ctx_struct})::Nothing
789789
return z
790790
end
791791

792-
function setcoeff!(z::T, n::Int, x::Int) where T <: Zmodn_fmpz_poly
793-
@ccall libflint.fmpz_mod_poly_set_coeff_si(z::Ref{T}, n::Int, x::UInt, base_ring(z).ninv::Ref{fmpz_mod_ctx_struct})::Nothing
792+
function setcoeff!(z::T, i::Int, x::Int, ctx::fmpz_mod_ctx_struct=base_ring(z).ninv) where T <: Zmodn_fmpz_poly
793+
@ccall libflint.fmpz_mod_poly_set_coeff_si(z::Ref{T}, i::Int, x::UInt, ctx::Ref{fmpz_mod_ctx_struct})::Nothing
794794
end
795795

796-
setcoeff!(z::T, n::Int, x::Integer) where T <: Zmodn_fmpz_poly = setcoeff!(z, n, flintify(x))
796+
setcoeff!(z::T, i::Int, x::Integer, ctx::fmpz_mod_ctx_struct=base_ring(z).ninv) where T <: Zmodn_fmpz_poly = setcoeff!(z, i, flintify(x), ctx)
797797

798-
setcoeff!(z::ZZModPolyRingElem, n::Int, x::ZZModRingElem) = setcoeff!(z, n, data(x))
798+
setcoeff!(z::ZZModPolyRingElem, i::Int, x::ZZModRingElem, ctx::fmpz_mod_ctx_struct=base_ring(z).ninv) = setcoeff!(z, i, data(x), ctx)
799799

800800
#
801801

src/flint/fmpz_mod_rel_series.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -599,23 +599,23 @@ for (etype, rtype, ctype, mtype, brtype) in (
599599
return nothing
600600
end
601601

602-
function setcoeff!(z::($etype), n::Int, x::ZZRingElemOrPtr)
603-
@ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{($etype)}, n::Int, x::Ref{ZZRingElem}, base_ring(z).ninv::Ref{($ctype)})::Nothing
602+
function setcoeff!(z::($etype), i::Int, x::ZZRingElemOrPtr, ctx::($ctype)=base_ring(z).ninv)
603+
@ccall libflint.fmpz_mod_poly_set_coeff_fmpz(z::Ref{($etype)}, i::Int, x::Ref{ZZRingElem}, ctx::Ref{($ctype)})::Nothing
604604
return z
605605
end
606606

607-
function setcoeff!(z::($etype), n::Int, x::UInt)
608-
@ccall libflint.fmpz_mod_poly_set_coeff_ui(z::Ref{($etype)}, n::Int, x::UInt, base_ring(z).ninv::Ref{($ctype)})::Nothing
607+
function setcoeff!(z::($etype), i::Int, x::UInt, ctx::($ctype)=base_ring(z).ninv)
608+
@ccall libflint.fmpz_mod_poly_set_coeff_ui(z::Ref{($etype)}, i::Int, x::UInt, ctx::Ref{($ctype)})::Nothing
609609
return z
610610
end
611611

612-
function setcoeff!(z::($etype), n::Int, x::Int)
613-
@ccall libflint.fmpz_mod_poly_set_coeff_si(z::Ref{($etype)}, n::Int, x::UInt, base_ring(z).ninv::Ref{($ctype)})::Nothing
612+
function setcoeff!(z::($etype), i::Int, x::Int, ctx::($ctype)=base_ring(z).ninv)
613+
@ccall libflint.fmpz_mod_poly_set_coeff_si(z::Ref{($etype)}, i::Int, x::UInt, ctx::Ref{($ctype)})::Nothing
614614
end
615615

616-
setcoeff!(z::($etype), n::Int, x::Integer) = setcoeff!(z, n, flintify(x))
616+
setcoeff!(z::($etype), i::Int, x::Integer, ctx::($ctype)=base_ring(z).ninv) = setcoeff!(z, i, flintify(x), ctx)
617617

618-
setcoeff!(z::($etype), n::Int, x::($mtype)) = setcoeff!(z, n, data(x))
618+
setcoeff!(z::($etype), i::Int, x::($mtype), ctx::($ctype)=base_ring(z).ninv) = setcoeff!(z, i, data(x), ctx)
619619

620620
function mul!(z::($etype), a::($etype), b::($etype))
621621
lena = pol_length(a)

src/flint/gfp_fmpz_poly.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ end
384384
#
385385
################################################################################
386386

387-
setcoeff!(z::FpPolyRingElem, n::Int, x::FpFieldElem) = setcoeff!(z, n, data(x))
387+
setcoeff!(z::FpPolyRingElem, i::Int, x::FpFieldElem, ctx::fmpz_mod_ctx_struct=base_ring(z).ninv) = setcoeff!(z, i, data(x), ctx)
388388

389389
################################################################################
390390
#

src/flint/gfp_poly.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ end
465465
#
466466
################################################################################
467467

468-
setcoeff!(z::fpPolyRingElem, n::Int, x::fpFieldElem) = setcoeff!(z, n, data(x))
468+
setcoeff!(z::fpPolyRingElem, i::Int, x::fpFieldElem, n::UInt=modulus(z)) = setcoeff!(z, i, data(x), n)
469469

470470
################################################################################
471471
#

src/flint/nmod_abs_series.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -484,23 +484,23 @@ for (etype, rtype, mtype, brtype) in (
484484
return nothing
485485
end
486486

487-
function setcoeff!(z::($etype), n::Int, x::UInt)
488-
@ccall libflint.nmod_poly_set_coeff_ui(z::Ref{($etype)}, n::Int, x::UInt)::Nothing
487+
function setcoeff!(z::($etype), i::Int, x::UInt, n::UInt=modulus(z))
488+
@ccall libflint.nmod_poly_set_coeff_ui(z::Ref{($etype)}, i::Int, x::UInt)::Nothing
489489
return z
490490
end
491491

492-
function setcoeff!(z::($etype), n::Int, x::Int)
493-
return setcoeff!(z, n, mod(x, modulus(z)))
492+
function setcoeff!(z::($etype), i::Int, x::Int, n::UInt=modulus(z))
493+
return setcoeff!(z, i, mod(x, n), n)
494494
end
495495

496-
function setcoeff!(z::($etype), n::Int, x::ZZRingElem)
497-
xx = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), x, modulus(z))
498-
return setcoeff!(z, n, xx)
496+
function setcoeff!(z::($etype), i::Int, x::ZZRingElem, n::UInt=modulus(z))
497+
xx = @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, n::UInt)::UInt
498+
return setcoeff!(z, i, xx, n)
499499
end
500500

501-
setcoeff!(z::($etype), n::Int, x::Integer) = setcoeff!(z, n, flintify(x))
501+
setcoeff!(z::($etype), i::Int, x::Integer, n::UInt=modulus(z)) = setcoeff!(z, i, flintify(x), n)
502502

503-
setcoeff!(z::($etype), n::Int, x::($mtype)) = setcoeff!(z, n, data(x))
503+
setcoeff!(z::($etype), i::Int, x::($mtype), n::UInt=modulus(z)) = setcoeff!(z, i, data(x), n)
504504

505505
function mul!(z::($etype), a::($etype), b::($etype))
506506
lena = length(a)

src/flint/nmod_poly.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -846,23 +846,23 @@ end
846846

847847
#
848848

849-
function setcoeff!(z::T, n::Int, x::UInt) where T <: Zmodn_poly
850-
@ccall libflint.nmod_poly_set_coeff_ui(z::Ref{T}, n::Int, x::UInt)::Nothing
849+
function setcoeff!(z::T, i::Int, x::UInt, n::UInt=modulus(z)) where T <: Zmodn_poly
850+
@ccall libflint.nmod_poly_set_coeff_ui(z::Ref{T}, i::Int, x::UInt)::Nothing
851851
return z
852852
end
853853

854-
function setcoeff!(z::T, n::Int, x::Int) where T <: Zmodn_poly
855-
return setcoeff!(z, n, mod(x, modulus(z)))
854+
function setcoeff!(z::T, i::Int, x::Int, n::UInt=modulus(z)) where T <: Zmodn_poly
855+
return setcoeff!(z, i, mod(x, n), n)
856856
end
857857

858-
function setcoeff!(z::T, n::Int, x::ZZRingElem) where T <: Zmodn_poly
859-
xx = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), x, modulus(z))
860-
return setcoeff!(z, n, xx)
858+
function setcoeff!(z::T, i::Int, x::ZZRingElem, n::UInt=modulus(z)) where T <: Zmodn_poly
859+
xx = ccall((:fmpz_fdiv_ui, libflint), UInt, (Ref{ZZRingElem}, UInt), x, n)
860+
return setcoeff!(z, i, xx, n)
861861
end
862862

863-
setcoeff!(z::T, n::Int, x::Integer) where T <: Zmodn_poly = setcoeff!(z, n, flintify(x))
863+
setcoeff!(z::T, i::Int, x::Integer, n::UInt=modulus(z)) where T <: Zmodn_poly = setcoeff!(z, i, flintify(x), n)
864864

865-
setcoeff!(z::zzModPolyRingElem, n::Int, x::zzModRingElem) = setcoeff!(z, n, data(x))
865+
setcoeff!(z::zzModPolyRingElem, i::Int, x::zzModRingElem, n::UInt=modulus(z)) = setcoeff!(z, i, data(x), n)
866866

867867
#
868868

src/flint/nmod_rel_series.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -641,23 +641,23 @@ for (etype, rtype, mtype, brtype) in (
641641
return nothing
642642
end
643643

644-
function setcoeff!(z::($etype), n::Int, x::UInt)
645-
@ccall libflint.nmod_poly_set_coeff_ui(z::Ref{($etype)}, n::Int, x::UInt)::Nothing
644+
function setcoeff!(z::($etype), i::Int, x::UInt, n::UInt=modulus(z))
645+
@ccall libflint.nmod_poly_set_coeff_ui(z::Ref{($etype)}, i::Int, x::UInt)::Nothing
646646
return z
647647
end
648648

649-
function setcoeff!(z::($etype), n::Int, x::Int)
650-
return setcoeff!(z, n, mod(x, modulus(z)))
649+
function setcoeff!(z::($etype), i::Int, x::Int, n::UInt=modulus(z))
650+
return setcoeff!(z, i, mod(x, n), n)
651651
end
652652

653-
function setcoeff!(z::($etype), n::Int, x::ZZRingElem)
654-
xx = @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, modulus(z)::UInt)::UInt
655-
return setcoeff!(z, n, xx)
653+
function setcoeff!(z::($etype), i::Int, x::ZZRingElem, n::UInt=modulus(z))
654+
xx = @ccall libflint.fmpz_fdiv_ui(x::Ref{ZZRingElem}, n::UInt)::UInt
655+
return setcoeff!(z, i, xx, n)
656656
end
657657

658-
setcoeff!(z::($etype), n::Int, x::Integer) = setcoeff!(z, n, flintify(x))
658+
setcoeff!(z::($etype), i::Int, x::Integer, n::UInt=modulus(z)) = setcoeff!(z, i, flintify(x), n)
659659

660-
setcoeff!(z::($etype), n::Int, x::($mtype)) = setcoeff!(z, n, data(x))
660+
setcoeff!(z::($etype), i::Int, x::($mtype), n::UInt=modulus(z)) = setcoeff!(z, i, data(x), n)
661661

662662
function mul!(z::($etype), a::($etype), b::($etype))
663663
lena = pol_length(a)

0 commit comments

Comments
 (0)