Exemplo n.º 1
0
 /// <summary>
 /// This <see cref="SparseBinaryMatrix"/> will contain the operation of or-ing the inputMatrix with the contents of this matrix; returning this matrix as the result.
 /// </summary>
 /// <param name="inputMatrix">the matrix containing the "on" bits to or</param>
 /// <returns>this matrix</returns>
 public AbstractSparseBinaryMatrix Or(AbstractSparseBinaryMatrix inputMatrix)
 {
     int[] mask = inputMatrix.GetSparseIndices();
     int[] ones = new int[mask.Length];
     ArrayUtils.Fill(ones, 1);
     return(set(mask, ones));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns true if the on bits of the specified matrix are matched by the on bits of this matrix. It is allowed that this matrix have more on bits than the specified matrix.
        /// </summary>
        /// <param name="matrix"></param>
        /// <returns></returns>
        public bool All(AbstractSparseBinaryMatrix matrix)
        {
            var  sparseSet = GetSparseSet();
            bool hasAll    = matrix.GetSparseIndices().All(itm2 => sparseSet.Contains(itm2));

            return(hasAll);
            //return getSparseSet().Contains(
            //    containsAll(matrix.getSparseIndices());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns true if any of the on bits of the specified matrix are matched by the on bits of this matrix. It is allowed that this matrix have more on bits than the specified matrix.
        /// </summary>
        /// <param name="matrix"></param>
        /// <returns></returns>
        public bool Any(AbstractSparseBinaryMatrix matrix)
        {
            var keySet = GetSparseSet();

            foreach (int i in matrix.GetSparseIndices())
            {
                if (keySet.Contains(i))
                {
                    return(true);
                }
            }

            return(false);
        }