https://ko.wikipedia.org/wiki/%ED%96%89%EB%A0%AC_%EA%B3%B1%EC%85%88
ํ๋ ฌ A๋ a x b ํ๋ ฌ, ํ๋ ฌ B๋ b x cํ๋ ฌ์ด๋ผ๊ณ ํ ๋,
ํ๋ ฌ A์ ํ๋ ฌ B์ ๊ณฑ์ผ๋ก ๋์จ ํ๋ ฌ C์ ์์๋ ๋ค์๊ณผ ๊ฐ๋ค.
fun matrixMultiply(arr1: Array<IntArray>, arr2: Array<IntArray>): Array<IntArray> {
val (m1, m2) = if (arr1[0].size == arr2.size) {
arr1 to arr2
} else { // arr2[0].size == arr1.size
arr2 to arr1
}
return Array<IntArray>(m1.size) { i ->
IntArray(m2[0].size) { j ->
var sum = 0
for (k in m2.indices) {
sum += m1[i][k] * m2[k][j]
}
sum
}
}
}
'๊ณณ๊ฐ์์ ์ธ์ฌ๋๋ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Java] Thread-Safeํ Singleton ๊ฐ์ฒด (0) | 2024.10.01 |
---|---|
[์ฝ๊ธฐ][Android] Could Google Be Forced to Abandon Android? (0) | 2024.09.17 |
[Android][Animation] 2์ด๋ง๋ค ๊น๋นก์ด๋ ์ ๋๋ฉ์ด์ . ์ด๊ฐ๋จ ๊ตฌํ (0) | 2023.07.27 |
[Android] Swipe ์ ์ค์ณ ๊ฐ์ง CustomView (0) | 2023.07.20 |