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 specialqFile = open("specialq.txt", "w") while (smoothsCount < K): while (True): q = primemath.nextPrime(q) roots = poly.getRootsModPFast(poly.Poly(nfsPoly), q) if (len(roots) > 0): break roots.sort() for s in roots: specialqFile.write(str([s, q]) + "\n") print "special_q: %s" % [q, s] I = 1024 J = 512 smooths = sieve_special_q(q, s, I, J, rfBase, afBase, (n, nfsPoly, m, B, M, K)) smoothsCount += len(smooths) print "total smooths: %s/%s" % (smoothsCount, K) smoothsFile = open("smooths.txt", "a") for smooth in smooths: smoothsFile.write(str(smooth) + "\n") smoothsFile.close()
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 specialqFile = open("specialq.txt", "w") while(smoothsCount < K): while(True): q = primemath.nextPrime(q) roots = poly.getRootsModPFast(poly.Poly(nfsPoly),q) if(len(roots) > 0): break roots.sort() for s in roots: specialqFile.write(str([s,q])+"\n") print "special_q: %s" % [q,s] I = 1024 J = 512 smooths = sieve_special_q(q,s,I,J,rfBase,afBase,(n,nfsPoly,m,B,M,K)) smoothsCount += len(smooths) print "total smooths: %s/%s" % (smoothsCount,K) smoothsFile = open("smooths.txt", "a") for smooth in smooths: smoothsFile.write(str(smooth)+"\n") smoothsFile.close()
def 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") smooths = files.loadFileArray("smooths.txt") specialq = files.loadFileArray("specialq.txt") nOfSmooths = len(smooths) #smooths = sorted(smooths,key=hash) #smooths = sorted({hash(val): val for val in smooths}, key=hash) smooths = sorted({hash(val): val for val in smooths}.values(), key=hash) #for smooth in smooths: #print smooth print "%s duplicates removed." % (nOfSmooths - len(smooths)) nOfSmooths = len(smooths) if (len(smooths) < K + len(specialq)): print "undersieved by %s." % ((K + len(specialq)) - len(smooths)) raise AssertionError while (len(smooths) > K + len(specialq)): smooths.pop() print "%s extra relations removed." % (nOfSmooths - len(smooths)) smoothsFile = open("smooths-fil.txt", "w") for smooth in smooths: smoothsFile.write(str(smooth) + "\n") rfBaseFile = open("rfbase-fil.txt", "w") for p in rfBase: rfBaseFile.write(str(p) + "\n") afBaseFile = open("afbase-fil.txt", "w") for p in afBase: afBaseFile.write(str(p) + "\n") for p in specialq: afBaseFile.write(str(p) + "\n") '''
dep[r] = n & 1 n >>= 1 for r in range(sideLen): for c in range(r + 1, sideLen): if (matrix[r][c] == 1): dep[r] = (dep[c] + dep[r]) % 2 return dep if __name__ == '__main__': (n, nfsPoly, m, B, M, K) = files.loadParamsFile() NF = poly.NumberField(poly.Poly(nfsPoly)) rfBase = files.loadFileArray("rfbase-fil.txt") rfBase = zip(*rfBase)[1] #grab only the primes afBase = files.loadFileArray("afbase-fil.txt") qcBase = matrixmath.generateQCBase(n, afBase[-1][1], poly.Poly(nfsPoly)) smooths = files.loadFileArray("smooths-fil.txt") print "Building matrix..." matrix = [] for smoothPair in smooths: smoothPoly = poly.Poly(smoothPair) matrixRow = matrixmath.getMatrixRowRat(smoothPoly, m, rfBase) matrixRow.extend(matrixmath.getMatrixRowAlg(smoothPoly, NF, afBase)) matrixRow.extend(matrixmath.getMatrixRowQC(smoothPoly, qcBase)) matrixRow.extend([0] * (K - len(rfBase) - len(afBase) - len(qcBase) - 1)) # one extra for sign matrix.append(matrixRow)
n >>= 1 for r in range(sideLen): for c in range(r+1,sideLen): if(matrix[r][c] == 1): dep[r] = (dep[c] + dep[r]) % 2 return dep if __name__ == '__main__': (n,nfsPoly,m,B,M,K) = files.loadParamsFile() NF = poly.NumberField(poly.Poly(nfsPoly)) rfBase = files.loadFileArray("rfbase-fil.txt") rfBase = zip(*rfBase)[1] #grab only the primes afBase = files.loadFileArray("afbase-fil.txt") qcBase = matrixmath.generateQCBase(n,afBase[-1][1],poly.Poly(nfsPoly)) smooths = files.loadFileArray("smooths-fil.txt") print "Building matrix..." matrix = [] for smoothPair in smooths: smoothPoly = poly.Poly(smoothPair) matrixRow = matrixmath.getMatrixRowRat(smoothPoly,m,rfBase) matrixRow.extend(matrixmath.getMatrixRowAlg(smoothPoly,NF,afBase)) matrixRow.extend(matrixmath.getMatrixRowQC(smoothPoly,qcBase)) matrixRow.extend([0]*(K-len(rfBase)-len(afBase)-len(qcBase)-1)) # one extra for sign matrix.append(matrixRow)
import poly import etcmath import files import fractions 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)