rust-lang-ja / ac-library-rs

ac-library-rs is a rust port of AtCoder Library (ACL).
Creative Commons Zero v1.0 Universal
225 stars 27 forks source link

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

Closed TonalidadeHidrica closed 1 year ago

TonalidadeHidrica commented 4 years ago

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 commented 3 years ago

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 commented 1 year ago

Resolved by #44.