From 59d6a4f8bdf515452665ab687a1baf95e0b435aa Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Thu, 19 Sep 2024 11:20:41 +0200 Subject: [PATCH] feat: allow more types for jacobi_symbol (#1855) --- Project.toml | 2 +- src/flint/fmpz.jl | 2 ++ test/flint/fmpz-test.jl | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index a60bc5d5ad..47d88d0b3b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Nemo" uuid = "2edaba10-b0f1-5616-af89-8c11ac63239a" -version = "0.47.0" +version = "0.47.1" [deps] AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d" diff --git a/src/flint/fmpz.jl b/src/flint/fmpz.jl index c0d5ae2126..8cd6d292a0 100644 --- a/src/flint/fmpz.jl +++ b/src/flint/fmpz.jl @@ -2044,6 +2044,8 @@ function jacobi_symbol(x::ZZRingElem, y::ZZRingElem) (Ref{ZZRingElem}, Ref{ZZRingElem}), x, y)) end +jacobi_symbol(x::IntegerUnion, y::IntegerUnion) = jacobi_symbol(ZZ(x), ZZ(y)) + @doc raw""" jacobi_symbol(x::Int, y::Int) diff --git a/test/flint/fmpz-test.jl b/test/flint/fmpz-test.jl index 6c4a88058d..12e0846bf4 100644 --- a/test/flint/fmpz-test.jl +++ b/test/flint/fmpz-test.jl @@ -1221,11 +1221,17 @@ end @test jacobi_symbol(2, 3) == -1 + for T in (Int, Integer, ZZRingElem) + for S in (Int, Integer, ZZRingElem) + @test jacobi_symbol(T(2), S(3)) == -1 + end + end + @test_throws DomainError jacobi_symbol(2, 0) @test_throws DomainError jacobi_symbol(-5, 4) - for T in [Int, ZZRingElem] + for T in (Int, ZZRingElem) for iters = 1:1000 m1 = T(rand(-100:100)) n1 = T(rand(-100:100))