From cfc0ec6c8a554bc4367b0ebdf4334f61d86c069e Mon Sep 17 00:00:00 2001 From: Daniel Schultz Date: Wed, 14 Jul 2021 21:23:49 +0200 Subject: [PATCH] bug fix --- src/number/n_algExt.jl | 11 ++++++++--- test/number/n_algExt-test.jl | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/number/n_algExt.jl b/src/number/n_algExt.jl index de4574aa2..d9ce8ebbd 100644 --- a/src/number/n_algExt.jl +++ b/src/number/n_algExt.jl @@ -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) @@ -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 diff --git a/test/number/n_algExt-test.jl b/test/number/n_algExt-test.jl index da07af2b8..5f793fb79 100644 --- a/test/number/n_algExt-test.jl +++ b/test/number/n_algExt-test.jl @@ -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