List of utility methods to do Array Two Dimension to One Dimension
void | array2dcopy(final String[][] src, final String[][] target) Copies the content of to_copy into target. assert (target.length == src.length); for (int i = 0; i < target.length; ++i) { int array_length = src[i].length; target[i] = new String[src[i].length]; System.arraycopy(src[i], 0, target[i], 0, array_length); |
void | array2dCopy(Object[][] src, Object[][] dest) deep copy a 2D array int n = src.length; for (int i = 0; i < n; i++) { System.arraycopy(src[i], 0, dest[i], 0, n); |
double[] | array2DTo1D(double[][] In) Returns 1d array (column major) of a 2d array. int W = In.length; int H = In[0].length; double[] Out = new double[H * W]; for (int j = 0; j < H; j++) for (int i = 0; i < W; i++) Out[j * W + i] = In[i][j]; return Out; |
float[] | array2dTo1d(float[][] in) arrayd Tod int b = in.length, c = in[0].length; float[] out = new float[b * c]; for (int i = 0; i < b; i++) { System.arraycopy(in[i], 0, out, i * c, c); return out; |
double[] | array2Dto1D(int m, int n, double[][] a) array Dto D int i, j; double b[]; b = new double[m * n]; for (i = 0; i < m; i++) for (j = 0; j < n; j++) b[i * n + j] = a[i][j]; return b; |
int[] | array2DTo1D(int[][] array2D) array D To D int[] array1D = new int[array2D[0].length * array2D.length]; for (int x = 0; x < array2D.length; x++) { for (int y = 0; y < array2D[0].length; y++) { array1D[(x * array2D.length) + y] = array2D[x][y]; return array1D; |
int[] | array2Dto1D(int[][] d2) array Dto D int hight = d2.length; int width = d2[0].length; int[] modImgArray = new int[width * hight]; for (int i = 0; i < hight; i++) { System.arraycopy(d2[i], 0, modImgArray, i * width, width); return modImgArray; |
short[][] | array2Square(short[] ar, int rows, int cols) array Square short[][] square = new short[rows][cols]; int c = 0, r = 0; for (int i = 0; i < ar.length; i++) { if (c == cols) { c = 0; r++; square[r][c] = ar[i]; ... |