diff --git a/lib/pure/complex.nim b/lib/pure/complex.nim index c06451ca8c..df08ace723 100755 --- a/lib/pure/complex.nim +++ b/lib/pure/complex.nim @@ -10,36 +10,66 @@ ## This module implements complex numbers. - {.push checks:off, line_dir:off, stack_trace:off, debugger:off.} # the user does not want to trace a part # of the standard library! + import math + +const + EPS = 5.0e-6 ## Epsilon used for float comparisons (should be smaller + ## if float is really float64, but w/ the current version + ## it seems to be float32?) + type - TComplex* = tuple[re, im: float] + TComplex* = tuple[re, im: float] ## a complex number, consisting of a real and an imaginary part proc `==` *(x, y: TComplex): bool = ## Compare two complex numbers `x` and `y` for equality. result = x.re == y.re and x.im == y.im +proc `=~` *(x, y: TComplex): bool = + ## Compare two complex numbers `x` and `y` approximately. + result = abs(x.re-y.re)