This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Matrix | |
def &(matrix) | |
Matrix.Raise ErrDimensionMismatch, "Matrix dimension mismatch" unless (row_count == matrix.row_count && column_count == matrix.column_count) | |
rows = Array.new(row_count) {|i| | |
Array.new(column_count) {|j| | |
self[i, j] & matrix[i, j] | |
} | |
} | |
new_matrix rows, matrix.column_count | |
end |