diff --git a/src/flint/gfp_elem.jl b/src/flint/gfp_elem.jl index b6f1ad138..e0692effe 100644 --- a/src/flint/gfp_elem.jl +++ b/src/flint/gfp_elem.jl @@ -35,6 +35,13 @@ end data(a::fpFieldElem) = a.data +function coeff(x::fpFieldElem, n::Int) + n < 0 && throw(DomainError(n, "Index must be non-negative")) + n == 0 && return data(x) + return UInt(0) +end + + lift(a::fpFieldElem) = ZZRingElem(data(a)) lift(::ZZRing, x::fpFieldElem) = lift(x) diff --git a/src/flint/gfp_fmpz_elem.jl b/src/flint/gfp_fmpz_elem.jl index fe468636f..a24adee62 100644 --- a/src/flint/gfp_fmpz_elem.jl +++ b/src/flint/gfp_fmpz_elem.jl @@ -35,6 +35,12 @@ end data(a::FpFieldElem) = a.data +function coeff(x::FpFieldElem, n::Int) + n < 0 && throw(DomainError(n, "Index must be non-negative")) + n == 0 && return data(x) + return zero(ZZ) +end + lift(a::FpFieldElem) = data(a) lift(::ZZRing, x::FpFieldElem) = lift(x) diff --git a/test/flint/gfp-test.jl b/test/flint/gfp-test.jl index bf96f0647..fe39d2f00 100644 --- a/test/flint/gfp-test.jl +++ b/test/flint/gfp-test.jl @@ -112,6 +112,9 @@ end @test deepcopy(R(3)) == R(3) + @test coeff(R(2), 0) == 2 + @test coeff(R(2), 1) == 0 + R1 = Native.GF(13) @test R === R1 diff --git a/test/flint/gfp_fmpz-test.jl b/test/flint/gfp_fmpz-test.jl index f4cc2d574..b4e176d90 100644 --- a/test/flint/gfp_fmpz-test.jl +++ b/test/flint/gfp_fmpz-test.jl @@ -95,6 +95,9 @@ end @test deepcopy(R(3)) == R(3) + @test coeff(R(2), 0) == 2 + @test coeff(R(2), 1) == 0 + R1 = Native.GF(ZZ(13)) @test R === R1