/** * <p> * AddsJava.Util.Random values to each element in the matrix from an uniform distribution.<br> * <br> * a<sub>ij</sub> = a<sub>ij</sub> + U(min,max)<br> * </p> * * @param A The matrix who is to be randomized. Modified * @param min The minimum value each element can be. * @param max The maximum value each element can be.. * @param randJava.Util.Random number generator used to fill the matrix. */ public static void addUniform(DMatrixRMaj A, double min, double max, Java.Util.Random rand) { double[] d = A.getData(); int size = A.NumElements; double r = max - min; for (int i = 0; i < size; i++) { d[i] += r * rand.NextDouble() + min; } }
/** * <p> * Adds random values to each element in the matrix from an uniform distribution.<br> * <br> * a<sub>ij</sub> = a<sub>ij</sub> + U(min,max)<br> * </p> * * @param A The matrix who is to be randomized. Modified * @param min The minimum value each element can be. * @param max The maximum value each element can be.. * @param rand Random number generator used to fill the matrix. */ public static void addUniform(DMatrixRMaj A, double min, double max, IMersenneTwister rand) { double[] d = A.getData(); int size = A.getNumElements(); double r = max - min; for (int i = 0; i < size; i++) { d[i] += r * rand.NextDouble() + min; } }