Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • eigen eigen
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 653
    • Issues 653
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Custom issue tracker
    • Custom issue tracker
  • Merge requests 17
    • Merge requests 17
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • libeigen
  • eigeneigen
  • Issues
  • #426
Closed
Open
Created Dec 04, 2019 by Eigen Bugzilla@eigenbzReporter

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>

Blocking

#814 (closed)

Edited Dec 05, 2019 by Eigen Bugzilla
Assignee
Assign to
Time tracking