Created
December 26, 2011 00:48
-
-
Save piotrga/1520154 to your computer and use it in GitHub Desktop.
singleThreadedMultiplication1
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
@inline def singleThreadedMultiplication1(m1:Seq[Array[Double]], m2:Array[Array[Double]] ) ={ | |
val res = Array.ofDim[Double](m1.length, m2(0).length) | |
var col, i = 0 | |
var row = 0 | |
// while statements are much faster than for statements | |
while(row < m1.length){ col = 0 | |
while(col < m2(0).length){ i = 0 | |
while(i < m1(0).length){ | |
res(row)(col) += m1(row)(i) * m2(i)(col) | |
i+=1 | |
} | |
col += 1 | |
} | |
row += 1 | |
} | |
res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment