Java Matrix Flatten flatten(double[][] spills)

Here you can find the source of flatten(double[][] spills)

Description

flatten

License

Open Source License

Declaration

public static double[] flatten(double[][] spills) 

Method Source Code

//package com.java2s;
/*/*from w w w  .  j a v a2s . c  om*/
 * ------------------------------------------------------------------------ Copyright 2016 by Aaron
 * Hart Email: Aaron.Hart@gmail.com
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * GNU General Public License, Version 3, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program; if
 * not, see <http://www.gnu.org/licenses>.
 * ---------------------------------------------------------------------
 *
 * Created on December 14, 2016 by Aaron Hart
 */

public class Main {
    public static double[] flatten(double[][] spills) {
        double[] flat;
        if (spills.length > 0) {
            flat = new double[spills.length * spills[0].length];
            for (int i = 0; i < spills.length; i++) {
                for (int j = 0; j < spills[0].length; j++) {
                    flat[i * spills[0].length + j] = spills[i][j];
                }
            }
        } else {
            flat = new double[] {};
        }
        return flat;
    }
}

Related

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