def test_rl_quad(): N = 5 values = [(0.2, 0.3, 0.2949533988361775), (1.2, 4.0, 0.04976184140700821), (1.5, 1.5, 0.1216505480495554)] for (ay, by, exact) in values: qi = rl_quad(N + 1, ay, by) qx = np.array(qi.x) qw = np.array(qi.w) gll_nodes = gll_basis(N).nodes np.testing.assert_almost_equal(gll_nodes, qx) f = lambda x: x ** 4 / np.sqrt((x - ay) ** 2 + by ** 2) est = np.sum(f(qx) * qw) # DUDE 13 digits! np.testing.assert_almost_equal(est, exact, 13)
def test_gll_basis(): bf = gll_basis(9) x_val = 0.9195339081664588138289 * 0.5 + 0.5 x = [x_val, x_val] val = bf.evaluate(8, x_val) np.testing.assert_almost_equal(val, [1.0, 1.0])