public int[] AddTest_SquareMatrix_Ints(int[] first, int[] second, int length)
        {
            SquareMatrix<int> firstMatrix = new SquareMatrix<int>(first, length);
            SquareMatrix<int> secondMatrix = new SquareMatrix<int>(second, length);
            int[] result = new int[length * length];

            firstMatrix.CalculateOperation(secondMatrix, (a, b) => a + b);

            int k = 0;
            for (int i = 0; i < firstMatrix.Width; i++)
                for (int j = 0; j < firstMatrix.Width; j++)
                {
                    result[k++] = firstMatrix[i, j];
                }

            return result;
        }
예제 #2
0
        static void Main(string[] args)
        {
            int[] ints = new int[4] { 1, 2, 3, 4 };
            SquareMatrix<int> m = new SquareMatrix<int>();
            m.ElementChanged += m_ElementChanged;
            Console.WriteLine(m.ToString());
            m[1, 1] = 5;
            Console.WriteLine(m.ToString());

            SymmetricalMatrix<int> s = new SymmetricalMatrix<int>(new int[] {1, 2, 3, 4, 5, 6}, 3);
            Console.WriteLine(s.ToString());
            s.ElementChanged += m_ElementChanged;
            s[1, 2] = 60;
            Console.WriteLine(s.ToString());

            SquareMatrix<int> m1 = new SquareMatrix<int>(new int[] { 1, 4, 5, 7 }, 2);
            SquareMatrix<int> m2 = new SquareMatrix<int>(new int[] { 1, 4, 5, 8 }, 2);
            Console.WriteLine(m1.CalculateOperation(m2, (a, b) => a + b));

            Console.ReadLine();
        }