Java Array Copy arrayCopy(double[][] src)

Here you can find the source of arrayCopy(double[][] src)

Description

Copies all rows and columns between two double arrays

License

Open Source License

Parameter

Parameter Description
src a parameter
dest a parameter

Declaration

public static double[][] arrayCopy(double[][] src) 

Method Source Code

//package com.java2s;
/*//from  w w  w. j a va2 s  .c  om
 *  Java Information Dynamics Toolkit (JIDT)
 *  Copyright (C) 2012, Joseph T. Lizier
 *  
 *  This program 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.
 *  
 *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Copies all rows and columns between two double arrays
     * 
     * @param src
     * @param dest
     */
    public static void arrayCopy(double[][] src, double[][] dest) {
        for (int r = 0; r < src.length; r++) {
            System.arraycopy(src[r], 0, dest[r], 0, src[r].length);
        }
    }

    /**
     * Copies all rows and columns between two double arrays
     * 
     * @param src
     * @param dest
     */
    public static double[][] arrayCopy(double[][] src) {
        double[][] dest = new double[src.length][];
        for (int r = 0; r < src.length; r++) {
            dest[r] = new double[src[r].length];
            System.arraycopy(src[r], 0, dest[r], 0, src[r].length);
        }
        return dest;
    }

    /**
     * Copies the required rows and columns between two 
     * double arrays
     * 
     * @param src
     * @param srcStartRow
     * @param srcStartCol
     * @param dest
     * @param destStartRow
     * @param destStartCol
     * @param rows
     * @param cols
     */
    public static void arrayCopy(double[][] src, int srcStartRow, int srcStartCol, double[][] dest,
            int destStartRow, int destStartCol, int rows, int cols) {

        for (int r = 0; r < rows; r++) {
            System.arraycopy(src[srcStartRow + r], srcStartCol, dest[destStartRow + r], destStartCol, cols);
        }
    }

    /**
     * Copies all rows and columns between two int arrays
     * 
     * @param src
     * @param dest
     */
    public static void arrayCopy(int[][] src, int[][] dest) {
        for (int r = 0; r < src.length; r++) {
            System.arraycopy(src[r], 0, dest[r], 0, src[r].length);
        }
    }

    /**
     * Copies the required rows and columns between two 
     * double arrays
     * 
     * @param src
     * @param srcStartRow
     * @param srcStartCol
     * @param dest
     * @param destStartRow
     * @param destStartCol
     * @param rows
     * @param cols
     */
    public static void arrayCopy(int[][] src, int srcStartRow, int srcStartCol, int[][] dest, int destStartRow,
            int destStartCol, int rows, int cols) {

        for (int r = 0; r < rows; r++) {
            System.arraycopy(src[srcStartRow + r], srcStartCol, dest[destStartRow + r], destStartCol, cols);
        }
    }
}

Related

  1. arraycopy(byte[] src, int src_position, byte[] dst, int dst_position, int length)
  2. arrayCopy(byte[] src, int srcOffset, byte[] target, int targetOffset, int length)
  3. arrayCopy(byte[] src, int srcStart, byte[] dest, int destStart, int destBitOffset, int lengthInBits)
  4. arraycopy(char[] A1, int offset1, char[] A2, int offset2, int length)
  5. arrayCopy(char[] chars)
  6. arrayCopy(final byte[] src, final byte[] dest)
  7. arrayCopy(final float[] arrayToCopy)
  8. arrayCopy(int[] array, int i0, int n, boolean isReverse)
  9. arrayCopy(int[] array, int length)