标签:
一、矩阵相乘
1 public int[][] matrixMulti(int[][]a, int[][]b){ 2 int[][] answer = new int[a.length][b[0].length]; 3 4 if (a[0].length != b.length) 5 { 6 System.out.println("这两个矩阵不能相乘!"); 7 return answer; 8 } 9 10 11 for (int[] x: answer ) 12 { 13 for (int y: x ) 14 { 15 y = 0; 16 } 17 } 18 19 for (int i=0;i<a.length ;i++ ) 20 { 21 for (int j=0;j<b[i].length ;j++ ) 22 { 23 for (int k = 0;k < b[i].length ; k++ ) 24 { 25 26 answer[i][j] = answer[i][j] + a[i][k] * b[k][i]; 27 } 28 } 29 } 30 return answer; 31 }
标签:
原文地址:http://www.cnblogs.com/youilika/p/4851013.html