Here you can find the source of shuffle(double[][] kernel, long seed)
Parameter | Description |
---|
public static double[][] shuffle(double[][] kernel, long seed)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.Collections; import java.util.Random; public class Main { /**// www .j a v a 2 s. co m * Shuffle a kernel matrix with seed to initialize the Random object * * @param kernel, 2D matrix of doubles * @param seed, for the Random object * @return the shuffled kernel matrix */ public static double[][] shuffle(double[][] kernel, long seed) { Double[][] kernelDouble = convert2DoubleObjects(kernel); for (int i = 0; i < kernel.length; i++) { Collections.shuffle(Arrays.asList(kernelDouble[i]), new Random(seed)); } Collections.shuffle(Arrays.asList(kernelDouble), new Random(seed)); return convert2DoublePrimitives(kernelDouble); } private static Double[][] convert2DoubleObjects(double[][] kernel) { Double[][] kernelDouble = new Double[kernel.length][kernel[0].length]; for (int i = 0; i < kernel.length; i++) { for (int j = 0; j < kernel[i].length; j++) { kernelDouble[i][j] = new Double(kernel[i][j]); } } return kernelDouble; } private static double[][] convert2DoublePrimitives(Double[][] kernelDouble) { double[][] kernel = new double[kernelDouble.length][kernelDouble[0].length]; for (int i = 0; i < kernelDouble.length; i++) { for (int j = 0; j < kernelDouble[i].length; j++) { kernel[i][j] = kernelDouble[i][j].doubleValue(); } } return kernel; } }