Skip to content

Add something like "Zero", "One", "Max" and "Min" traits #42

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

Closed
TonalidadeHidrica opened this issue Sep 11, 2020 · 2 comments
Closed

Add something like "Zero", "One", "Max" and "Min" traits #42

TonalidadeHidrica opened this issue Sep 11, 2020 · 2 comments

Comments

@TonalidadeHidrica
Copy link
Collaborator

I will provide some default implementation for monoid, such as calculating sums, products, maximum or minimum values. I want to implement them for all types available, but currently there are no traits that ensure the existence of additive unit etc.. I suggest creating a new trait that returns such values. The names listed in the title are just examples.

@professor-flux
Copy link

i think implementing traits like multiplicative/additive identity can be useful in many generic functions like binary_exp, (so the end user can implement a wrapper class for 2D vector and implement MulIdentity trait and Mul operator and use the same binary_exp for matrix exp), gcd, ext_gcd, etc.
and we can implement traits for primitive types using macros as
implement_mul_iden!(i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize);

@TonalidadeHidrica
Copy link
Collaborator Author

Resolved by #44.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants