Here you can find the source of array1dTo2d(float[] in, int firstDim)
public static float[][] array1dTo2d(float[] in, int firstDim)
//package com.java2s; /** Ben F Rayfield offers this software opensource MIT license */ public class Main { /** returns a float[firstDim][in.length/firstDim] where in.length%firstDim==0 */ public static float[][] array1dTo2d(float[] in, int firstDim) { int secondDim = in.length / firstDim; if (firstDim * secondDim != in.length) throw new Error(in.length + " not divisible by " + firstDim); float[][] out = new float[firstDim][secondDim]; for (int i = 0; i < firstDim; i++) { System.arraycopy(in, i * secondDim, out[i], 0, secondDim); }/*from ww w. j a v a 2 s . c om*/ return out; } }