Beispiel #1
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));
                }
            }
        }
Beispiel #2
0
        public PluckerSignMatrixDistribution(long sampleSize, int dimensions)
        {
            Matrix <double> mask = Matrix <double> .Build.Dense(5, 5, 1);

            mask[2, 0] = 0;
            mask[3, 0] = 0;
            mask[3, 1] = 0;
            for (long i = sampleSize; i > 0; i--)
            {
                Ngon          ngon       = Program.generateRandomNgon(dimensions);
                PluckerMatrix plucker    = new PluckerMatrix(ngon);
                SignMatrix    signMatrix = new SignMatrix(plucker, mask);

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

                ReducedSignMatrix2 reducedKey = similarReducedMatrix.Keys.FirstOrDefault(m => m.Equals(signMatrix.getReduced2(mask)));
                if (reducedKey == null)
                {
                    similarReducedMatrix.Add(signMatrix.getReduced2(mask), new List <Ngon>());
                    reducedKey = signMatrix.getReduced2(mask);
                }
                similarReducedMatrix[reducedKey].Add(ngon);
                if (i % (sampleSize / 100) == 0)
                {
                    Console.Write("\rCreating sign matrix table: {0}%    ", i / (sampleSize / 100));
                }
            }
        }
Beispiel #3
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));
                }
            }
        }
        public ReducedSignMatrix(SignMatrix matrix)
        {
            int length = matrix.columnVectors.Count() - 1;

            this.data = new int[length + 1];
            for (int i = 0; i < length; i++)
            {
                this.data[i] = Math.Sign(matrix.columnVectors[i + 1][i]);
            }
            this.data[length] = Math.Sign(matrix.columnVectors[length][0]);
        }
        public bool EqualsWithMask(SignMatrix other, Matrix <double> mask)
        {
            int dimensions = this.columnVectors[0].Length;

            for (int i = 0; i < dimensions; i++)
            {
                for (int j = i; j < dimensions; j++)
                {
                    if (this.columnVectors[i][j] * mask[i, j] != other.columnVectors[i][j] * mask[i, j])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #6
0
        private string htmlTableRowDistribution(SignMatrix matrix, IEnumerable <SignMatrix> relatedMatrices)
        {
            string result = "<tr style=\"border: 2px solid black;>\">";

            result += "<td style=\"border: 1px solid black;>\">";
            result += matrix.ToHtml();
            result += "</td>";
            foreach (SignMatrix relatedMatrix in relatedMatrices)
            {
                result += "<td style=\"border: 1px solid black;\">";
                result += "<p>" + matrixMap[matrix][relatedMatrix] + relatedMatrix.ToHtml() + "</p>";
                result += "</td>";
            }

            result += "<td style=\"border: 1px solid black;>\">";
            result += "<p>" + matrixMap[matrix].Values.Sum() + "</p>";
            result += "</td>";

            result += "</tr>\n";
            return(result);
        }
        public ReducedSignMatrix2(SignMatrix matrix, Matrix <double> mask)
        {
            int length = matrix.columnVectors.Count();

            this.data = new int[length][];
            for (int i = 0; i < length; i++)
            {
                int[] column = new int[length];
                for (int j = 0; j < i; j++)
                {
                    if (mask[i, j] == 1)
                    {
                        column[j] = Math.Sign(matrix.columnVectors[i][j]);
                    }
                    else
                    {
                        column[j] = 0;
                    }
                }
                this.data[i] = column;
            }
        }
Beispiel #8
0
        private string htmlTableRowPermutations(SignMatrix matrix)
        {
            string result = "<tr style=\"border: 2px solid black;>\">";

            result += "<td style=\"border: 1px solid black;>\">";
            result += matrix.ToHtml();
            result += "</td>";

            List <NgonEdgePermutations> permutations = new List <NgonEdgePermutations>();

            foreach (Ngon ngon in similarFullMatrix[matrix])
            {
                permutations.Add(new NgonEdgePermutations(ngon));
            }

            result += "<td style=\"border: 1px solid black;\">";
            foreach (NgonEdgePermutations permutation in permutations)
            {
                result += "<p>" + permutation.convex + "</p>";
            }
            result += "</td>";

            result += "<td style=\"border: 1px solid black;>\">";
            foreach (NgonEdgePermutations permutation in permutations)
            {
                result += "<p>" + permutation.reflex + "</p>";
            }
            result += "</td>";

            result += "<td style=\"border: 1px solid black;>\">";
            foreach (NgonEdgePermutations permutation in permutations)
            {
                result += "<p>" + permutation.self_intersecting + "</p>";
            }
            result += "</td>";

            result += "</tr>\n";
            return(result);
        }