Last active
October 15, 2017 13:24
-
-
Save anyley/0de0662eea378a2eb57a24d103516b93 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
def matrix_mult(a, b) | |
a.map do |ar| | |
ar.each_index.map do |aci| | |
b.each_with_index.reduce(0) do |sum, (br, bri)| | |
sum + ar[bri] * br[aci] | |
end | |
end | |
end | |
end | |
def m_mult(a, b) | |
a.map { |ar| ar.each_index.map { |aci| b.each_with_index.reduce(0) { |sum, (br, bri)| sum + ar[bri] * br[aci] }}} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment