Here you can find the source of matrix2vector(int[][] matrix)
public static int[] matrix2vector(int[][] matrix)
//package com.java2s; //License from project: Apache License public class Main { public static int[] matrix2vector(int[][] matrix) { if (matrix == null || matrix.length <= 0 || matrix[0].length <= 0) { return null; }// w w w . j av a 2 s . c o m int[] vector = new int[matrix.length * matrix[0].length]; int index = 0; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[0].length; j++, index++) { vector[index] = matrix[i][j]; } } return vector; } }