Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use better approximately equal algo for Complex
  • Loading branch information
TimToady committed Dec 16, 2015
1 parent a54024a commit aa12a40
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/Complex.pm
Expand Up @@ -437,9 +437,9 @@ multi sub infix:<===>(Complex:D \a, Complex:D \b) returns Bool:D {
a.WHAT =:= b.WHAT && a == b
}

multi sub infix:<β‰…>(Complex:D \a, Complex:D \b) returns Bool:D { .not with a <=> b }
multi sub infix:<β‰…>(Complex:D \a, Num(Real) \b) returns Bool:D { .not with a <=> b }
multi sub infix:<β‰…>(Num(Real) \a, Complex:D \b) returns Bool:D { .not with a <=> b }
multi sub infix:<β‰…>(Complex:D \a, Complex:D \b) returns Bool:D { a.re β‰… b.re && a.im β‰… b.im || a <=> b =:= Same }
multi sub infix:<β‰…>(Complex:D \a, Num(Real) \b) returns Bool:D { a β‰… b.Complex }
multi sub infix:<β‰…>(Num(Real) \a, Complex:D \b) returns Bool:D { a.Complex β‰… b }

# Meaningful only for sorting purposes, of course.
# We delegate to Real::cmp rather than <=> because parts might be NaN.
Expand Down

1 comment on commit aa12a40

@grondilu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have imagined:

multi sub infix:<β‰…>(Complex:D \a, Complex:D \b) returns Bool:D { (a - b).abs β‰… 0 }

Please sign in to comment.