Here you can find the source of multiplyScalars_optimizedByKnowingBothAreRectangle(float[][] x, float[][] y)
public static float[][] multiplyScalars_optimizedByKnowingBothAreRectangle(float[][] x, float[][] y)
//package com.java2s; /** Ben F Rayfield offers this software opensource MIT license */ public class Main { /** Not matrixMultiply. BigO of squared. Returns a 2d array where each index is the multiply of an index from each param array. They must both be rectangle arrays the same sizes. The optimization allows java to allocate the 2d array as 1 block of memory, and to branch in code less.// w ww . j a v a 2 s . c om */ public static float[][] multiplyScalars_optimizedByKnowingBothAreRectangle(float[][] x, float[][] y) { int b = x.length; int c = x[0].length; if (y.length != b || y[0].length != c) throw new Error("Diff sizes"); float[][] ret = new float[b][c]; for (int j = 0; j < b; j++) { for (int k = 0; k < c; k++) { ret[j][k] = x[j][k] * y[j][k]; } } return ret; } }