/** * This {@code SparseBinaryMatrix} will contain the operation of or-ing * the inputMatrix with the contents of this matrix; returning this matrix * as the result. * * @param inputMatrix the matrix containing the "on" bits to or * @return this matrix */ public AbstractSparseBinaryMatrix or(AbstractSparseBinaryMatrix inputMatrix) { int[] mask = inputMatrix.getSparseIndices(); int[] ones = new int[mask.Length]; ArrayUtils.Fill(ones, 1); return(set(mask, ones)); }
/** * 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. * * @param matrix * @return */ 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()); }
/** * 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. * * @param matrix * @return */ public bool any(AbstractSparseBinaryMatrix matrix) { var keySet = getSparseSet(); foreach (int i in matrix.getSparseIndices()) { if (keySet.Contains(i)) { return(true); } } return(false); }