Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • $\begingroup$ In case of your matrix, Plus@@Flatten[binarym] should work. There may be faster ways using Trace or similar. Please note that your outer round parentheses do not actually do anything. $\endgroup$ Commented Jan 2, 2018 at 3:12
  • 3
    $\begingroup$ Count can take a level specification (say 2, for a matrix): Count[binarym, 0, 2], while something like Total[1 - binarym, 2] might be faster in some cases. $\endgroup$ Commented Jan 2, 2018 at 3:12
  • 1
    $\begingroup$ Select all the zeros and then find out how many of them there are: Length@Select[Flatten[binarym], # == 0 &] This gives 17, which is the expected answer. $\endgroup$ Commented Jan 2, 2018 at 3:14
  • $\begingroup$ Times @@ Dimensions[binarym] - Total@Flatten@binarym $\endgroup$ Commented Jan 2, 2018 at 3:25
  • $\begingroup$ Closely related: (9637), (38624), (157222). Possibly of interest: (19357) $\endgroup$ Commented Jan 3, 2018 at 16:54