MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / multiply

Method multiply

src/class098/Code02_BigShow.java:40–53  ·  view source on GitHub ↗
(int[][] a, int[][] b)

Source from the content-addressed store, hash-verified

38 // 矩阵相乘
39 // a的列数一定要等于b的行数
40 public static int[][] multiply(int[][] a, int[][] b) {
41 int n = a.length;
42 int m = b[0].length;
43 int k = a[0].length;
44 int[][] ans = new int[n][m];
45 for (int i = 0; i < n; i++) {
46 for (int j = 0; j < m; j++) {
47 for (int c = 0; c < k; c++) {
48 ans[i][j] += a[i][c] * b[c][j];
49 }
50 }
51 }
52 return ans;
53 }
54
55 // 矩阵快速幂
56 // 要求矩阵m是正方形矩阵

Callers 8

powerMethod · 0.95
f1Method · 0.95
f2Method · 0.95
f3Method · 0.95
f4Method · 0.95
f1Method · 0.45
computeMethod · 0.45
c1Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected