/** * Returns new bool matrix with true or false values selected with equal probability. * * @param numRow Number of rows in the new matrix. * @param numCol Number of columns in the new matrix. * @param randJava.Util.Random number generator used to fill the matrix. * @return The randomly generated matrix. */ public static BMatrixRMaj randomBinary(int numRow, int numCol, Java.Util.Random rand) { BMatrixRMaj mat = new BMatrixRMaj(numRow, numCol); setRandomB(mat, rand); return(mat); }
/** * Returns new bool matrix with true or false values selected with equal probability. * * @param numRow Number of rows in the new matrix. * @param numCol Number of columns in the new matrix. * @param rand Random number generator used to fill the matrix. * @return The randomly generated matrix. */ public static BMatrixRMaj randomBinary(int numRow, int numCol, IMersenneTwister rand) { BMatrixRMaj mat = new BMatrixRMaj(numRow, numCol); setRandomB(mat, rand); return(mat); }
/** * <p> * Sets each element in the bool matrix to true or false with equal probability * </p> * * @param mat The matrix who is to be randomized. Modified. * @param randJava.Util.Random number generator used to fill the matrix. */ public static void setRandomB(BMatrixRMaj mat, Java.Util.Random rand) { bool[] d = mat.data; int size = mat.NumElements; for (int i = 0; i < size; i++) { d[i] = rand.NextBoolean(); } }
/** * <p> * Sets each element in the bool matrix to true or false with equal probability * </p> * * @param mat The matrix who is to be randomized. Modified. * @param rand Random number generator used to fill the matrix. */ public static void setRandomB(BMatrixRMaj mat, IMersenneTwister rand) { bool[] d = mat.data; int size = mat.getNumElements(); for (int i = 0; i < size; i++) { d[i] = rand.NextBoolean(); } }
/** * <p> * Checks to see if each element in the two matrices are equal: * a<sub>ij</sub> == b<sub>ij</sub> * <p> * * <p> * NOTE: If any of the elements are NaN then false is returned. If two corresponding * elements are both positive or negative infinity then they are equal. * </p> * * @param a A matrix. Not modified. * @param b A matrix. Not modified. * @return true if identical and false otherwise. */ public static bool isEquals(BMatrixRMaj a, BMatrixRMaj b) { if (a.numRows != b.numRows || a.numCols != b.numCols) { return(false); } int length = a.NumElements; for (int i = 0; i < length; i++) { if (!(a.get(i) == b.get(i))) { return(false); } } return(true); }