Here you can find the source of matrixMultiplication(double[][] w, double[][] v)
Parameter | Description |
---|---|
w | a parameter |
v | a parameter |
public static double[][] matrixMultiplication(double[][] w, double[][] v)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w . j a v a 2 s . c om*/ * results = w*v * @param w * @param v * @return */ public static double[][] matrixMultiplication(double[][] w, double[][] v) { int w1 = w.length; int w2 = w[0].length; int v1 = v.length; int v2 = v[0].length; if (w2 != v1) { System.out.println("Matrix dimensions do not agree..."); System.exit(-1); } double[][] result = new double[w1][v2]; for (int w_i1 = 0; w_i1 < w1; w_i1++) { for (int v_i2 = 0; v_i2 < v2; v_i2++) { double sum = 0; for (int w_i2 = 0; w_i2 < w2; w_i2++) { sum += w[w_i1][w_i2] * v[w_i2][v_i2]; } result[w_i1][v_i2] = sum; } } return result; } }