예제 #1
0
 private Program()
 {
     _matrix = new Portable.Matrix(new double[, ] {
         { 2, -1, 2 }, { -2, 3, 1 }
     });
     _matrix2 = new Portable.Matrix(new[, ] {
         { 2.5, 3.4, 2.2 }, { 8.5, 6.4, 4 }
     });
     _matrix3 = new Portable.Matrix(new double[, ] {
         { -3, 2 }, { 2, 1 }, { 3, -1 }
     });
     _submatrix3 = _matrix3.SubMatrix(new Point(0, 0), new Point(2, 2));
     DrawTable(_matrix3);
     DrawTable(_submatrix3);
     Console.WriteLine(_submatrix3.ToSquareMatrix().Determinant);
     _matrix3.ToArray()[0, 0] = 100000;
     DrawTable(_matrix3);
 }
예제 #2
0
        public void DrawTable(Portable.Matrix matrix)
        {
            var filler = new string[matrix.ColumnCount].Fill(string.Empty);

            filler[0] = nameof(matrix);
            var table = new ConsoleTable(filler);

            for (var x = 0; x < matrix.RowCount; x++)
            {
                var row = new string[matrix.ColumnCount];

                for (var y = 0; y < matrix.ColumnCount; y++)
                {
                    row[y] = $"{matrix[x, y]}";
                }

                table.AddRow(row);
            }

            table.Write(Format.Alternative);
        }