Skip to content

Commit c50b1e6

Browse files
committed
minor cleanup
1 parent eb28764 commit c50b1e6

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

src/primality_check.jl

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,34 +61,24 @@ function check_primality(
6161
ring = parent(leaders[1])
6262

6363
Rspec, vspec = Nemo.polynomial_ring(Nemo.QQ, [var_to_str(l) for l in leaders])
64-
# Generic degree of each generator in its leader. Specializing the other
65-
# variables must preserve these degrees; the ideal is considered on the
66-
# open set where the leading coefficients (w.r.t. the leaders) do not
67-
# vanish, so a specialization that drops a degree corresponds to leaving
68-
# that set and would collapse the quotient ring, yielding a spurious result.
69-
leader_degrees = Dict(l => Nemo.degree(p, l) for (l, p) in polys)
64+
leader_degrees = Dict(lead => Nemo.degree(poly, lead) for (lead, poly) in polys)
7065

7166
local zerodim_ideal
7267
attempts = 0
7368
while true
7469
attempts += 1
75-
eval_point = [v in keys(polys) ? v : ring(rand(1:100)) for v in gens(ring)]
76-
specialized = Dict(l => evaluate(polys[l], eval_point) for l in leaders)
77-
if all(Nemo.degree(specialized[l], l) == leader_degrees[l] for l in leaders)
70+
eval_point = [v in keys(polys) ? v : ring(rand(1:(100 * attempts))) for v in gens(ring)]
71+
specialized = Dict(lead => evaluate(polys[lead], eval_point) for lead in leaders)
72+
# Checks if the degrees in leaders drop, restarts if they do
73+
if all(Nemo.degree(specialized[lead], lead) == leader_degrees[lead] for lead in leaders)
7874
all_polys = vcat(
79-
[specialized[l] for l in leaders],
75+
[specialized[lead] for lead in leaders],
8076
[evaluate(p, eval_point) for p in extra_relations],
8177
)
8278
zerodim_ideal =
8379
collect(map(p -> parent_ring_change(p, Rspec), all_polys))
8480
break
8581
end
86-
if attempts >= 100
87-
error(
88-
"Failed to find a generic specialization for the primality check " *
89-
"after $attempts attempts (the leading coefficients keep vanishing).",
90-
)
91-
end
9282
end
9383

9484
return check_primality_zerodim(zerodim_ideal)

0 commit comments

Comments
 (0)