Hipparchus-Math / hipparchus

An efficient, general-purpose mathematics components library in the Java programming language
Apache License 2.0
142 stars 41 forks source link

Complex utility functions if imaginary part is 0 #92

Closed axkr closed 4 years ago

axkr commented 4 years ago

Are there some similar utility functions for the Complex number type as in the Guava DoubleMath utility class, if the imaginary part is 0.0?

isMathematicalInteger https://github.com/google/guava/blob/45958948bea8f7aaf38c1a3dd200ce0263c0bcfa/android/guava/src/com/google/common/math/DoubleMath.java#L286

roundToInt: https://github.com/google/guava/blob/45958948bea8f7aaf38c1a3dd200ce0263c0bcfa/android/guava/src/com/google/common/math/DoubleMath.java#L131

maisonobe commented 4 years ago

For questions, please use the new forum at https://forum.orekit.org/c/hipparchus-usage/.

There are not (yet) similar functions in Complex. We have added quite a large number of functions so Complex now implements the new CalculusFieldElement interface, for the sake of solving issue #67. The closest function to your second need would be round, but it is in the RealFieldElement interface, not in the CalculusFieldElement class. We could move it up as explained in the comment I wrote here.

We could implement the first method directly in Complex, without reference to any higher level interface.