Java Array Deep Copy deepArrayCopy(double[][] original)

Here you can find the source of deepArrayCopy(double[][] original)

Description

deep Array Copy

License

Open Source License

Declaration

public static double[][] deepArrayCopy(double[][] original) 

Method Source Code

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

import java.util.Arrays;

public class Main {
    public static double[][] deepArrayCopy(double[][] original) {
        /*double[][] copy = original.clone();
        for (int i = 0; i < copy.length; i++) 
        {/*from w  w w .  j av a 2s . c o  m*/
            copy[i] = copy[i].clone();
        }*/

        double[][] copy = new double[original.length][original[0].length];

        for (int i = 0; i < copy.length; i++) {
            copy[i] = Arrays.copyOf(original[i], original[i].length);
        }

        return copy;
    }

    public static float[][] deepArrayCopy(float[][] original) {
        /*double[][] copy = original.clone();
        for (int i = 0; i < copy.length; i++) 
        {
            copy[i] = copy[i].clone();
        }*/

        float[][] copy = new float[original.length][original[0].length];

        for (int i = 0; i < copy.length; i++) {
            copy[i] = Arrays.copyOf(original[i], original[i].length);
        }

        return copy;
    }
}

Related

  1. deep_copy(int M[][])
  2. deepArrayCopy(double[][] original)
  3. deepArrayCopy(double[][] original)
  4. deepClone(double[][] ary)
  5. deepClone(int[][] source)