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

Feature request: Recip trait #34

Closed
clarfonthey opened this issue Feb 11, 2018 · 2 comments · Fixed by #37
Closed

Feature request: Recip trait #34

clarfonthey opened this issue Feb 11, 2018 · 2 comments · Fixed by #37

Comments

@clarfonthey
Copy link
Contributor

Essentially, a pair to Neg for multiplication. Anything which can have its reciprocal taken would implement this. Useful in the context of Mul + Recip + One, for example.

@cuviper
Copy link
Member

cuviper commented Feb 12, 2018

Sure, I could see this applicable to floating point, Complex, and Ratio at least.

It may also be useful for stuff like modular arithmetic and square matrices, although it would more often be called an "inverse" in those settings. Those may also want more control of failure modes, since it's not as simple as division by zero -- maybe with try/checked variants?

@clarfonthey
Copy link
Contributor Author

@cuviper I agree, and while Inv might be a better name, recip is already used for most numbers and may be best. Also, even though "reciprocal matrix" is weird to say, it's not unheard of.

bors bot added a commit that referenced this issue Feb 27, 2018
37: Add Inv and Pow traits. r=cuviper a=clarcharr

This is not a breaking change, and closes #34 and #38.

This doesn't add any impls for the other `num` crates, just floats with `std` enabled. The trait has to be added before those other crates can be updated.
@bors bors bot closed this as completed in #37 Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants