Esempio n. 1
0
        public int CompareTo(object obj)
        {
            ReducedSignMatrix other = (ReducedSignMatrix)obj;

            if (this.data.Length > other.data.Length)
            {
                return(1);
            }
            if (this.data.Length < other.data.Length)
            {
                return(-1);
            }
            for (int i = 0; i < this.data.Length; i++)
            {
                if (this.data[i] == other.data[i])
                {
                    continue;
                }
                if (this.data[i] > other.data[i])
                {
                    return(-1);
                }
                if (this.data[i] < other.data[i])
                {
                    return(1);
                }
            }
            return(0);
        }
Esempio n. 2
0
        public ProjectionSignMatrixDistribution(long sampleSize, int dimensions)
        {
            for (long i = sampleSize; i > 0; i--)
            {
                Ngon             ngon       = Program.generateRandomNgon(dimensions);
                ProjectionMatrix projetion  = new ProjectionMatrix(ngon);
                SignMatrix       signMatrix = new SignMatrix(projetion);

                SignMatrix fullKey = similarFullMatrix.Keys.FirstOrDefault(m => m.Equals(signMatrix));
                if (fullKey == null)
                {
                    similarFullMatrix.Add(signMatrix, new List <Ngon>());
                    fullKey = signMatrix;
                }
                similarFullMatrix[fullKey].Add(ngon);

                ReducedSignMatrix reducedKey = similarReducedMatrix.Keys.FirstOrDefault(m => m.Equals(signMatrix.getReduced()));
                if (reducedKey == null)
                {
                    similarReducedMatrix.Add(signMatrix.getReduced(), new List <Ngon>());
                    reducedKey = signMatrix.getReduced();
                }
                similarReducedMatrix[reducedKey].Add(ngon);
                if (i % (sampleSize / 100) == 0)
                {
                    Console.Write("\rCreating sign matrix table: {0}%    ", i / (sampleSize / 100));
                }
            }
        }
Esempio n. 3
0
        public int[] predictFiveReduced2(ReducedSignMatrix reduced1)
        {
            var result = predictConvexReduced2(reduced1);

            result[0] = -result[0];
            result[1] = -result[1];

            return(result);
        }
Esempio n. 4
0
        public PluckerAndProjectionMatricesDistribution(long sampleSize, int dimensions)
        {
            for (long i = sampleSize; i > 0; i--)
            {
                Ngon ngon = Program.generateRandomNgon(dimensions);

                #region Plucker
                PluckerMatrix plucker        = new PluckerMatrix(ngon);
                SignMatrix    pluckerSign    = new SignMatrix(plucker);
                SignMatrix    fullPluckerKey = similarPluckerFullMatrix.Keys.FirstOrDefault(m => m.Equals(pluckerSign));
                if (fullPluckerKey == null)
                {
                    similarPluckerFullMatrix.Add(pluckerSign, new List <Ngon>());
                    fullPluckerKey = pluckerSign;
                }
                similarPluckerFullMatrix[fullPluckerKey].Add(ngon);

                ReducedSignMatrix reducedPluckerKey = similarReducedMatrix.Keys.FirstOrDefault(m => m.Equals(pluckerSign.getReduced()));
                if (reducedPluckerKey == null)
                {
                    similarReducedMatrix.Add(pluckerSign.getReduced(), new List <Ngon>());
                    reducedPluckerKey = pluckerSign.getReduced();
                }
                similarReducedMatrix[reducedPluckerKey].Add(ngon);
                #endregion
                #region Projection
                ProjectionMatrix projection        = new ProjectionMatrix(ngon);
                SignMatrix       projectionSign    = new SignMatrix(projection);
                SignMatrix       fullProjectionKey = similarProjectionFullMatrix.Keys.FirstOrDefault(m => m.Equals(projectionSign));
                if (fullProjectionKey == null)
                {
                    similarProjectionFullMatrix.Add(projectionSign, new List <Ngon>());
                    fullProjectionKey = projectionSign;
                }
                similarProjectionFullMatrix[fullProjectionKey].Add(ngon);
                #endregion
                SignMatrix fullMatrixKey = matrixMap.Keys.FirstOrDefault(m => m.Equals(pluckerSign));
                if (fullMatrixKey == null)
                {
                    matrixMap.Add(pluckerSign, new Dictionary <SignMatrix, int>());
                    fullMatrixKey = pluckerSign;
                }
                SignMatrix projectionResult = matrixMap[fullMatrixKey].Keys.FirstOrDefault(m => m.Equals(projectionSign));
                if (projectionResult == null)
                {
                    matrixMap[fullMatrixKey].Add(projectionSign, 0);
                    projectionResult = projectionSign;
                }
                matrixMap[fullMatrixKey][projectionResult]++;
                if (i % (sampleSize / 100) == 0)
                {
                    Console.Write("\rCreating sign matrix table: {0}%    ", i / (sampleSize / 100));
                }
            }
        }
