Esempio n. 1
0
        static void Main(string[] args)
        {
            int[,] coeff  = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
            int[,] coeff2 = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
            IMatrix <int>        matrixSq = new SquareMatrix <int>(coeff);
            DiagonalMatrix <int> matrixD  = new DiagonalMatrix <int>(coeff2);
            IMatrix <int>        matrix   = matrixSq.AddMatrix(matrixD);

            Console.WriteLine(matrix.GetStringMatrix());


            string[,] str1 = { { "H", "i" }, { "Y", "O" } };
            string[,] str2 = { { "Is", null }, { null, "strange" } };
            SquareMatrix <string>   strSq     = new SquareMatrix <string>(str1);
            DiagonalMatrix <string> strD      = new DiagonalMatrix <string>(str2);
            IMatrix <string>        strMatrix = strD.AddMatrix(strSq);

            foreach (var temp in strMatrix.GetMatrix())
            {
                Console.Write(temp + " ");
            }
            double[,] coeff3 = { { 1, 2, 3 }, { 2, 1, 4 }, { 3, 4, 1 } };
            SymmetricMatrix <double> matrixSum = new SymmetricMatrix <double>(coeff3);

            Console.ReadKey();
        }
        public void Test()
        {
            SquareMatrix <T> result = _matrix1.AddMatrix(_matrix2, _addingFunc);

            Assert.AreEqual(_expected.Length, result.Count);
            for (int i = 0; i < result.Size; i++)
            {
                for (int j = 0; j < result.Size; j++)
                {
                    Assert.AreEqual(_expected[i, j], result[i, j], $"Expected: {_expected[i, j]} But was: {result[i, j]} at index [{i},{j}]");
                }
            }
        }