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
Monoid and Abelian #134
Monoid and Abelian #134
Conversation
The commits just above introduces the For the standard fn group_arranged<L>(&self, logic: L) -> ...
{
self.group_solve(move |key, input, output, change| {
logic(key, input, change);
change.extend(output.drain(..).map(|(x,d)| (x,-d)));
consolidate(change);
})
} However, the For example, in something like shortest path computation this difference type may track the shortest path (min, rather than sum) and the update rule just considers whether we need an updated min as output, rather than attempting to subtract the old min from the new min (won't work). // blah blah collections
.group_solve(|_key, input, output, updates| {
if output.is_empty() || input[0].1 < output[0].1 {
updates.push(((), input[0].1));
}
}) A new |
That should be |
This shifts the
Diff
trait to be an alias ofAbelian
, corresponding to an Abelian (commutative) group. There is also aMonoid
trait corresponding to a commutative monoid.Abelian
isMonoid
with the addition of theSub
andNeg
traits.In many cases
Monoid
is sufficient, andAbelian
is only required where subtraction is needed. Operators likejoin
do not require subtraction, thoughantijoin
does in its current implementation.More generally, we should think about shifting some of the uses of negation to other forms. Iteration requires negation to correct for its initial input, but this is only required when we have an initial input and not otherwise.
cc @eoxxs