Last active
September 15, 2018 08:34
-
-
Save hkilis/111e71d89c45f9000eeb10ff21a8f67d to your computer and use it in GitHub Desktop.
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
include ExceptionForMatrix | |
def and_matrices(mx1, mx2) | |
Matrix.Raise ErrDimensionMismatch, "Matrix dimension mismatch" unless (mx1.row_count == mx2.row_count && mx1.column_count == mx2.column_count) | |
arr = Array.new(mx1.row_count){Array.new(mx1.column_count)} | |
mx1.each_with_index{ |elem, ix, iy| arr[ix][iy] = (elem && mx2.element(ix,iy)) } | |
Matrix.rows(arr) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment