def test_ts_roots(): weightf = orth.sh_chebyt(5).weight_func verify_gauss_quad(orth.ts_roots, orth.eval_sh_chebyt, weightf, 0.0, 1.0, 5) verify_gauss_quad(orth.ts_roots, orth.eval_sh_chebyt, weightf, 0.0, 1.0, 25) verify_gauss_quad(orth.ts_roots, orth.eval_sh_chebyt, weightf, 0.0, 1.0, 100, atol=1e-13) x, w = orth.ts_roots(5, False) y, v, m = orth.ts_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, 0, 1) assert_allclose(m, muI, rtol=muI_err) assert_raises(ValueError, orth.ts_roots, 0) assert_raises(ValueError, orth.ts_roots, 3.3)
def test_roots_sh_chebyt(): weightf = orth.sh_chebyt(5).weight_func verify_gauss_quad(sc.roots_sh_chebyt, sc.eval_sh_chebyt, weightf, 0., 1., 5) verify_gauss_quad(sc.roots_sh_chebyt, sc.eval_sh_chebyt, weightf, 0., 1., 25) verify_gauss_quad(sc.roots_sh_chebyt, sc.eval_sh_chebyt, weightf, 0., 1., 100, atol=1e-13) x, w = sc.roots_sh_chebyt(5, False) y, v, m = sc.roots_sh_chebyt(5, True) assert_allclose(x, y, 1e-14, 1e-14) assert_allclose(w, v, 1e-14, 1e-14) muI, muI_err = integrate.quad(weightf, 0, 1) assert_allclose(m, muI, rtol=muI_err) assert_raises(ValueError, sc.roots_sh_chebyt, 0) assert_raises(ValueError, sc.roots_sh_chebyt, 3.3)
def test_sh_chebyt(self): # T*_n(x) = T_n(2x-1) psub = np.poly1d([2, -1]) Ts0 = orth.sh_chebyt(0) Ts1 = orth.sh_chebyt(1) Ts2 = orth.sh_chebyt(2) Ts3 = orth.sh_chebyt(3) Ts4 = orth.sh_chebyt(4) Ts5 = orth.sh_chebyt(5) tse0 = orth.chebyt(0)(psub) tse1 = orth.chebyt(1)(psub) tse2 = orth.chebyt(2)(psub) tse3 = orth.chebyt(3)(psub) tse4 = orth.chebyt(4)(psub) tse5 = orth.chebyt(5)(psub) assert_array_almost_equal(Ts0.c, tse0.c, 13) assert_array_almost_equal(Ts1.c, tse1.c, 13) assert_array_almost_equal(Ts2.c, tse2.c, 13) assert_array_almost_equal(Ts3.c, tse3.c, 13) assert_array_almost_equal(Ts4.c, tse4.c, 12) assert_array_almost_equal(Ts5.c, tse5.c, 12)
def test_sh_chebyt(self): # T*_n(x) = T_n(2x-1) psub = np.poly1d([2,-1]) Ts0 = orth.sh_chebyt(0) Ts1 = orth.sh_chebyt(1) Ts2 = orth.sh_chebyt(2) Ts3 = orth.sh_chebyt(3) Ts4 = orth.sh_chebyt(4) Ts5 = orth.sh_chebyt(5) tse0 = orth.chebyt(0)(psub) tse1 = orth.chebyt(1)(psub) tse2 = orth.chebyt(2)(psub) tse3 = orth.chebyt(3)(psub) tse4 = orth.chebyt(4)(psub) tse5 = orth.chebyt(5)(psub) assert_array_almost_equal(Ts0.c,tse0.c,13) assert_array_almost_equal(Ts1.c,tse1.c,13) assert_array_almost_equal(Ts2.c,tse2.c,13) assert_array_almost_equal(Ts3.c,tse3.c,13) assert_array_almost_equal(Ts4.c,tse4.c,12) assert_array_almost_equal(Ts5.c,tse5.c,12)