mirror of
https://github.com/golang/go
synced 2024-11-18 09:04:49 -07:00
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/15500 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
bf3bf092d1
commit
1ef9b5a5b9
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user