Beispiel #1
0
 def runTest(self):
     n = 4
     nvals = n*(n+1)//2
     hess = Hessian(n)
     self.assertEqual(hess.shape(), (nvals,), 'Wrong shape for initialisation')
     self.assertEqual(hess.dim(), n, 'Wrong dimension')
     self.assertEqual(len(hess), nvals, 'Wrong length')
     self.assertTrue(np.all(hess.upper_triangular() == np.zeros((nvals,))), 'Wrong initialised values')
Beispiel #2
0
 def runTest(self):
     n = 5
     nvals = n*(n+1)//2
     x = np.arange(nvals, dtype=np.float)
     hess = Hessian(n, vals=x)
     self.assertEqual(hess.shape(), (nvals,), 'Wrong shape for initialisation')
     self.assertEqual(hess.dim(), n, 'Wrong dimension')
     self.assertEqual(len(hess), nvals, 'Wrong length')
     self.assertTrue(np.all(hess.upper_triangular() == x), 'Wrong initialised values')
Beispiel #3
0
 def runTest(self):
     n = 3
     nvals = n*(n+1)//2
     A = np.arange(n**2, dtype=np.float).reshape((n,n))
     hess = Hessian(n, vals=A+A.T)  # force symmetric
     self.assertEqual(hess.shape(), (nvals,), 'Wrong shape for initialisation')
     self.assertEqual(hess.dim(), n, 'Wrong dimension')
     self.assertEqual(len(hess), nvals, 'Wrong length')
     self.assertTrue(np.all(hess.upper_triangular() == np.array([0.0, 4.0, 8.0, 8.0, 12.0, 16.0])),
                     'Wrong initialised values')