Java Matrix to Vector matrix2vector(int[][] matrix)

Here you can find the source of matrix2vector(int[][] matrix)

Description

matrixvector

License

Apache License

Declaration

public static int[] matrix2vector(int[][] matrix) 

Method Source Code

//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;
    }
}

Related

  1. matrix2Vector(double[][] m)
  2. matrixToVectorArray(int M, int N, float[][] a, float[] b)
  3. matrixToVectorArray(int M, int N, float[][] a, float[] b)
  4. matrixVector(double[][] w, double[] v)
  5. matrixVectorProductVDw(final double[][] V, final double[] d, final double[] w, final double[] a, int l1, int l2)