示例#1
0
文件: Relation.cs 项目: zzfeed/GNFS-1
        public void Sieve(PolyRelationsSieveProgress relationsSieve)
        {
            Sieve(relationsSieve._gnfs.PrimeFactorBase.RationalFactorBase, ref RationalQuotient, RationalFactorization);

            if (IsRationalQuotientSmooth) // No sense wasting time on factoring the AlgebraicQuotient if the relation is ultimately going to be rejected anyways.
            {
                Sieve(relationsSieve._gnfs.PrimeFactorBase.AlgebraicFactorBase, ref AlgebraicQuotient, AlgebraicFactorization);
            }
        }
示例#2
0
 public GNFS()
 {
     PrimeFactorBase               = new FactorBase();
     PolynomialCollection          = new List <IPolynomial>();
     RationalFactorPairCollection  = new FactorPairCollection();
     AlgebraicFactorPairCollection = new FactorPairCollection();
     QuadraticFactorPairCollection = new FactorPairCollection();
     CurrentRelationsProgress      = new PolyRelationsSieveProgress();
 }
示例#3
0
文件: Relation.cs 项目: be4/GNFS
 public void Sieve(PolyRelationsSieveProgress relationsSieve)
 {
     Sieve(relationsSieve._gnfs.PrimeFactorBase.AlgebraicFactorBase, ref AlgebraicQuotient, AlgebraicFactorization);
     Sieve(relationsSieve._gnfs.PrimeFactorBase.RationalFactorBase, ref RationalQuotient, RationalFactorization);
 }
示例#4
0
        public GNFS(CancellationToken cancelToken, LogMessageDelegate logFunction, BigInteger n, BigInteger polynomialBase, int polyDegree, BigInteger primeBound, int relationQuantity, int relationValueRange)
            : this()
        {
            LogFunction = logFunction;
            N           = n;

            SaveLocations = new DirectoryLocations(N, polynomialBase, polyDegree);

            if (!Directory.Exists(SaveLocations.SaveDirectory))
            {
                // New GNFS instance
                Directory.CreateDirectory(SaveLocations.SaveDirectory);
                LogMessage($"Directory created.");

                if (polyDegree == -1)
                {
                    this.PolynomialDegree = CalculateDegree(n);
                }
                else
                {
                    this.PolynomialDegree = polyDegree;
                }
                this.PolynomialBase = polynomialBase;

                if (cancelToken.IsCancellationRequested)
                {
                    return;
                }

                ConstructNewPolynomial(this.PolynomialBase, this.PolynomialDegree);
                LogMessage($"Polynomial constructed.");

                if (cancelToken.IsCancellationRequested)
                {
                    return;
                }

                CaclulatePrimeFactorBaseBounds(primeBound);

                if (cancelToken.IsCancellationRequested)
                {
                    return;
                }

                SetPrimeFactorBases();
                LogMessage($"Prime bounds calculated.");

                if (cancelToken.IsCancellationRequested)
                {
                    return;
                }

                NewFactorPairCollections(cancelToken);
                LogMessage($"Factor bases populated.");

                if (cancelToken.IsCancellationRequested)
                {
                    return;
                }

                CurrentRelationsProgress = new PolyRelationsSieveProgress(this, relationQuantity, relationValueRange);
                LogMessage($"Relations container initialized.");

                Serialization.Save.All(this);
            }
        }