Skip to content

Commit

Permalink
Fix some finite field promotion (#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma authored Nov 4, 2023
1 parent 1acb178 commit 04d5a3a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Nemo"
uuid = "2edaba10-b0f1-5616-af89-8c11ac63239a"
version = "0.37.3"
version = "0.37.4"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
12 changes: 9 additions & 3 deletions src/flint/fq_default_extended.jl
Original file line number Diff line number Diff line change
Expand Up @@ -837,15 +837,21 @@ end

function _try_promote(K::FqField, a::FqFieldElem)
L = parent(a)
if degree(K) == 1 && K !== L
return false, a
end

if K === L
return true, a
end

if absolute_degree(L) == 1 && L === base_field(K)
return true, K(lift(ZZ, a))
end

if degree(K) == 1 && K !== L
return false, a
end

fl, b = _try_promote(base_field(K), a)

if fl
return fl, K(a)::FqFieldElem
else
Expand Down
8 changes: 8 additions & 0 deletions test/flint/fq_default_extended-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,12 @@ end
end
@test divexact(a, one(FF)) == divexact(FF(a), one(FF))
end

F = Nemo._GF(3)
Fx, x = F["x"]
FF, = Nemo._residue_field(x - 2)
a = one(F) * one(FF)
@test parent(a) === FF && is_one(a)
a = one(FF) * one(F)
@test parent(a) === FF && is_one(a)
end

2 comments on commit 04d5a3a

@thofma
Copy link
Member Author

@thofma thofma commented on 04d5a3a Nov 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/94738

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.37.4 -m "<description of version>" 04d5a3ad56e68e96c5830e6dc9afef1f043bd03f
git push origin v0.37.4

Please sign in to comment.