예제 #1
0
파일: sieve-lat.py 프로젝트: JoeyL12138/nfs
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()
예제 #2
0
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()	
예제 #3
0
def generateQCBase(n, p, nfsPoly):
    qcbase = []
    while (len(qcbase) < 3 * math.log(n, 10)):
        p = primemath.nextPrime(p)
        roots = poly.getRootsModPFast(nfsPoly, p)
        for root in roots:
            if (nfsPoly.derivative().evaluate(root) % p != 0):
                qcbase.append([root, p])
    return qcbase
예제 #4
0
def generateQCBase(n,p,nfsPoly):
	qcbase = []
	while(len(qcbase) < 3*math.log(n,10)):
		p = primemath.nextPrime(p)
		roots = poly.getRootsModPFast(nfsPoly,p)
		for root in roots:
			if(nfsPoly.derivative().evaluate(root) % p != 0):
				qcbase.append([root,p])
	return qcbase