/** * <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(FMatrixRMaj A, float min, float max, IMersenneTwister rand) { float[] d = A.getData(); int size = A.getNumElements(); float r = max - min; for (int i = 0; i < size; i++) { d[i] += r * rand.NextFloat() + min; } }