Created
November 22, 2020 16:58
-
-
Save dionsaputra/e68d97202f7e4282708c5ebb8a0d0ccd to your computer and use it in GitHub Desktop.
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
// matrix cross-product | |
infix fun x(other: Matrix): Matrix { | |
require(cols == other.rows) | |
val res = Matrix(rows, other.cols, Array(rows * other.cols) { 0.0 }) | |
for (i in 0 until rows) { | |
for (j in 0 until other.cols) { | |
for (k in 0 until cols) res[i,j] += (this[i,k] * other[k,j]) | |
} | |
} | |
return res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment