Skip to content

Commit

Permalink
Merge pull request #463 from tthsqe12/nfbug
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
tthsqe12 authored Jul 14, 2021
2 parents 0b497f0 + cfc0ec6 commit c600382
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/number/n_algExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ promote_rule(C::Type{n_algExt}, ::Type{Nemo.fmpz}) = n_algExt

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

# TODO really need a hand-crafted nf_elem <-> n_algExt
function (SK::Singular.N_AlgExtField)(a::Singular.Nemo.nf_elem)
K = parent(a)
SKa = gen(SK)
Expand All @@ -305,11 +306,15 @@ end
function (K::Singular.Nemo.AnticNumberField)(a::Singular.n_algExt)
SK = parent(a)
SF = parent(modulus(SK))
Sa = n_transExt_to_spoly(SF(a))
# it gets even worse: n_transExt_to_spoly only converts the "numerator"
# which doesn't include the "denominator" we need
SFa = SF(a)
numSa = n_transExt_to_spoly(numerator(SFa))
denSa = first(coefficients(n_transExt_to_spoly(denominator(SFa))))
res = zero(K)
Ka = gen(K)
for (c, e) in zip(coefficients(Sa), exponent_vectors(Sa))
res += Singular.Nemo.fmpq(c)*Ka^e[1]
for (c, e) in zip(coefficients(numSa), exponent_vectors(numSa))
res += Singular.Nemo.fmpq(c//denSa)*Ka^e[1]
end
return res
end
Expand Down
2 changes: 2 additions & 0 deletions test/number/n_algExt-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ end
@assert 0*b+1 == K2(K1(0*b+1))
@assert a^2 == K1(K2(a^2))
@assert b^2 == K2(K1(b^2))
@assert a^3//3 == K1(K2(a^3//3))
@assert b^3//3 == K2(K1(b^3//3))
end

@testset "n_algExt.unary_ops" begin
Expand Down

0 comments on commit c600382

Please sign in to comment.