mirror of
https://github.com/gonum/gonum.git
synced 2025-10-06 07:37:03 +08:00
fix bugs in Gradient and test
This commit is contained in:
@@ -306,8 +306,8 @@ func TestDivergence(t *testing.T) {
|
||||
|
||||
func TestGradient(t *testing.T) {
|
||||
const (
|
||||
tol = 1e-12
|
||||
h = 1e-4
|
||||
tol = 1e-6
|
||||
h = 1e-5
|
||||
)
|
||||
step := Vec{X: h, Y: h, Z: h}
|
||||
rnd := rand.New(rand.NewSource(1))
|
||||
@@ -316,7 +316,7 @@ func TestGradient(t *testing.T) {
|
||||
p := randomVec(rnd)
|
||||
got := Gradient(p, step, test.field)
|
||||
want := test.gradient(p)
|
||||
if vecApproxEqual(got, want, tol) {
|
||||
if !vecApproxEqual(got, want, tol) {
|
||||
t.Errorf("result out of tolerance. got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user