Use nnz to implement sum over bool arrays

This minor change results in about 1.5x - 2x speedup and smaller memory footprint.
Merge pull request #5288 from lindahua/dh/sumbool

Use nnz to implement sum over bool arrays