Skip to content

Commit

Permalink
Merge pull request #489 from tthsqe12/FFconv
Browse files Browse the repository at this point in the history
add missing FField conversions
  • Loading branch information
tthsqe12 committed Aug 11, 2021
2 parents 4db52e6 + 02e001a commit c37bf1d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/number/n_transExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,16 @@ end

promote_rule(C::Type{n_transExt}, ::Type{T}) where T <: Integer = n_transExt

promote_rule(C::Type{n_transExt}, ::Type{T}) where T <: Rational = n_transExt

promote_rule(C::Type{n_transExt}, ::Type{Nemo.fmpz}) = n_transExt

promote_rule(C::Type{n_transExt}, ::Type{Nemo.fmpq}) = n_transExt

promote_rule(C::Type{n_transExt}, ::Type{n_Z}) = n_transExt

promote_rule(C::Type{n_transExt}, ::Type{n_Q}) = n_transExt

###############################################################################
#
# Parent call functions
Expand All @@ -338,6 +344,17 @@ function (R::N_FField)(n::n_transExt)
return n
end

function (F::Singular.N_FField)(x::gfp_elem)
if characteristic(F) != characteristic(parent(x))
throw(ArgumentError("wrong characteristic"))
end
return n_transExt(F, x.data)
end

function (F::Singular.N_FField)(x::Union{n_Q, Nemo.fmpq, Rational})
return F(numerator(x)) // F(denominator(x))
end

(R::N_FField)(n::libSingular.number_ptr) = n_transExt(R, n)

###############################################################################
Expand Down
8 changes: 8 additions & 0 deletions test/number/n_transExt-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ end

@test deepcopy(F(2)) == F(2)
@test n_transExt_to_spoly(x, parent_ring = R) == p

@test F(1//2) == F(3)
@test F(1//2) == 1//2
@test F(1//2) == big(1//2)
@test F(1//2) == QQ(1//2)
@test F(1//2) == Nemo.QQ(1//2)
@test F(Nemo.GF(5)(3)) == 1//2
@test_throws Exception F(Nemo.GF(7)(3))
end

@testset "n_transExt.unary_ops" begin
Expand Down

0 comments on commit c37bf1d

Please sign in to comment.