def test_s_roots(): weightf = orth.chebys(5).weight_func verify_gauss_quad(orth.s_roots, orth.eval_chebys, weightf, -2., 2., 5) verify_gauss_quad(orth.s_roots, orth.eval_chebys, weightf, -2., 2., 25) verify_gauss_quad(orth.s_roots, orth.eval_chebys, weightf, -2., 2., 100) x, w = orth.s_roots(5, False) y, v, m = orth.s_roots(5, True) assert_allclose(x, y, 1e-14, 1e-14) assert_allclose(w, v, 1e-14, 1e-14) muI, muI_err = integrate.quad(weightf, -2, 2) assert_allclose(m, muI, rtol=muI_err) assert_raises(ValueError, orth.s_roots, 0) assert_raises(ValueError, orth.s_roots, 3.3)
def test_roots_chebys(): weightf = orth.chebys(5).weight_func verify_gauss_quad(sc.roots_chebys, orth.eval_chebys, weightf, -2., 2., 5) verify_gauss_quad(sc.roots_chebys, orth.eval_chebys, weightf, -2., 2., 25) verify_gauss_quad(sc.roots_chebys, orth.eval_chebys, weightf, -2., 2., 100) x, w = sc.roots_chebys(5, False) y, v, m = sc.roots_chebys(5, True) assert_allclose(x, y, 1e-14, 1e-14) assert_allclose(w, v, 1e-14, 1e-14) muI, muI_err = integrate.quad(weightf, -2, 2) assert_allclose(m, muI, rtol=muI_err) assert_raises(ValueError, sc.roots_chebys, 0) assert_raises(ValueError, sc.roots_chebys, 3.3)
def test_chebys(self): S0 = orth.chebys(0) S1 = orth.chebys(1) S2 = orth.chebys(2) S3 = orth.chebys(3) S4 = orth.chebys(4) S5 = orth.chebys(5) assert_array_almost_equal(S0.c, [1], 13) assert_array_almost_equal(S1.c, [1, 0], 13) assert_array_almost_equal(S2.c, [1, 0, -1], 13) assert_array_almost_equal(S3.c, [1, 0, -2, 0], 13) assert_array_almost_equal(S4.c, [1, 0, -3, 0, 1], 13) assert_array_almost_equal(S5.c, [1, 0, -4, 0, 3, 0], 13)
def test_chebys(self): S0 = orth.chebys(0) S1 = orth.chebys(1) S2 = orth.chebys(2) S3 = orth.chebys(3) S4 = orth.chebys(4) S5 = orth.chebys(5) assert_array_almost_equal(S0.c,[1],13) assert_array_almost_equal(S1.c,[1,0],13) assert_array_almost_equal(S2.c,[1,0,-1],13) assert_array_almost_equal(S3.c,[1,0,-2,0],13) assert_array_almost_equal(S4.c,[1,0,-3,0,1],13) assert_array_almost_equal(S5.c,[1,0,-4,0,3,0],13)