def test_u_roots(): weightf = orth.chebyu(5).weight_func verify_gauss_quad(orth.u_roots, orth.eval_chebyu, weightf, -1., 1., 5) verify_gauss_quad(orth.u_roots, orth.eval_chebyu, weightf, -1., 1., 25) verify_gauss_quad(orth.u_roots, orth.eval_chebyu, weightf, -1., 1., 100) x, w = orth.u_roots(5, False) y, v, m = orth.u_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, -1, 1) assert_allclose(m, muI, rtol=muI_err) assert_raises(ValueError, orth.u_roots, 0) assert_raises(ValueError, orth.u_roots, 3.3)
def test_roots_chebyu(): weightf = orth.chebyu(5).weight_func verify_gauss_quad(sc.roots_chebyu, orth.eval_chebyu, weightf, -1., 1., 5) verify_gauss_quad(sc.roots_chebyu, orth.eval_chebyu, weightf, -1., 1., 25) verify_gauss_quad(sc.roots_chebyu, orth.eval_chebyu, weightf, -1., 1., 100) x, w = sc.roots_chebyu(5, False) y, v, m = sc.roots_chebyu(5, True) assert_allclose(x, y, 1e-14, 1e-14) assert_allclose(w, v, 1e-14, 1e-14) muI, muI_err = integrate.quad(weightf, -1, 1) assert_allclose(m, muI, rtol=muI_err) assert_raises(ValueError, sc.roots_chebyu, 0) assert_raises(ValueError, sc.roots_chebyu, 3.3)
def test_chebyu(self): U0 = orth.chebyu(0) U1 = orth.chebyu(1) U2 = orth.chebyu(2) U3 = orth.chebyu(3) U4 = orth.chebyu(4) U5 = orth.chebyu(5) assert_array_almost_equal(U0.c, [1], 13) assert_array_almost_equal(U1.c, [2, 0], 13) assert_array_almost_equal(U2.c, [4, 0, -1], 13) assert_array_almost_equal(U3.c, [8, 0, -4, 0], 13) assert_array_almost_equal(U4.c, [16, 0, -12, 0, 1], 13) assert_array_almost_equal(U5.c, [32, 0, -32, 0, 6, 0], 13)
def test_chebyu(self): U0 = orth.chebyu(0) U1 = orth.chebyu(1) U2 = orth.chebyu(2) U3 = orth.chebyu(3) U4 = orth.chebyu(4) U5 = orth.chebyu(5) assert_array_almost_equal(U0.c,[1],13) assert_array_almost_equal(U1.c,[2,0],13) assert_array_almost_equal(U2.c,[4,0,-1],13) assert_array_almost_equal(U3.c,[8,0,-4,0],13) assert_array_almost_equal(U4.c,[16,0,-12,0,1],13) assert_array_almost_equal(U5.c,[32,0,-32,0,6,0],13)
def test_sh_chebyu(self): # U*_n(x) = U_n(2x-1) psub = np.poly1d([2, -1]) Us0 = orth.sh_chebyu(0) Us1 = orth.sh_chebyu(1) Us2 = orth.sh_chebyu(2) Us3 = orth.sh_chebyu(3) Us4 = orth.sh_chebyu(4) Us5 = orth.sh_chebyu(5) use0 = orth.chebyu(0)(psub) use1 = orth.chebyu(1)(psub) use2 = orth.chebyu(2)(psub) use3 = orth.chebyu(3)(psub) use4 = orth.chebyu(4)(psub) use5 = orth.chebyu(5)(psub) assert_array_almost_equal(Us0.c, use0.c, 13) assert_array_almost_equal(Us1.c, use1.c, 13) assert_array_almost_equal(Us2.c, use2.c, 13) assert_array_almost_equal(Us3.c, use3.c, 13) assert_array_almost_equal(Us4.c, use4.c, 12) assert_array_almost_equal(Us5.c, use5.c, 11)
def test_sh_chebyu(self): # U*_n(x) = U_n(2x-1) psub = np.poly1d([2,-1]) Us0 = orth.sh_chebyu(0) Us1 = orth.sh_chebyu(1) Us2 = orth.sh_chebyu(2) Us3 = orth.sh_chebyu(3) Us4 = orth.sh_chebyu(4) Us5 = orth.sh_chebyu(5) use0 = orth.chebyu(0)(psub) use1 = orth.chebyu(1)(psub) use2 = orth.chebyu(2)(psub) use3 = orth.chebyu(3)(psub) use4 = orth.chebyu(4)(psub) use5 = orth.chebyu(5)(psub) assert_array_almost_equal(Us0.c,use0.c,13) assert_array_almost_equal(Us1.c,use1.c,13) assert_array_almost_equal(Us2.c,use2.c,13) assert_array_almost_equal(Us3.c,use3.c,13) assert_array_almost_equal(Us4.c,use4.c,12) assert_array_almost_equal(Us5.c,use5.c,11)