Here you can find the source of collapse(float[][] array)
Parameter | Description |
---|---|
array | the two-dimensional array |
public static float[] collapse(float[][] array)
//package com.java2s; /*//from w w w.j a v a 2 s. co m * ArikTools * Copyright (C) Arik Z.Lakritz, Peter Macko, and David K. Wittenberg * * This file is part of ArikTools. * * ArikTools is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ArikTools 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 ArikTools. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Collapse a two-dimensional array to a one-dimensional one * * @param array the two-dimensional array * @return the corresponding one-dimensional array */ public static float[] collapse(float[][] array) { float[] a = new float[array[0].length * array.length]; int i = 0; for (int x = 0; x < array.length; x++) { for (int y = 0; y < array[x].length; y++) { a[i++] = array[x][y]; } } return a; } }