Пример #1
0
        static void Main(string[] args)
        {
            uint matrixRowsCount;
            uint matrixColumnsCount;

            Console.Write("Введите количество строк матрицы: ");
            if (!TryEnterNumberFromConsole(out matrixRowsCount))
            {
                Console.Read();
                return;
            }

            Console.Write("Введите количество столбцов матрицы: ");
            if (!TryEnterNumberFromConsole(out matrixColumnsCount))
            {
                Console.Read();
                return;
            }
            Console.WriteLine();

            Console.WriteLine("Матрица А: ");
            Matrix A = new Matrix(matrixRowsCount, matrixColumnsCount);

            PrintMatrixToConsole(A);
            Console.WriteLine();

            Console.WriteLine("Матрица B: ");
            Matrix B = new Matrix(matrixRowsCount, matrixColumnsCount);

            PrintMatrixToConsole(B);
            Console.WriteLine();

            Console.WriteLine("A + B: ");
            PrintMatrixToConsole(A.GetSumOfMatrices(B));
            Console.WriteLine();

            Console.WriteLine("A + 5: ");
            PrintMatrixToConsole(A.GetSumOfMatrixAndNumber(5));
            Console.WriteLine();

            Console.WriteLine("A * B: ");
            PrintMatrixToConsole(A.GetMatrixProduct(B));
            Console.WriteLine();

            Console.WriteLine("B * 5: ");
            PrintMatrixToConsole(B.GetProductOfNumberWithMatrix(5));
            Console.WriteLine();

            Console.WriteLine("Транспонированная матрица А: ");
            PrintMatrixToConsole(A.GetTransposedMatrix());
            Console.WriteLine();

            ToeplitzMatrix tm = new ToeplitzMatrix(matrixRowsCount, matrixColumnsCount);

            Console.WriteLine(tm.GetItem(2, 2));

            Console.Write("Определитель матрицы B: ");
            Console.WriteLine(B.GetDeterminantOfMatrix());
            Console.WriteLine();

            /*Console.WriteLine("Теплицева матрица: ");
             * Matrix toeplitz = new Matrix(matrixRowsCount, matrixColumnsCount);
             * toeplitzMatrix = new int[matrixRowsCount, matrixColumnsCount];
             * toeplitzMatrix = toeplitz.CreateMatrix();
             * PrintMatrixToConsole(secondMatrix);
             * Console.WriteLine();*/

            Console.Read();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Matrix A = new Matrix(new double[, ]
            {
                { 1, 2 },
                { 3, 4 },
                { 5, 6 }
            });
            Matrix B = new Matrix(new double[, ]
            {
                { 7, 8 },
                { 9, 10 },
                { 11, 12 }
            });
            Matrix C = new Matrix(new double[, ]
            {
                { -7, 8, 9 },
                { 10, 11, 12 }
            });
            Matrix D = new Matrix(new double[, ]
            {
                { -7, 8, 9 },
                { 10, 11, 12 },
                { 1, 2, -100 }
            });

            Console.WriteLine("Исходная матрица A:");
            Console.WriteLine(A);

            Console.WriteLine("Матрица A + 3:");
            Console.WriteLine(A + 3);

            Console.WriteLine("Матрица A * 2:");
            Console.WriteLine(A * 2);

            Console.WriteLine("Матрица A транспонированная:");
            Console.WriteLine(A.GetTranspose());

            Console.WriteLine("Исходная матрица B:");
            Console.WriteLine(B);

            Console.WriteLine("Матрица A + B:");
            Console.WriteLine(A + B);

            Console.WriteLine("Исходная матрица C:");
            Console.WriteLine(C);

            Console.WriteLine("Матрица A * C:");
            Console.WriteLine(A * C);

            Console.WriteLine("Исходная матрица D:");
            Console.WriteLine(D);

            Console.WriteLine("Определитель матрицы D:");
            Console.Write(D.GetDeterminant() + "\n");

            Matrix tA = new ToeplitzMatrix(new double[] { 1, 2, 3, 4 }, new double[] { 5, 7, 9 });
            Matrix tB = new ToeplitzMatrix(new double[] { 5, 73, -9, 1 }, new double[] { -5, 57, -19 });

            Console.WriteLine("Матрица Тёплица tA:");
            Console.WriteLine(tA);

            Console.ReadLine();
        }