Java Array One Dimension to Two Dimension array1dTo2d(float[] in, int firstDim)

Here you can find the source of array1dTo2d(float[] in, int firstDim)

Description

returns a float[firstDim][in.length/firstDim] where in.length%firstDim==0

License

Open Source License

Declaration

public static float[][] array1dTo2d(float[] in, int firstDim) 

Method Source Code

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

Related

  1. array1DTo2D(double[] In, int H)
  2. array1DTo2D(final Object data, final int bitpix, final int width, final int height)
  3. array1Dto2D(int m, int n, double[] b)
  4. array1DTo2D(int[] array1D)
  5. array1Dto2D(int[] d1, int imageWidth, int imageHeight)
  6. array2multidim(float[] arr, int width, int height)