Skip to content

Commit 55718a1

Browse files
committed
Update MPQS.sage
1 parent f0b2070 commit 55718a1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

MPQS.sage

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,23 +556,24 @@ def relations_find(taskid, N, start, stop, P, min_log_primes, log_primes, logs_y
556556
proc += 1
557557
f = minifactor4(y, P, smooth_base)
558558
if f != None:
559-
if f[1] == 1: # found a relation
559+
if f[1] == 1: # Found a relation
560560
rels_found += 1
561561
filtered = filter_out_even_powers(f[0])
562-
rel = [filtered, y, Rad, A]
563-
Rels.append(rel)
564-
elif merge and (f[1] in partials): # found a partial and try to merge
562+
rel = [filtered, y, Rad, A]
563+
if rel not in Rels:
564+
Rels.append(rel)
565+
elif merge and (f[1] in partials): # Found a partial, try to find a cycle
565566
a = partials[f[1]]
566567
p = filter_out_even_powers(f[0] + a[0])
567-
Ahs = A*a[3]
568+
Ahs = A * a[3]
568569
lhs = Rad * a[2]
569570
rhs = y * a[1]
570571
LHS = Ahs + lhs
571572
g = gcd(isqrt(LHS) - rhs, N)
572573
if N > g > 1:
573574
cycleFactors.append([g , N // g])
574575
sys.stderr.write("Found cycle with partial\n")
575-
else: # didnt merge so store the partial for later merging
576+
else: # Cycle not found, merge
576577
if merge:
577578
rel = [p, rhs, lhs, Ahs]
578579
if rel not in Rels:
@@ -582,7 +583,7 @@ def relations_find(taskid, N, start, stop, P, min_log_primes, log_primes, logs_y
582583
merged_count.value += 1
583584
del partials[f[1]]
584585
else:
585-
if merge:
586+
if merge: # Didnt merge, store the partial for later merging
586587
partials[f[1]] = [f[0], y, Rad, A]
587588
else:
588589
noproc += 1

0 commit comments

Comments
 (0)