Esempio n. 5
0
 public int[] predictConvexReduced2(ReducedSignMatrix reduced1)
 {
     int[] result = new int[2];
     result[0] = ((reduced1.data[0] == 1) ^ (reduced1.data[1] == 1)) ? 1 : -1;
     result[1] = ((reduced1.data[2] == 1) ^ (reduced1.data[3] == 1)) ? 1 : -1;
     if (reduced1.countPositive() % 2 == 1)
     {
         result[0] = -result[0];
         result[1] = -result[1];
     }
     return(result);
 }
Esempio n. 6
0
        public MultipleReducedMatricesDistribution(int dimensions = 5)
        {
            db = new NgonDatabase(dimensions);
            Matrix <double> mask = Matrix <double> .Build.Dense(dimensions, dimensions, 1);

            if (dimensions == 5)
            {
                mask[3, 0] = 0;
                mask[3, 1] = 0;
                mask[4, 1] = 0;
            }
            if (dimensions == 4)
            {
                mask[2, 0] = 0;
                mask[3, 2] = 0;
            }

            foreach (SignMatrix matrix in db.PluckerSignMatrices)
            {
                var reduced1 = matrix.getReduced();
                var reduced2 = matrix.getReduced2(mask);

                ReducedSignMatrix reduced1Key = similarReducedMatrix.Keys.FirstOrDefault(m => m.Equals(reduced1));
                if (reduced1Key == null)
                {
                    similarReducedMatrix.Add(reduced1, new List <ReducedSignMatrix2>());
                    reduced1Key = reduced1;
                }

                ReducedSignMatrix2 reduced2Key = similarReduced2Matrix.Keys.FirstOrDefault(m => m.Equals(reduced2));
                if (reduced2Key == null)
                {
                    similarReducedMatrix[reduced1Key].Add(reduced2);
                    similarReduced2Matrix.Add(reduced2, new List <SignMatrix>());
                    reduced2Key = reduced2;
                }

                similarReduced2Matrix[reduced2Key].Add(matrix);
            }
        }
Esempio n. 7
0
        public MaskExperiment4()
        {
            int dimensions = 4;

            db = new NgonDatabase(dimensions);
            Matrix <double> mask = Matrix <double> .Build.Dense(dimensions, dimensions, 1);

            mask[2, 0] = 0;
            mask[3, 2] = 0;

            foreach (SignMatrix matrix in db.PluckerSignMatrices)
            {
                var reduced1 = matrix.getReduced();
                var reduced2 = matrix.getReduced2(mask);

                ReducedSignMatrix reduced1Key = similarReducedMatrix.Keys.FirstOrDefault(m => m.Equals(reduced1));
                if (reduced1Key == null)
                {
                    similarReducedMatrix.Add(reduced1, new List <SignMatrix>());
                    reduced1Key = reduced1;
                }
                similarReducedMatrix[reduced1Key].Add(matrix);
            }
        }