Here you can find the source of mult(double[][] A, double[][] B)
public static double[][] mult(double[][] A, double[][] B)
//package com.java2s; //License from project: Creative Commons License import java.util.Arrays; public class Main { public static double[][] mult(double[][] A, double[][] B) { if (A.length != B.length) throw new IllegalArgumentException("dim A != dim B"); double[][] AB = buildZeroMatrix(A.length); for (int i = 0; i < A.length; i++) { for (int j = 0; j < A.length; j++) { AB[i][j] = 0;//w w w . j a va2 s. c om for (int k = 0; k < A.length; k++) { AB[i][j] += A[i][k] * B[k][j]; } } } return AB; } /** * * @return zero matrix of m*m size */ public static double[][] buildZeroMatrix(int m) { double[][] matrix = new double[m][m]; for (int index = 0; index < m; index++) Arrays.fill(matrix[index], 0); return matrix; } }