Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement reduce algorithm #4

Open
BenBrock opened this issue Sep 9, 2022 · 0 comments
Open

Implement reduce algorithm #4

BenBrock opened this issue Sep 9, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@BenBrock
Copy link
Collaborator

BenBrock commented Sep 9, 2022

We should implement a reduce algorithm that will reduce a grb::vector to a single value or reduce a grb::matrix to a single value, or vector by row or column.

We had a long discussion in this week's meeting about the API for reduce, and whether to

  1. Default an initial value to T{}, as in std::reduce
  2. Always require an initial value
  3. Default the initial value to grb::monoid_traits<Fn, T>::identity() when the binary operator passed in is a monoid.

At some point we should implement this full algorithm, but for now I am leaving this unimplemented as it is fairly trivial to use std::reduce at the moment, as shown below.

grb::matrix<float> x = ...;
grb::values_view view(x);
float sum = std::reduce(view.begin(), view.end(), float(0), grb::plus{});
@BenBrock BenBrock self-assigned this Sep 9, 2022
@BenBrock BenBrock added the enhancement New feature or request label Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant