Java Matrix Copy matrixCopy(int[][] matrix)

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

Description

matrix Copy

License

Apache License

Declaration

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

Method Source Code


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

import java.util.Arrays;

public class Main {
    public static int[][] matrixCopy(int[][] matrix) {
        if (matrix == null) {
            return null;
        }/*from   ww w . j  a  v  a2  s  .  co  m*/

        int[][] result = new int[matrix.length][];
        for (int i = 0; i < matrix.length; ++i) {
            result[i] = Arrays.copyOf(matrix[i], matrix[i].length);
        }

        return result;
    }
}

Related

  1. copyMatrix(final int rowsCount, final int columnsCount, final double[][] origMatrix)
  2. copyMatrix(float[] origin, float destination[])
  3. copyMatrixBlock(final double[][] src, int i_src, int j_src, final double[][] dest, int i_dest, int j_dest, int rows, int cols)
  4. copyMatrixEliminateRowAndColumn(double[][] matrix, int rowToEliminate, int colToEliminate)
  5. copyMatrixRow(final float[] m_in, final int m_in_off, final int row, final float[] v_out, final int v_out_off)