Here you can find the source of multiply(double[][] a, double[][] x)
public static double[][] multiply(double[][] a, double[][] x)
//package com.java2s; //License from project: Open Source License public class Main { public static double[][] multiply(double[][] a, double[][] x) { double[][] y = new double[a.length][x[0].length]; double[][] x_t = transpose(x); for (int i = 0; i < a.length; i++) { for (int j = 0; j < x_t.length; j++) { y[i][j] = dotProduct(a[i], x_t[j]); }// ww w . j a va 2 s .co m } return y; } public static double[][] transpose(double[][] x) { double[][] t = new double[x[0].length][x.length]; for (int i = 0; i < x.length; i++) { for (int j = 0; j < x[0].length; j++) { t[j][i] = x[i][j]; } } return t; } public static double dotProduct(double[] xs1, double[] xs2) { double product = 0; for (int i = 0; i < xs1.length; i++) { product += xs1[i] * xs2[i]; } return product; } }