Exemplo n.º 1
0
        public GaussianMatrix(GNFS gnfs, List <Relation> rels)
        {
            _gnfs = gnfs;
            relationMatrixTuple = new List <Tuple <Relation, bool[]> >();
            eliminationStep     = false;
            freeCols            = new bool[0];
            M = new List <bool[]>();


            int maxRelationsToSelect = PrimeFactory.GetIndexFromValue(_gnfs.PrimeFactorBase.RationalFactorBaseMax) + PrimeFactory.GetIndexFromValue(_gnfs.PrimeFactorBase.AlgebraicFactorBaseMax) + _gnfs.QuadraticFactorPairCollection.Count + 3;

            relations = rels;

            List <GaussianRow> relationsAsRows = new List <GaussianRow>();

            foreach (Relation rel in relations)
            {
                GaussianRow row = new GaussianRow(_gnfs, rel);

                relationsAsRows.Add(row);
            }

            //List<GaussianRow> orderedRows = relationsAsRows.OrderBy(row1 => row1.LastIndexOfAlgebraic).ThenBy(row2 => row2.LastIndexOfQuadratic).ToList();

            List <GaussianRow> selectedRows = relationsAsRows.Take(maxRelationsToSelect).ToList();

            int maxIndexRat = selectedRows.Select(row => row.LastIndexOfRational).Max();
            int maxIndexAlg = selectedRows.Select(row => row.LastIndexOfAlgebraic).Max();
            int maxIndexQua = selectedRows.Select(row => row.LastIndexOfQuadratic).Max();

            foreach (GaussianRow row in selectedRows)
            {
                row.ResizeRationalPart(maxIndexRat);
                row.ResizeAlgebraicPart(maxIndexAlg);
                row.ResizeQuadraticPart(maxIndexQua);
            }

            GaussianRow exampleRow = selectedRows.First();
            int         newLength  = exampleRow.GetBoolArray().Length;

            newLength++;

            selectedRows = selectedRows.Take(newLength).ToList();


            foreach (GaussianRow row in selectedRows)
            {
                relationMatrixTuple.Add(new Tuple <Relation, bool[]>(row.SourceRelation, row.GetBoolArray()));
            }
        }
Exemplo n.º 2
0
        public GaussianMatrix(GNFS gnfs, List <Relation> rels)
        {
            _gnfs = gnfs;
            relationMatrixTuple = new List <Tuple <Relation, bool[]> >();
            eliminationStep     = false;
            freeCols            = new bool[0];
            M = new List <bool[]>();

            relations = rels;

            List <GaussianRow> relationsAsRows = new List <GaussianRow>();

            foreach (Relation rel in relations)
            {
                GaussianRow row = new GaussianRow(_gnfs, rel);

                relationsAsRows.Add(row);
            }

            //List<GaussianRow> orderedRows = relationsAsRows.OrderBy(row1 => row1.LastIndexOfAlgebraic).ThenBy(row2 => row2.LastIndexOfQuadratic).ToList();

            List <GaussianRow> selectedRows = relationsAsRows.Take(_gnfs.CurrentRelationsProgress.SmoothRelationsRequiredForMatrixStep).ToList();

            int maxIndexRat = selectedRows.Select(row => row.LastIndexOfRational).Max();
            int maxIndexAlg = selectedRows.Select(row => row.LastIndexOfAlgebraic).Max();
            int maxIndexQua = selectedRows.Select(row => row.LastIndexOfQuadratic).Max();

            foreach (GaussianRow row in selectedRows)
            {
                row.ResizeRationalPart(maxIndexRat);
                row.ResizeAlgebraicPart(maxIndexAlg);
                row.ResizeQuadraticPart(maxIndexQua);
            }

            GaussianRow exampleRow = selectedRows.First();
            int         newLength  = exampleRow.GetBoolArray().Length;

            newLength++;

            selectedRows = selectedRows.Take(newLength).ToList();


            foreach (GaussianRow row in selectedRows)
            {
                relationMatrixTuple.Add(new Tuple <Relation, bool[]>(row.SourceRelation, row.GetBoolArray()));
            }
        }