Java Matrix Copy copyMatrixBlock(final double[][] src, int i_src, int j_src, final double[][] dest, int i_dest, int j_dest, int rows, int cols)

Here you can find the source of copyMatrixBlock(final double[][] src, int i_src, int j_src, final double[][] dest, int i_dest, int j_dest, int rows, int cols)

Description

Copies a block from one matrix to another

License

Open Source License

Parameter

Parameter Description
src source matrix
i_src first row of the source matrix block to copy
j_src first column of the source matrix block to copy
dest destination matrix
i_dest first row of the destination matrix block to be copied to
j_dest first column of the destination matrix block to be copied to
rows number of rows to copy
cols number of columns to copy

Declaration

public static void copyMatrixBlock(final double[][] src, int i_src, int j_src, final double[][] dest,
        int i_dest, int j_dest, int rows, int cols) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   www. j  a  v a  2  s . c  om*/
     * Copies a block from one matrix to another
     * @param src     source matrix
     * @param i_src   first row of the source matrix block to copy
     * @param j_src   first column of the source matrix block to copy
     * @param dest    destination matrix
     * @param i_dest  first row of the destination matrix block to be copied to
     * @param j_dest  first column of the destination matrix block to be copied to
     * @param rows    number of rows to copy
     * @param cols    number of columns to copy
     */
    public static void copyMatrixBlock(final double[][] src, int i_src, int j_src, final double[][] dest,
            int i_dest, int j_dest, int rows, int cols) {
        assert src != null;
        assert dest != null;
        assert src != dest;
        // TODO do all the other safety checks

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                dest[i_dest + i][j_dest + j] = src[i_src + i][j_src + j];
            }
        }
    }
}

Related

  1. copyMatrix(boolean[][] old)
  2. copyMatrix(final double[][] c)
  3. copyMatrix(final double[][] src, final double[][] dest, int n)
  4. copyMatrix(final int rowsCount, final int columnsCount, final double[][] origMatrix)
  5. copyMatrix(float[] origin, float destination[])
  6. copyMatrixEliminateRowAndColumn(double[][] matrix, int rowToEliminate, int colToEliminate)
  7. copyMatrixRow(final float[] m_in, final int m_in_off, final int row, final float[] v_out, final int v_out_off)
  8. matrixCopy(int[][] matrix)