Here you can find the source of matrix_x_matrix(double[][] A, double[][] B)
Parameter | Description |
---|---|
A | Matrix (m x n). |
B | Matrix (n x o). |
public static double[][] matrix_x_matrix(double[][] A, double[][] B)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . j a va 2s . com * Multiplies two matrices. * @param A Matrix (m x n). * @param B Matrix (n x o). * @return The resulting matrix of size m x o. */ public static double[][] matrix_x_matrix(double[][] A, double[][] B) { final int nA = A[0].length; final int mC = A.length; final int nC = B[0].length; final double[][] C = new double[mC][nC]; for (int i = 0; i < mC; i++) { final double[] C_row = C[i]; final double[] A_row = A[i]; for (int j = 0; j < nC; j++) { for (int k = 0; k < nA; k++) { C_row[j] += A_row[k] * B[k][j]; } } } return C; } }