Hipparchus-Math / hipparchus

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

Define interface `Comparable` method `compareTo` as "canonical order" in more `FieldElement` derived classes #274

Closed axkr closed 1 year ago

axkr commented 1 year ago

A Comparable interface should be established for a "canonical order" for more FieldElement derived classes.

The Binary64method already has a Comparable interface:

For the Complexclass I would like to suggest:

public int compareTo(final Complex o) {
    int c = Double.compare(this.getReal(), o.getReal());
    if (c != 0) {
      return c;
    }
    return Double.compare(this.getImaginary(), o.getImaginary());
}