Created
December 26, 2011 02:20
-
-
Save piotrga/1520404 to your computer and use it in GitHub Desktop.
Matrix multiplication with parallel collections and idiomatic scala
This file contains 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 multiThreadedIdiomatic(m1:Seq[Array[Double]], m2:Array[Array[Double]] ) ={ | |
val res = Array.fill(m1.length, m2(0).length)(0.0) | |
for(row <- (0 until m1.length).par; | |
col <- (0 until m2(0).length).par; | |
i <- 0 until m1(0).length){ | |
res(row)(col) += m1(row)(i) * m2(i)(col) | |
} | |
res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment