@@ -556,23 +556,24 @@ def relations_find(taskid, N, start, stop, P, min_log_primes, log_primes, logs_y
556
556
proc += 1
557
557
f = minifactor4 (y , P , smooth_base )
558
558
if f != None :
559
- if f [1 ] == 1 : # found a relation
559
+ if f [1 ] == 1 : # Found a relation
560
560
rels_found += 1
561
561
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
565
566
a = partials [f [1 ]]
566
567
p = filter_out_even_powers (f [0 ] + a [0 ])
567
- Ahs = A * a [3 ]
568
+ Ahs = A * a [3 ]
568
569
lhs = Rad * a [2 ]
569
570
rhs = y * a [1 ]
570
571
LHS = Ahs + lhs
571
572
g = gcd (isqrt (LHS ) - rhs , N )
572
573
if N > g > 1 :
573
574
cycleFactors .append ([g , N // g ])
574
575
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
576
577
if merge :
577
578
rel = [p , rhs , lhs , Ahs ]
578
579
if rel not in Rels :
@@ -582,7 +583,7 @@ def relations_find(taskid, N, start, stop, P, min_log_primes, log_primes, logs_y
582
583
merged_count .value += 1
583
584
del partials [f [1 ]]
584
585
else :
585
- if merge :
586
+ if merge : # Didnt merge, store the partial for later merging
586
587
partials [f [1 ]] = [f [0 ], y , Rad , A ]
587
588
else :
588
589
noproc += 1
0 commit comments