diff --git a/Project.toml b/Project.toml index 01a8ef8eaa..d0fe70c0fb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "AbstractAlgebra" uuid = "c3fe647b-3220-5bb0-a1ea-a7954cac585d" -version = "0.40.6" +version = "0.40.7" [deps] InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" diff --git a/src/julia/GF.jl b/src/julia/GF.jl index 8702f0127f..6ff71a1ded 100644 --- a/src/julia/GF.jl +++ b/src/julia/GF.jl @@ -465,7 +465,7 @@ By default, the integer $p$ is checked with a probabilistic algorithm for primal When `check == false`, no check is made, but the behaviour of the resulting object is undefined if $p$ is composite. """ -function GF(p::T; check::Bool=true) where T <: Integer +function GF(p::T; cached::Bool = true, check::Bool=true) where T <: Integer check && !is_probable_prime(p) && throw(DomainError(p, "Characteristic is not prime in GF(p)")) - return GFField{T}(p) + return GFField{T}(p; cached = cached) end diff --git a/src/julia/JuliaTypes.jl b/src/julia/JuliaTypes.jl index 29070588d6..2eaf5dfce7 100644 --- a/src/julia/JuliaTypes.jl +++ b/src/julia/JuliaTypes.jl @@ -34,12 +34,14 @@ end mutable struct GFField{T <: Integer} <: FinField p::T - function GFField{T}(p::T) where T <: Integer - if haskey(GFFieldID, (T, p)) + function GFField{T}(p::T; cached::Bool = true) where T <: Integer + if cached && haskey(GFFieldID, (T, p)) z = GFFieldID[T, p]::GFField{T} else z = new{T}(p) - GFFieldID[T, p] = z + if cached + GFFieldID[T, p] = z + end end return z end diff --git a/test/julia/GFElem-test.jl b/test/julia/GFElem-test.jl index a6f2d2390a..93c65626d3 100644 --- a/test/julia/GFElem-test.jl +++ b/test/julia/GFElem-test.jl @@ -10,6 +10,8 @@ end end @testset "Julia.GFElem.constructors" begin + @test GF(2, cached = false) !== GF(2, cached = false) + @test GF(2) === GF(2) @test_throws DomainError GF(4) @test_throws DomainError GF(4, check=true) F = GF(4, check=false)