def testConstantODE2(self):
        iv = np.array([1.0])
        h: np.float = 0.1

        y = odesolvers.ImplicitEulerSolver(constantode, iv, self.t0, self.tn,
                                           h, constantodeJ)

        self.assertEqual(y[0], iv)
        self.assertGreater(y[1], y[0])
    def testStableODE2(self):
        iv = np.array([1.0])
        h: np.float = 0.01

        y = odesolvers.ImplicitEulerSolver(stableode, iv, self.t0, self.tn, h,
                                           stableodeJ)

        self.assertEqual(y[0], iv)
        self.assertLess(y[1], y[0])
    def testMultivariableODE(self):
        iv = np.array([1.0, 2.0])
        h: np.float = 0.01

        y = odesolvers.ImplicitEulerSolver(multivariableode, iv, self.t0,
                                           self.tn, h, multivariableodeJ)

        self.assertEqual(y[0, 0], iv[0])
        self.assertEqual(y[0, 1], iv[1])
        self.assertLess(y[1, 1], y[0, 1])
    def testStiffODE2(self):
        iv = np.array([1.0, 2.0])
        h: np.float = 0.05

        N: np.uint = np.uint(np.ceil((self.tn - self.t0) / h))
        # final step
        y = odesolvers.ImplicitEulerSolver(stiffode, iv, self.t0, self.tn, h,
                                           stiffodeJ)

        self.assertEqual(y[0, 0], iv[0])
        self.assertEqual(y[0, 1], iv[1])
        self.assertLess(np.absolute(y[N, 1] - y[0, 1]), 3)
    def testNewtonItConvergenceFail(self):
        iv = np.array([1.0, 2.0])
        h: np.float = 0.01

        with self.assertRaises(ArithmeticError):
            odesolvers.ImplicitEulerSolver(multivariableode,
                                           iv,
                                           self.t0,
                                           self.tn,
                                           h,
                                           multivariableodeJ,
                                           NEWTITER=0)