Exemple #1
0
        protected static MatrixInt DotMultiplication(
            MatrixInt matrixLeft,
            MatrixInt matrixRight)
        {
            if (matrixLeft.ColumnCount != matrixRight.RowCount)
            {
                throw new DimensionMismatchException("Number of columns in first matrix does not equal number of rows in second matrix.");
            }

            var rawResult = new int[matrixLeft.RowCount, matrixRight.ColumnCount];

            for (int row = 0; row < rawResult.GetLength(0); row++)
            {
                for (int col = 0; col < rawResult.GetLength(1); col++)
                {
                    int sum = 0;
                    for (int k = 0; k < matrixLeft.ColumnCount; k++)
                    {
                        sum += matrixLeft[row, k] * matrixRight[k, col];
                    }
                    rawResult[row, col] = sum;
                }
            }
            MatrixInt result = new MatrixInt(rawResult);

            return(result);
        }
Exemple #2
0
        public MatrixInt Transpose()
        {
            var rawResult = Transpose(this);

            var result = new MatrixInt(rawResult);

            return(result);
        }
Exemple #3
0
        public MatrixInt GetRangeOfColumns(
            RangeInt columnRange)
        {
            var baseResult = GetRangeOfColumns(this, columnRange);
            var result     = new MatrixInt(baseResult);

            return(result);
        }
Exemple #4
0
        public MatrixInt GetRangeOfRows(
            RangeInt rowRange)
        {
            var baseResult = GetRangeOfRows(this, rowRange);
            var result     = new MatrixInt(baseResult);

            return(result);
        }
Exemple #5
0
 protected static MatrixInt Negative(
     MatrixInt matrix)
 {
     return(new MatrixInt(
                UnaryElementWiseOperation(
                    matrix,
                    (a) => - a
                    )));
 }
Exemple #6
0
        public MatrixInt SubMatrix(
            RangeInt rowRange,
            RangeInt columnRange)
        {
            var baseResult = SubMatrix(this, rowRange, columnRange);
            var result     = new MatrixInt(baseResult);

            return(result);
        }
Exemple #7
0
        public static MatrixInt Concatenate(
            MatrixInt matrixLeft,
            MatrixInt matrixRight)
        {
            var baseResult = MatrixBase <int> .Concatenate(matrixLeft, matrixRight);

            var result = new MatrixInt(baseResult);

            return(result);
        }
Exemple #8
0
 protected static MatrixInt Mod(
     MatrixInt matrix,
     int scalar)
 {
     return(new MatrixInt(
                ElementWiseOperation(
                    matrix,
                    scalar,
                    (a, b) => a % b
                    )));
 }
Exemple #9
0
 protected static MatrixInt Multiplication(
     MatrixInt matrixLeft,
     MatrixInt matrixRight)
 {
     return(new MatrixInt(
                ElementWiseOperation(
                    matrixLeft,
                    matrixRight,
                    (a, b) => a * b
                    )));
 }
Exemple #10
0
 protected static MatrixInt Subtraction(
     MatrixInt matrixLeft,
     MatrixInt matrixRight)
 {
     return(new MatrixInt(
                ElementWiseOperation(
                    matrixLeft,
                    matrixRight,
                    (a, b) => a - b
                    )));
 }
Exemple #11
0
        public bool Equals(MatrixInt other)
        {
            if (RowCount != other.RowCount)
            {
                throw new DimensionMismatchException("The number of rows in this matrix does not equal the number of rows in other matrix");
            }
            if (ColumnCount != other.ColumnCount)
            {
                throw new DimensionMismatchException("The number of columns in this matrix does not equal the number of columns in other matrix");
            }

            for (var row = 0; row < RowCount; row++)
            {
                for (var col = 0; col < ColumnCount; col++)
                {
                    if (this[row, col] != other[row, col])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemple #12
0
        public int FindColumn(MatrixInt column)
        {
            var result = FindColumn(this, column);

            return(result);
        }
Exemple #13
0
        internal int FindRow(MatrixInt row)
        {
            var result = FindRow(this, row);

            return(result);
        }
Exemple #14
0
        public MatrixInt AppendRows(MatrixInt rows)
        {
            var baseResult = AppendRows(this, rows);

            return(new MatrixInt(baseResult));
        }