Java Matrix Multiply multiplyScalars(float[][] x, float[][] y)

Here you can find the source of multiplyScalars(float[][] x, float[][] y)

Description

1d arrays can be different sizes within same parent array, but x and y must be same sizes in all ways.

License

Open Source License

Declaration

public static float[][] multiplyScalars(float[][] x, float[][] y) 

Method Source Code

//package com.java2s;
/** Ben F Rayfield offers this software opensource MIT license */

public class Main {
    /** 1d arrays can be different sizes within same parent array, but x and y must be same sizes in all ways. */
    public static float[][] multiplyScalars(float[][] x, float[][] y) {
        if (x.length != y.length)
            throw new Error("diff sizes");
        float[][] ret = new float[x.length][];
        for (int i = 0; i < x.length; i++) {
            int innerSize = x[i].length;
            ret[i] = new float[innerSize];
            if (innerSize != y[i].length)
                throw new Error("diff sizes");
            for (int j = 0; j < innerSize; j++) {
                ret[i][j] = x[i][j] * y[i][j];
            }/*from   ww w  .  j a v  a 2s .  c o m*/
        }
        return ret;
    }
}

Related

  1. multiplyMatrices(int[][] mat1, int[][] mat2)
  2. multiplyMatrix(int[][] a, int[] b, int mod)
  3. multiplyMatrixByMatrix(double[][] a, double[][] b)
  4. multiplyMatrixes(double[][] m1, double[][] m2)
  5. multiplyQuad(final double[][] A, final double[][] B, final double[][] dest, int n)
  6. multiplyScalars_optimizedByKnowingBothAreRectangle(float[][] x, float[][] y)
  7. multiplySparse2dense(int[][][] as, int A, int[][][] bs, int B, int[][] c)
  8. multiplyVectorAndMatrix(double[] vector, double[][] matrix)
  9. multiplyVectorByMatrix(double[] v, double[][] m)