Esempio n. 1
0
        /**
         * <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();
            }
        }
Esempio n. 2
0
        /**
         * <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.getNumElements();

            for (int i = 0; i < length; i++)
            {
                if (!(a.get(i) == b.get(i)))
                {
                    return(false);
                }
            }

            return(true);
        }