Commit 1ef9b5a5 authored by Charlie Dorian's avatar Charlie Dorian Committed by Ian Lance Taylor

math/cmplx: make error tolerance test function of expected value

Copy math package CL 12230 to cmplx package.

Change-Id: I3345b782b84b5b98e2b6a60d8774c7e7cede2891
Reviewed-on: https://go-review.googlesource.com/15500Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent bf3bf092
......@@ -438,8 +438,10 @@ func tolerance(a, b, e float64) bool {
d = -d
}
if a != 0 {
e = e * a
// note: b is correct (expected) value, a is actual value.
// make error tolerance a fraction of b, not a.
if b != 0 {
e = e * b
if e < 0 {
e = -e
}
......@@ -460,8 +462,8 @@ func alike(a, b float64) bool {
func cTolerance(a, b complex128, e float64) bool {
d := Abs(a - b)
if a != 0 {
e = e * Abs(a)
if b != 0 {
e = e * Abs(b)
if e < 0 {
e = -e
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment