Java Matrix Flatten flatten(int[][] arr)

Here you can find the source of flatten(int[][] arr)

Description

flatten

License

Apache License

Declaration

public static int[] flatten(int[][] arr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int[] flatten(int[][] arr) {
        int[] ret = new int[arr.length * arr[0].length];
        int count = 0;
        for (int i = 0; i < arr.length; i++)
            for (int j = 0; j < arr[i].length; j++)
                ret[count++] = arr[i][j];
        return ret;
    }/*from  ww  w  . j a  va2s  . com*/

    public static double[] flatten(double[][] arr) {
        double[] ret = new double[arr.length * arr[0].length];
        int count = 0;
        for (int i = 0; i < arr.length; i++)
            for (int j = 0; j < arr[i].length; j++)
                ret[count++] = arr[i][j];
        return ret;
    }
}

Related

  1. flatten(double[][] array)
  2. flatten(double[][] array)
  3. flatten(double[][] matrix)
  4. flatten(double[][] matrix)
  5. flatten(double[][] spills)
  6. Flatten(int[][] in, int[] out)
  7. flatten(String[][] table)
  8. flatten2DArray(byte[][] array)
  9. flatten2DArray(double[][] array)