Here you can find the source of unpack(double[] packed, int width, int height, int outputIndex)
Parameter | Description |
---|---|
packed | The packed array. |
width | The width, or number of columns, in the unpacked array. |
height | The height, or number of rows, in the unpacked array. |
outputIndex | The index to start reading from in the packed array. |
public static double[][] unpack(double[] packed, int width, int height, int outputIndex)
//package com.java2s; //License from project: Open Source License public class Main { /** // w ww.j a v a 2s .com * Returns a new array that is the result of unpacking the given 1D array into a 2D array, row-first. * @param packed The packed array. * @param width The width, or number of columns, in the unpacked array. * @param height The height, or number of rows, in the unpacked array. * @param outputIndex The index to start reading from in the packed array. * @see #pack(double[][]) */ public static double[][] unpack(double[] packed, int width, int height, int outputIndex) { double[][] unpacked = new double[height][width]; return unpack(packed, unpacked, outputIndex); } /** * Unpacks the values in the given 1D array into the given 2D array, row-first. * @param packed The packed array. * @param unpacked an array to copy the result into. Should have dimensions [height/rows][width/columns]. * @param outputIndex The index to start reading from in the packed array. * @return a reference to the array passed in for parameter unpacked. * @see #pack(double[][]) */ public static double[][] unpack(double[] packed, double[][] unpacked, int outputIndex) { int width = unpacked[0].length; int height = unpacked.length; int i = outputIndex; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { unpacked[y][x] = packed[i++]; } } return unpacked; } }