#include

vector<vector> matrixMultiply(vector<vector>& array1, vector<vector>& array2) { int row1 = array1.size(), col1 = array1[0].size(); int row2 = array2.size(), col2 = array2[0].size(); vector<vector> res(row1, vector(col2, 0)); if(col1 != row2) return res; else{ for(int i = 0; i < row1; i++){ for(int j = 0; j < col2; j++){ int temp = 0; for(int k = 0; k<col1; k++){ temp += array1[i][k] * array2[k][j]; } res[i][j] = temp; } } return res; }

C++ 矩阵相乘函数:任意行列数矩阵乘法实现

原文地址: https://www.cveoy.top/t/topic/ljyQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录