package com.main;
import java.util.Arrays;
public class Main {
public void multiply(int[][] A, int[][] B) {
int aRows = A.length, bRows = B.length, bColumns = B[0].length;
int[][] C = new int[aRows][bColumns];
for (int i = 0; i < aRows; i++) {
for (int j = 0; j < bColumns; j++) {
for (int k = 0; k < bRows; k++) {//这里A的列数与B的行数相等
C[i][j] += A[i][k] * B[k][j];
}
}
}
System.out.println(Arrays.toString(C));
}//multiply
public static void main(String[] args) {//(4*3)*(3*2)=(4*2)
// write your code here
int[][] A = new int[][]{
{1, 2, 3}, {1, 0, 1}, {2, 1, 0}, {1, 1, 0}};
int[][] B = new int
矩阵相乘
最新推荐文章于 2020-02-17 15:39:48 发布