Description
Rationale
While coding polynomial computations over differing fields with commons math3 where the field is a generic parameter in the implementation of monomials and polynomials, I coded the comparison with zero and one as coefficient.getField().getZero().equals(coefficient).
With commons-numbers this gets slightly less cumbersome as coefficient.zero().equals(coefficient), but cumbersome and somewhat weird looking it is still.
But the look of it is not the only problem: employing async-profiler I saw that the equals() required a non-negligible amount of CPU power, in particular for the BigFraction field, which in some cases near-duplicates the value to be compared due to calls to negate().
Requirement
- Add a method isZero() to interface Addition which returns true iff the object is semantically equivalent to the object returned by zero().
- Add a method isOne() to interface Multiplication which returns true iff the object is semantically equivalent to the value returned by one().
Attachments
Issue Links
- links to