From d411bf952eca1b7a825c833706e55526b94ca1f7 Mon Sep 17 00:00:00 2001 From: Thomas Breuer Date: Wed, 13 Sep 2023 16:11:31 +0200 Subject: [PATCH] moved two functions from Oscar to Nemo (#1519) This is not yet satisfactory: - Should `embed` return something? The `embed(k::T, K::T) where T <: FinField` method returns a mapping, but the documentation does not state what is returned, and the code that calls `embed` seems to ignore the return value. - Tests and documentation are missing. --- src/embedding/embedding.jl | 4 ++++ src/flint/fmpq.jl | 2 ++ test/flint/fmpq-test.jl | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/embedding/embedding.jl b/src/embedding/embedding.jl index 10425436a..8e5082092 100644 --- a/src/embedding/embedding.jl +++ b/src/embedding/embedding.jl @@ -428,6 +428,10 @@ function embed(k::T, K::T) where T <: FinField end end +function embed(k::Nemo.fpField, K::fqPolyRepField) + @assert characteristic(K) == characteristic(k) +end + ################################################################################ # # Preimage map diff --git a/src/flint/fmpq.jl b/src/flint/fmpq.jl index b8fcba8b3..140d780d1 100644 --- a/src/flint/fmpq.jl +++ b/src/flint/fmpq.jl @@ -178,6 +178,8 @@ returned as a rational with denominator $1$. """ Base.ceil(a::QQFieldElem) = QQFieldElem(cdiv(numerator(a), denominator(a)), 1) +nbits(a::QQFieldElem) = nbits(numerator(a)) + nbits(denominator(a)) + ############################################################################### # # Canonicalisation diff --git a/test/flint/fmpq-test.jl b/test/flint/fmpq-test.jl index 82a2cb41c..373569a26 100644 --- a/test/flint/fmpq-test.jl +++ b/test/flint/fmpq-test.jl @@ -173,6 +173,9 @@ end @test ceil(QQFieldElem(2, 3)) == 1 @test ceil(QQFieldElem(-1, 3)) == 0 @test ceil(QQFieldElem(2, 1)) == 2 + + @test nbits(QQFieldElem(12, 1)) == 5 + @test nbits(QQFieldElem(1, 3)) == 3 end @testset "QQFieldElem.unary_ops" begin