Java Matrix Multiply matrixMultiplication(double[][] w, double[][] v)

Here you can find the source of matrixMultiplication(double[][] w, double[][] v)

Description

results = w*v

License

Open Source License

Parameter

Parameter Description
w a parameter
v a parameter

Declaration

public static double[][] matrixMultiplication(double[][] w, double[][] v) 

Method Source Code

//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;
    }
}

Related

  1. matrix4x4f_Mult(float[] result, float[] a, float[] b)
  2. matrix_matrix_mult(double ad[][], double ad1[][], double ad2[][])
  3. matrixMult(final float[] result, float[] m1, float[] m2)
  4. matrixMultiply(double[][] A, double[][] B, int aHeight, int bWidth, int comm, int bz, double[][] C)
  5. matrixMultiply(double[][] A, double[][] B, int n)
  6. matrixMultiply(double[][] M, float[] V)
  7. matrixMultiply(double[][] M1, double[][] M2)