fix bugs in Gradient and test

This commit is contained in:
soypat
2022-08-04 11:23:44 -03:00
committed by Dan Kortschak
parent 1fbf8fb724
commit 177c87adcd
2 changed files with 6 additions and 6 deletions

View File

@@ -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)
}
}