rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
732 stars 135 forks source link

Added real and imaginary parts methods #100

Closed YakoYakoYokuYoku closed 5 years ago

YakoYakoYokuYoku commented 5 years ago

I added them in purpose to match my num-complex pull request.

YakoYakoYokuYoku commented 5 years ago

TODO: Fix this implementation :weary:

cuviper commented 5 years ago

What is your motivating use case for these trait methods? Are you writing generic code that doesn't know whether it has an actual Complex type?

I think this would be better off as a new trait. The default impls you've added to Float are wrong for any type which is not purely real, and we have no way of knowing this from here. Plus, these methods are not really specific to floating point anyway -- for instance Gaussian integers are complex too.

YakoYakoYokuYoku commented 5 years ago

Closing in favor of #101.