Skip to content

Commit

Permalink
Add set! for FqField
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 18, 2024
1 parent 633112d commit 6872cf9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 52 deletions.
63 changes: 11 additions & 52 deletions src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2294,59 +2294,18 @@ mutable struct FqFieldElem <: FinFieldElem
return d
end

function FqFieldElem(ctx::FqField, x::Int)
function FqFieldElem(
ctx::FqField,
x::Union{
FqFieldElem,
Integer, ZZRingElem,
ZZPolyRingElem,
zzModPolyRingElem, fpPolyRingElem,
ZZModPolyRingElem, FpPolyRingElem,
},
)
d = FqFieldElem(ctx)
ccall((:fq_default_set_si, libflint), Nothing,
(Ref{FqFieldElem}, Int, Ref{FqField}), d, x, ctx)
return d
end

function FqFieldElem(ctx::FqField, x::ZZRingElem)
d = FqFieldElem(ctx)
ccall((:fq_default_set_fmpz, libflint), Nothing,
(Ref{FqFieldElem}, Ref{ZZRingElem}, Ref{FqField}), d, x, ctx)
return d
end

function FqFieldElem(ctx::FqField, x::ZZPolyRingElem)
d = FqFieldElem(ctx)
ccall((:fq_default_set_fmpz_poly, libflint), Nothing,
(Ref{FqFieldElem}, Ref{ZZPolyRingElem}, Ref{FqField}), d, x, ctx)
return d
end

function FqFieldElem(ctx::FqField, x::zzModPolyRingElem)
d = FqFieldElem(ctx)
ccall((:fq_default_set_nmod_poly, libflint), Nothing,
(Ref{FqFieldElem}, Ref{zzModPolyRingElem}, Ref{FqField}), d, x, ctx)
return d
end

function FqFieldElem(ctx::FqField, x::fpPolyRingElem)
d = FqFieldElem(ctx)
ccall((:fq_default_set_nmod_poly, libflint), Nothing,
(Ref{FqFieldElem}, Ref{fpPolyRingElem}, Ref{FqField}), d, x, ctx)
return d
end

function FqFieldElem(ctx::FqField, x::ZZModPolyRingElem)
d = FqFieldElem(ctx)
ccall((:fq_default_set_fmpz_mod_poly, libflint), Nothing,
(Ref{FqFieldElem}, Ref{ZZModPolyRingElem}, Ref{FqField}), d, x, ctx)
return d
end

function FqFieldElem(ctx::FqField, x::FpPolyRingElem)
d = FqFieldElem(ctx)
ccall((:fq_default_set_fmpz_mod_poly, libflint), Nothing,
(Ref{FqFieldElem}, Ref{FpPolyRingElem}, Ref{FqField}), d, x, ctx)
return d
end

function FqFieldElem(ctx::FqField, x::FqFieldElem)
d = FqFieldElem(ctx)
ccall((:fq_default_set, libflint), Nothing,
(Ref{FqFieldElem}, Ref{FqFieldElem}, Ref{FqField}), d, x, ctx)
set!(d, x)
return d
end
end
Expand Down
49 changes: 49 additions & 0 deletions src/flint/fq_default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,55 @@ end

#

function set!(z::FqFieldElem, a::FqFieldElemOrPtr)
@ccall libflint.fq_default_set(z::Ref{FqFieldElem}, a::Ref{FqFieldElem}, parent(z)::Ref{FqField})::Nothing
z.poly = nothing
end

function set!(z::FqFieldElem, a::Int)
@ccall libflint.fq_default_set_si(z::Ref{FqFieldElem}, a::Int, parent(z)::Ref{FqField})::Nothing
z.poly = nothing
end

function set!(z::FqFieldElem, a::UInt)
@ccall libflint.fq_default_set_ui(z::Ref{FqFieldElem}, a::UInt, parent(z)::Ref{FqField})::Nothing
z.poly = nothing

Check warning on line 663 in src/flint/fq_default.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fq_default.jl#L661-L663

Added lines #L661 - L663 were not covered by tests
end

function set!(z::FqFieldElem, a::ZZRingElemOrPtr)
@ccall libflint.fq_default_set_fmpz(z::Ref{FqFieldElem}, a::Ref{ZZRingElem}, parent(z)::Ref{FqField})::Nothing
z.poly = nothing
end

set!(z::FqFieldElem, a::Integer) = set!(z, flintify(a))

Check warning on line 671 in src/flint/fq_default.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fq_default.jl#L671

Added line #L671 was not covered by tests

function set!(z::FqFieldElem, a::ZZPolyRingElemOrPtr)
@ccall libflint.fq_default_set_fmpz_poly(z::Ref{FqFieldElem}, a::Ref{ZZPolyRingElem}, parent(z)::Ref{FqField})::Nothing
z.poly = nothing
end

function set!(z::FqFieldElem, a::zzModPolyRingElemOrPtr)
@ccall libflint.fq_default_set_nmod_poly(z::Ref{FqFieldElem}, a::Ref{zzModPolyRingElem}, parent(z)::Ref{FqField})::Nothing
z.poly = nothing
end

function set!(z::FqFieldElem, a::fpPolyRingElemOrPtr)
@ccall libflint.fq_default_set_nmod_poly(z::Ref{FqFieldElem}, a::Ref{fpPolyRingElem}, parent(z)::Ref{FqField})::Nothing
z.poly = nothing
end

function set!(z::FqFieldElem, a::ZZModPolyRingElemOrPtr)
@ccall libflint.fq_default_set_fmpz_mod_poly(z::Ref{FqFieldElem}, a::Ref{ZZModPolyRingElem}, parent(z)::Ref{FqField})::Nothing
z.poly = nothing
end

function set!(z::FqFieldElem, a::FpPolyRingElemOrPtr)
@ccall libflint.fq_default_set_fmpz_mod_poly(z::Ref{FqFieldElem}, a::Ref{FpPolyRingElem}, parent(z)::Ref{FqField})::Nothing
z.poly = nothing
end

#

function add!(z::FqFieldElem, x::FqFieldElem, y::FqFieldElem)
@ccall libflint.fq_default_add(z::Ref{FqFieldElem}, x::Ref{FqFieldElem}, y::Ref{FqFieldElem}, x.parent::Ref{FqField})::Nothing
z.poly = nothing
Expand Down

0 comments on commit 6872cf9

Please sign in to comment.