Java Matrix Multiply multiplyMatrices(float[][] left, float[][] right)

Here you can find the source of multiplyMatrices(float[][] left, float[][] right)

Description

Returns the matrix product left * right.

License

Open Source License

Declaration

public static float[][] multiplyMatrices(float[][] left, float[][] right) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   w  w  w.  j  a  va2  s . c  om*/
     * Returns the matrix product left * right. Dimensions of left and right must match up.
     */
    public static float[][] multiplyMatrices(float[][] left, float[][] right) {
        if (left[0].length != right.length) {
            throw new IllegalArgumentException("Columns of left matric must match rows of right matrix.");
        }

        float[][] result = new float[left.length][right[0].length];
        for (int i = 0; i < left.length; ++i) {
            for (int j = 0; j < right[0].length; ++j) {
                result[i][j] = 0;
                for (int k = 0; k < right.length; ++k) {
                    result[i][j] += left[i][k] * right[k][j];
                }
            }
        }

        return result;
    }
}

Related

  1. multiply(float[][] a, float[][] b)
  2. multiply(int[][] mat1, int[][] mat2)
  3. multiply(String[] tempResult, int nextIndex, String[][] pys)
  4. multiplyAffine(final double[][] A, final double[][] B, final double[][] dest, int n)
  5. multiplyMatrices(double[][] a, double[][] b)
  6. multiplyMatrices(int[][] mat1, int[][] mat2)
  7. multiplyMatrix(int[][] a, int[] b, int mod)
  8. multiplyMatrixByMatrix(double[][] a, double[][] b)
  9. multiplyMatrixes(double[][] m1, double[][] m2)