Exemplo n.º 1
0
        public void ExtentionMethodTests()
        {
            DiagonalMatrix <Book> ds = new DiagonalMatrix <Book>(new Book("Roman", "Ditle", "Ganre", "Publisher", 8)
                                                                 , new Book("Roman", "Ditle", "Ganre", "Publisher", 5));
            SymetricMatrix <Book> ss = new SymetricMatrix <Book>(2, new Book("Roman", "Ditle", "Ganre", "Publisher", 4)
                                                                 , new Book("Roman", "Ditle", "Ganre", "Publisher", 5), new Book("ASDASDSAD", "Ditle", "Ganre", "Publisher", 12));

            Console.WriteLine(ss);

            Console.WriteLine(ds);

            ss.Add(ds);
            Console.WriteLine(ss);

            /*DiagonalMatrix<int> m = new DiagonalMatrix<int>(1, 2, 3, 4, 5);
             * SymetricMatrix<int> m2 = new SymetricMatrix<int>(5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
             *
             * m2.MatrixEvent += (o, e) => Console.WriteLine($"EVENT: {o.ToString()}");
             * Console.WriteLine(m2);
             * m2.Add(m);
             * Console.WriteLine(m2);
             * m2.SomeMethod();
             *
             * m2[1, 1] = 12;*/
        }
Exemplo n.º 2
0
        public void Test2(int[] smas, int rc)
        {
            SymetricMatrix <int> m = new SymetricMatrix <int>(rc, smas);

            Console.WriteLine(m);
            m.MatrixEvent += (o, e) => Console.WriteLine($"Event cng {e.PreviousValue} to {e.NewValue}");
            m[0, 1]        = 131;
            //Func<int,SymetricMatrix<int>,bool> f=(o,x) => o == x[0, 1] && o == x[1, 0];
            //Assert(f);
            m[3, 3] = 12;
            Console.WriteLine(m);
        }
Exemplo n.º 3
0
        public void AddExtensionsIntTests_SymetricDiagonal(int dimension, int[] masA, int[] masB, int[] result)
        {
            var matrixA      = new SymetricMatrix <int>(dimension, masA);
            var matrixB      = new DiagonalMatrix <int>(masB); //TODO: add big diag  + sym => sym with 0s
            var resultMatrix = new SymetricMatrix <int>(dimension, result);

            matrixA.Add(matrixB);

            Console.WriteLine(matrixA);
            Console.WriteLine(resultMatrix);

            CollectionAssert.AreEquivalent(matrixA.InnerMatrix, resultMatrix.InnerMatrix);
        }
Exemplo n.º 4
0
        public void AddExtensionsIntTests_Symetric(int rc, int[] masA, int[] masB, int[] result)
        {
            var matrixA      = new SymetricMatrix <int>(rc, masA);
            var matrixB      = new SymetricMatrix <int>(rc, masB);
            var resultMatrix = new SymetricMatrix <int>(rc, result);

            matrixA.Add(matrixB);

            Console.WriteLine(matrixA);
            Console.WriteLine(resultMatrix);

            CollectionAssert.AreEquivalent(matrixA.InnerMatrix, resultMatrix.InnerMatrix);
        }
Exemplo n.º 5
0
 public void Visit(SymetricMatrix <T> matrixA, DiagonalMatrix <T> matrixB)
 {
     try
     {
         for (int i = 0; i < matrixB.RowsAndColsNumber; i++)
         {
             matrixA[i, i] += (dynamic)matrixB[i, i];
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("bad");
     }
 }
Exemplo n.º 6
0
 public void Visit(SymetricMatrix <T> matrixA, SymetricMatrix <T> matrixB)
 {
     try
     {
         for (int i = 0; i < matrixA.InnerMatrix.Length; i++)
         {
             matrixA.InnerMatrix[i] += (dynamic)matrixB.InnerMatrix[i];
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("bad");
     }
 }
Exemplo n.º 7
0
 public void Visit(SquareMaxrix <T> matrixA, SymetricMatrix <T> matrixB)
 {
     try
     {
         for (int i = 0; i < matrixB.RowsAndColsNumber; i++)
         {
             for (int j = 0; j < matrixB.RowsAndColsNumber; j++)
             {
                 matrixA[i, j] += (dynamic)matrixB[i, j];
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("bad");
     }
 }
Exemplo n.º 8
0
 public void Visit(SymetricMatrix <T> matrixA, SquareMaxrix <T> matrixB)
 {
     Visit(matrixB, matrixA);
 }
Exemplo n.º 9
0
 public void Visit(DiagonalMatrix <T> matrixA, SymetricMatrix <T> matrixB)
 {
     Visit(matrixB, matrixA);
 }
Exemplo n.º 10
0
 public void Visit(SymetricMatrix <T> m)
 {
     Console.WriteLine("Some method of symet");
 }