Behavior of sum() for Matrix<bool> is unexpected and confusing
Submitted by iv0..@..il.com
Assigned to Nobody
Link to original bugzilla bug (#426)
Version: 3.0
Description
When using the .sum() method on a Matrix<bool> my code compiles and runs perfectly. However, it did not do what I'd expect, e.g.,
smaller.any(): 1 1 1 0 0 1
smaller.any().sum(): 1
Coming from Matlab, I had expected sum() to add all the true values as integer (where true is 1):
smaller.any().sum(): 4
What I had to use was count(),
smaller.any().count(): 4
Now, sum() works more like any()
Proposed solutions:
- remove sum() for Matrix<bool> to avoid confusing (so it doesn't compile at all)
- forward sum() to count(), only for Matrix<bool>