rust-num / num-complex

Complex numbers for Rust
Apache License 2.0
232 stars 50 forks source link

Add a ComplexFloat trait #53

Closed YakoYakoYokuYoku closed 3 years ago

YakoYakoYokuYoku commented 5 years ago

Following my attempts to tackle this issue, I've found an idea that @aplund has purposed may be the solution:

Also, I think Complex itself should be a trait rather than a concrete type given that Floats (i.e. Reals) and Integers are traits.

This wasn't a good plan to do at first considering that creating the Complex<T> trait conflicts in every way with the widely adopted Complex<T> struct type. So we need another name and to separate the trait, and I've come with it:

:tada: ComplexFloat :tada:

So why ComplexFloat and not ComplexNumber or ComplexFooBar? The answer is, as obvious as it sounds, that the name implies that the methods that are employed takes complex numbers with real and imaginary parts that are floating point numbers. The trait also has an associated named Output so if we want to bound the first with a Self we can use Output to control the output type of some methods e.g. the re() outputs a Float no matter what if you implemented on a f64 or a Complex<U>. The name also leaves room for a future ComplexInteger trait that has methods for Gaussian Integers.

As a note: Huge shoutout to @aplund for suggesting the idea.

YakoYakoYokuYoku commented 5 years ago

Successfully updated to 0.2.3 :wrench:

YakoYakoYokuYoku commented 5 years ago

fix #2

cc @cuviper

obsgolem commented 3 years ago

@YakoYakoYokuYoku are you still working on this? If not I would be willing to take over trying to get this in.

YakoYakoYokuYoku commented 3 years ago

I left this for two years already because it hasn't got any review (no hard feelings to the maintainers) and failed earlier. Still I'm interested for a trait that implements Float functionalities while excluding PartialOrd and similar. You are free to work upon this.