> On 1 Oct 2020, at 15:07, Gilles Sadowski <gillese...@gmail.com> wrote:
> 
> ---CUT---
> more operations for angles and vectors, close equality check for complex 
> numbers
> ---CUT---
> 

There are close equality checks in o.a.c.math3.complex.Complex:

public static boolean equals(Complex x, Complex y, int maxUlps)
public static boolean equals(Complex x, Complex y)
public static boolean equals(Complex x, Complex y, double eps)
public static boolean equalsWithRelativeTolerance(Complex x, Complex y, double 
eps)

However there are many ways to define closeness. Thus this was removed from the 
new numbers Complex class to simplify the API.

I would suggest something more like a user defined closeness operator:

public static boolean equals(Complex x, Complex y, DoubleBiPredicate equal)

There is no primitive specialisation of BiPredicate for double but we could 
declare one.

One issue is that the equality is defined using both real and complex parts. 
Should these be treated with the same closeness test? In addition some values 
such as infinity may have only one infinite component. So are these equal:

(inf + i 3) vs (inf + i 4)
(inf + i 3) vs (-inf + i 3)

Likewise there are multiple possible instances of Complex where isNaN() returns 
true. Currently these situations are not dealt with in the Object.equals method 
of Complex either. That implements a true binary equality using 
doubleToLongBits on each part.

With the large number of permutations this is one to discuss on the dev list.

Alex


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to