147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/include/prime_mpqs.rb', line 147
def find_factor_single_thread
r_list = []
factorization = []
big_prime_sup = []
loop do
a, b, c, d = next_poly
sieve_rslt = sieve(a, b, c, d)
next if sieve_rslt.empty?
f, big, r = eliminate_big_primes(sieve_rslt)
next if f.empty?
factorization += f
r_list += r
big_prime_sup += big
eliminated = gaussian_elimination(f)
eliminated.each do |row|
x = y = 1
f = Array.new(@factor_base_size, 0)
factorization.size.times do |i|
next if row[i] == 0
x = x * r_list[i] % @n
f = f.zip(factorization[i]).map{|e1, e2| e1 + e2}
y = y * big_prime_sup[i] % @n
end
2.upto(@factor_base_size - 1) do |i|
y = y * Abst.power(@factor_base[i], f[i] >> 1, @n) % @n
end
y = (y << (f[1] >> 1)) % @n
z = Abst.lehmer_gcd(x - y, @original_n)
return z if 1 < z and z < @original_n
end
end
end
|