コード例 #1
0
        public new IntegerMatrix GetTransposed()
        {
            IntegerMatrix matrix = new IntegerMatrix(Rows, Columns);

            Transpose(matrix);
            return(matrix);
        }
コード例 #2
0
 public static IntegerSquareMatrix ConvertToIntegerSquareMatrix(IntegerMatrix matrix)
 {
     try
     {
         return(matrix as IntegerSquareMatrix);
     }
     catch (InvalidCastException)
     {
         throw new InvalidCastException();
     }
 }
コード例 #3
0
        public static IntegerMatrix operator %(IntegerMatrix divinded, int mod)
        {
            IntegerMatrix result = new IntegerMatrix(divinded);

            for (int i = 0; i < divinded.Rows; i++)
            {
                for (int j = 0; j < divinded.Columns; j++)
                {
                    result[i, j] = divinded[i, j] % mod;
                }
            }

            return(result);
        }
コード例 #4
0
        public static IntegerMatrix operator +(IntegerMatrix matrix1, IntegerMatrix matrix2)
        {
            int rows    = Math.Max(matrix1.Rows, matrix2.Rows);
            int columns = Math.Max(matrix1.Columns, matrix2.Columns);

            IntegerMatrix sum = new IntegerMatrix(rows, columns);

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    sum[i, j] = matrix1[i, j] + matrix2[i, j];
                }
            }
            return(sum);
        }
コード例 #5
0
        public static IntegerMatrix operator *(IntegerMatrix factor1, IntegerMatrix factor2)
        {
            if (factor1.Rows != factor2.Columns) //factor1.GetLength(1) число столбцов в 1 матрице
            {
                return(null);                    //factor2.GetLength(0) число строк в 2 матрице
            }

            IntegerMatrix composition = new IntegerMatrix(factor1.Rows, factor2.Columns);

            for (int i = 0; i < factor1.Rows; i++)
            {
                for (int j = 0; j < factor2.Columns; j++)
                {
                    for (int k = 0; k < factor2.Rows; k++)
                    {
                        composition[i, j] += factor1[i, k] * factor2[k, j];
                    }
                }
            }
            return(composition);
        }
コード例 #6
0
        public IntegerSquareMatrix(IntegerMatrix matrix)
        {
            if (matrix.Columns > matrix.Rows)
            {
                Columns = matrix.Rows;
                Rows    = matrix.Rows;
            }
            else
            {
                Columns = matrix.Columns;
                Rows    = matrix.Columns;
            }

            elements = new int[Rows, Rows];
            for (int i = 0; i < Rows; i++)
            {
                for (int j = 0; j < Rows; j++)
                {
                    this[i, j] = matrix[i, j];
                }
            }
        }