if(abgcd != 1): continue normRat = a+b*m elog_r = math.log(abs(normRat)) sieveBound_r = elog_r-lambd_r*logB if (sieve[i+I/2-1][j+J/2-1] > sieveBound_r): normAlg = NF(poly.Poly([a,b])).norm()/q elog_a = math.log(abs(normAlg)) sieveBound_a = elog_a-lambd_a*logB if (sieve[i+I/2-1][j+J/2-1] > sieveBound_a+sieveBound_r): candidates += 1 if(etcmath.trialdivide(normAlg,afBase) and etcmath.trialdivide(normRat,rfBase)): count += 1 smooths.append([a,b]) print "%s smooths found out of %s candidates." % (count,candidates) return smooths def main(): (n,nfsPoly,m,B,M,K) = files.loadParamsFile() afBase = files.loadFileArray("afbase.txt") rfBase = files.loadFileArray("rfbase.txt") smoothsFile = open("smooths.txt", "w") smoothsCount = 0 q = B K+=K/10
continue normRat = a + b * m elog_r = math.log(abs(normRat)) sieveBound_r = elog_r - lambd_r * logB if (sieve[i + I / 2 - 1][j + J / 2 - 1] > sieveBound_r): normAlg = NF(poly.Poly([a, b])).norm() / q elog_a = math.log(abs(normAlg)) sieveBound_a = elog_a - lambd_a * logB if (sieve[i + I / 2 - 1][j + J / 2 - 1] > sieveBound_a + sieveBound_r): candidates += 1 if (etcmath.trialdivide(normAlg, afBase) and etcmath.trialdivide(normRat, rfBase)): count += 1 smooths.append([a, b]) print "%s smooths found out of %s candidates." % (count, candidates) return smooths def main(): (n, nfsPoly, m, B, M, K) = files.loadParamsFile() afBase = files.loadFileArray("afbase.txt") rfBase = files.loadFileArray("rfbase.txt") smoothsFile = open("smooths.txt", "w") smoothsCount = 0
if __name__ == '__main__': (n,nfsPoly,m,B,M,K) = files.loadParamsFile() NF = poly.NumberField(poly.Poly(nfsPoly)) rfBase = files.loadFileArray("rfbase.txt") afBase = files.loadFileArray("afbase.txt") open("specialq.txt", "w") smoothsFile = open("smooths.txt", "w") a = -M b = 1 smoothsCount = 0 while(smoothsCount < K): a += 1 if(a > M): a = -M b += 1 if(fractions.gcd(a,b) != 1): continue polyToTest = poly.Poly([a,b]) if(etcmath.trialdivide(NF(polyToTest).norm(),afBase) and etcmath.trialdivide((a+b*m),rfBase)): smoothsCount += 1 print "%s/%s: %s" % (smoothsCount,K,polyToTest) smoothsFile.write(str([a,b])+"\n") smoothsFile.close()