def runTest(self): xbase = np.array([0.0, 0.0]) g = np.array([1.0, -1.0]) a = np.array([-2.0, -2.0]) b = np.array([1.0, 2.0]) delta = 5.0 c = -1.0 x = max_step_in_box_and_ball(xbase, c, g, a, b, delta) xtrue = np.array([-2.0, 2.0]) self.assertTrue(np.max(np.abs(x - xtrue)) < 1e-10, 'Wrong step')
def runTest(self): xbase = np.array([0.0, 0.0]) + 1 g = np.array([1.0, -1.0]) a = np.array([-2.0, -2.0]) + 1 b = np.array([1.0, 2.0]) + 1 delta = 5.0 c = 3.0 # may want to max instead x = max_step_in_box_and_ball(xbase, c, g, a, b, delta) xtrue = np.array([1.0, -2.0]) + 1 self.assertTrue(np.max(np.abs(x - xtrue)) < 1e-10, 'Wrong step')
def runTest(self): xbase = np.array([0.0, 0.0, 0.0]) g = np.array([-1.0, -1.0, -1.0]) a = np.array([-2.0, -2.0, -2.0]) b = np.array([0.9, 0.1, 5.0]) delta = sqrt(3.0) c = -1.0 # may want to max instead x = max_step_in_box_and_ball(xbase, c, g, a, b, delta) xtrue = np.array([0.9, 0.1, sqrt(3.0 - 0.81 - 0.01)]) print(x) self.assertTrue(np.max(np.abs(x - xtrue)) < 1e-10, 'Wrong step')