Skip to content

Instantly share code, notes, and snippets.

@piotrga
Created December 26, 2011 00:48
Show Gist options
  • Save piotrga/1520154 to your computer and use it in GitHub Desktop.
Save piotrga/1520154 to your computer and use it in GitHub Desktop.
singleThreadedMultiplication1
@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