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); }
public MatrixInt Transpose() { var rawResult = Transpose(this); var result = new MatrixInt(rawResult); return(result); }
public MatrixInt GetRangeOfColumns( RangeInt columnRange) { var baseResult = GetRangeOfColumns(this, columnRange); var result = new MatrixInt(baseResult); return(result); }
public MatrixInt GetRangeOfRows( RangeInt rowRange) { var baseResult = GetRangeOfRows(this, rowRange); var result = new MatrixInt(baseResult); return(result); }
protected static MatrixInt Negative( MatrixInt matrix) { return(new MatrixInt( UnaryElementWiseOperation( matrix, (a) => - a ))); }
public MatrixInt SubMatrix( RangeInt rowRange, RangeInt columnRange) { var baseResult = SubMatrix(this, rowRange, columnRange); var result = new MatrixInt(baseResult); return(result); }
public static MatrixInt Concatenate( MatrixInt matrixLeft, MatrixInt matrixRight) { var baseResult = MatrixBase <int> .Concatenate(matrixLeft, matrixRight); var result = new MatrixInt(baseResult); return(result); }
protected static MatrixInt Mod( MatrixInt matrix, int scalar) { return(new MatrixInt( ElementWiseOperation( matrix, scalar, (a, b) => a % b ))); }
protected static MatrixInt Multiplication( MatrixInt matrixLeft, MatrixInt matrixRight) { return(new MatrixInt( ElementWiseOperation( matrixLeft, matrixRight, (a, b) => a * b ))); }
protected static MatrixInt Subtraction( MatrixInt matrixLeft, MatrixInt matrixRight) { return(new MatrixInt( ElementWiseOperation( matrixLeft, matrixRight, (a, b) => a - b ))); }
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); }
public int FindColumn(MatrixInt column) { var result = FindColumn(this, column); return(result); }
internal int FindRow(MatrixInt row) { var result = FindRow(this, row); return(result); }
public MatrixInt AppendRows(MatrixInt rows) { var baseResult = AppendRows(this, rows); return(new MatrixInt(baseResult)); }