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

Method f1

src/class098/Code02_BigShow.java:91–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90 // 矩阵乘法的展示
91 public static void f1() {
92 int[][] a = { { 1, 3 }, { 4, 2 } };
93 int[][] b = { { 2, 3 }, { 3, 2 } };
94 // 2 3
95 // 3 2
96 //
97 // 1 3 11 9
98 // 4 2 14 16
99 int[][] ans1 = multiply(a, b);
100 print(ans1);
101 System.out.println("======");
102 int[][] c = { { 2, 4 }, { 3, 2 } };
103 int[][] d = { { 2, 3, 2 }, { 3, 2, 3 } };
104 // 2 3 2
105 // 3 2 3
106 //
107 // 2 4 16 14 16
108 // 3 2 12 13 12
109 int[][] ans2 = multiply(c, d);
110 print(ans2);
111 System.out.println("======");
112 int[][] e = { { 2, 4 }, { 1, 2 }, { 3, 1 } };
113 int[][] f = { { 2, 3 }, { 4, 1 } };
114 // 2 3
115 // 4 1
116 //
117 // 2 4 20 10
118 // 1 2 10 5
119 // 3 1 10 10
120 int[][] ans3 = multiply(e, f);
121 print(ans3);
122 System.out.println("======");
123 int[][] g = { { 3, 1, 2 } };
124 int[][] h = { { 1, 2, 1 }, { 3, 2, 1 }, { 4, 2, -2 } };
125 // 1 2 1
126 // 3 2 1
127 // 4 2 -2
128 //
129 // 3 1 2 14 12 0
130 int[][] ans4 = multiply(g, h);
131 print(ans4);
132 }
133
134 // 矩阵快速幂用法的展示
135 public static void f2() {

Callers 1

mainMethod · 0.95

Calls 3

multiplyMethod · 0.95
printMethod · 0.95
printlnMethod · 0.45

Tested by

no test coverage detected