I would like to calculate number of elements in a matrix that are equal to Zero or One. The goal is calculate density of elements in a matrix that are equal to zero or one. I use this to calculate sparseness of the matrix as well.
Generally in Sparse matrix, majority of the elements are ZEROs. But in the matrix I privided has very few Zero and Ones and elements having value 'X' are more in number. Hence I would like to find count of elements having zero and one first. Then I shall use them to calculate Sparseness and Sparse density of the matrix.
The matrix looks like:
\begin{matrix} 1 & 0 & x & x & x & x & 0 & x & x & x & 0 & x & x & x & x & x & x & x\\ x & x & x & x & 0 & x & x & x & x & x & x & x & x & x & 1 & x & x & 0\\ 0 & x & x & x & x & 1 & x & x & x & x & x & 0 & x & x & x & x & x & x\\ \end{matrix}