Skip to content

Commit

Permalink
add coeff methods for fpFieldElem and FpFieldElem (#1796)
Browse files Browse the repository at this point in the history
* add `coeff` methods for `fpFieldElem` and `FpFieldElem`
  • Loading branch information
mjrodgers authored Jun 21, 2024
1 parent befc7d7 commit 997bd2d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/flint/gfp_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions src/flint/gfp_fmpz_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions test/flint/gfp-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/flint/gfp_fmpz-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 997bd2d

Please sign in to comment.