Ejemplo n.º 1
0
    def test_reverse():
        def fun(x):
            return x[0] + x[1]**2 + x[2]**3

        htrue = np.array([0., 2., 18.])
        h_fun = nd.Hessdiag(fun, method='reverse')
        hd = h_fun([1, 2, 3])
        assert_allclose(hd, htrue)
Ejemplo n.º 2
0
 def test_reverse():
     def fun(x):
         return x[0] + x[1] ** 2 + x[2] ** 3
     htrue = np.array([0., 2., 18.])
     Hfun = nd.Hessdiag(fun, method='reverse')
     hd = Hfun([1, 2, 3])
     _error = hd - htrue
     assert_array_almost_equal(hd, htrue)
Ejemplo n.º 3
0
    def test_forward():
        def fun(x):
            return x[0] + x[1]**2 + x[2]**3

        htrue = np.array([0., 2., 18.])
        h_fun = nd.Hessdiag(fun)
        hd = h_fun([1, 2, 3])

        assert_allclose(hd, htrue)