예제 #1
0
        private static void SameSignInTwoEntries()
        {
            NgonDatabase database     = new NgonDatabase();
            long         length       = Factorial(database.PluckerSignMatrices.First().columnVectors.Length - 1) - 1;
            long         actualLength = 0;

            int[,] incrementMatrix = new int[length, length];
            var l = (from r in database.PluckerSignMatrices select r);

            foreach (SignMatrix matrix in l)
            {
                if (matrix.Ngons.Count(n => n.Type == NgonType.Convex) != -1)
                {
                    actualLength++;
                    int l1 = 0;
                    for (int i = 0; i < matrix.columnVectors.Length; i++)
                    {
                        for (int j = i + 1; j < matrix.columnVectors.Length; j++)
                        {
                            int l2 = 0;
                            for (int m = 0; m < matrix.columnVectors.Length; m++)
                            {
                                for (int n = m + 1; n < matrix.columnVectors.Length; n++)
                                {
                                    //Console.Write(i + "-" + j + ":" + m + "-" + n + "   ");
                                    //Console.WriteLine();

                                    if (matrix.columnVectors[i][j] == matrix.columnVectors[m][n])
                                    {
                                        incrementMatrix[l1, l2]++;
                                    }
                                    l2++;
                                }
                            }
                            l1++;
                        }
                    }
                }
            }
            for (int h = 0; h < length; h++)
            {
                for (int b = 0; b < length; b++)
                {
                    Console.Write((double)incrementMatrix[h, b] + " ");
                }
                Console.WriteLine();
            }
            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < length; j++)
                {
                    Console.Write((double)incrementMatrix[i, j] / actualLength + " ");
                }
                Console.WriteLine();
            }
        }
예제 #2
0
        private static void EditNgonMatrixLinks()
        {
            NgonDatabase database = new NgonDatabase();

            foreach (Ngon ngon in database.Ngons)
            {
                ngon.PluckerSignMatrix.Ngons.Add(ngon);
            }
            database.SaveChanges();
        }
예제 #3
0
        private static void addNgonToDatabase(int n, int sampleSize = 1)
        {
            NgonDatabase database = new NgonDatabase(n);

            List <Ngon> ngons = new List <Ngon>();

            for (int i = 0; i < sampleSize; i++)
            {
                Ngon          ngon       = Program.generateRandomNgon(n);
                PluckerMatrix plucker    = new PluckerMatrix(ngon);
                SignMatrix    signMatrix = new SignMatrix(plucker);
                SignMatrix    existing   = null;
                try { existing = database.PluckerSignMatricesStorage.FirstOrDefault(m => m.encodedColumnVectors == signMatrix.encodedColumnVectors); }
                catch (Exception e) { }
                if (existing == null)
                {
                    database.Add(signMatrix);
                    existing = signMatrix;
                }
                ngon.PluckerSignMatrix = existing;
                ngons.Add(ngon);
            }
            database.Add(ngons);
        }