提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
矩阵向量乘积函数
public class Main { static int[] MultiplyMatrixVector(int[][] mat, int[] v) { int[] result; result = new int[mat.length]; /** N o w J a v a . c o m 提供 **/ for (int i = 0; i < result.length; i++) { result[i] = 0; for (int j = 0; j < v.length; j++) result[i] += mat[i][j] * v[j]; } return result; } public static void main(String[] args) { int[][] M = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int[] v = {1, 2, 3}; int[] z = MultiplyMatrixVector(M, v); /** 时 代 J a v a -