GNU bug report logs -
#74031
[PATCH] srfi-64: Accept complex numbers in test-approximate.
Previous Next
Full log
View this message in rfc822 format
Like I wrote in a separate message, I think test-approximate should check the https://en.wikipedia.org/wiki/Euclidean_distance :
(<= (magnitude (- expected value)) epsilon)
For real numbers, it means the same as the current test. It would also work for other types for which the user has defined - and magnitude, like vectors.
I just checked the old impl:
-(define (%test-approximate= error)
- (lambda (value expected)
- (let ((rval (real-part value))
- (ival (imag-part value))
- (rexp (real-part expected))
- (iexp (imag-part expected)))
- (and (>= rval (- rexp error))
- (>= ival (- iexp error))
- (<= rval (+ rexp error))
- (<= ival (+ iexp error))))))
This is still *a* distance (https://en.wikipedia.org/wiki/Chebyshev_distance), and close numbers will be close either way, but speaking as an engineer who uses complex numbers all day, Euclidean distance is the only one I've ever wanted to use.
Regards
lloda
This bug report was last modified 233 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.