mirror of
https://github.com/gonum/gonum.git
synced 2025-10-05 23:26:52 +08:00
optimize/functions: fix BrownBadlyScaled for BFGS and LBFGS tests
With the fused operation, f3 is calculated to -9e-17 rather than zero, allowing another iteration, which fails to progress due to underflow.
This commit is contained in:
@@ -553,7 +553,7 @@ func (BrownBadlyScaled) Grad(grad, x []float64) {
|
||||
|
||||
f1 := x[0] - 1e6
|
||||
f2 := x[1] - 2e-6
|
||||
f3 := x[0]*x[1] - 2
|
||||
f3 := float64(x[0]*x[1]) - 2 // Prevent fused multiply subtract.
|
||||
grad[0] = 2*f1 + 2*f3*x[1]
|
||||
grad[1] = 2*f2 + 2*f3*x[0]
|
||||
}
|
||||
|
Reference in New Issue
Block a user