public static float multiplyMatrix float float int linesL Length int c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public static float[][] multiplyMatrix(float[][] l, float[][] r)
{
int linesL = l.Length;
int columnsL = l[0].Length;
int linesR = r.Length;
if (columnsL != linesR) return null;
int columnsR = r[0].Length;
float[][] ans = new float[linesL][];
for (int i = 0; i < linesL; ++i)
ans[i] = new float[columnsR];
for (int i = 0; i < linesL; ++i)
for (int j = 0; j < columnsR; ++j)
for (int k = 0; k < columnsL; ++k)
ans[i][j] += l[i][k] * r[k][j];
return ans;
}