def test_ps_roots(): weightf = orth.sh_legendre(5).weight_func verify_gauss_quad(orth.ps_roots, orth.eval_sh_legendre, weightf, 0., 1., 5) verify_gauss_quad(orth.ps_roots, orth.eval_sh_legendre, weightf, 0., 1., 25, atol=1e-13) verify_gauss_quad(orth.ps_roots, orth.eval_sh_legendre, weightf, 0., 1., 100, atol=1e-12) x, w = orth.ps_roots(5, False) y, v, m = orth.ps_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.ps_roots, 0) assert_raises(ValueError, orth.ps_roots, 3.3)
def test_ps_roots(): weightf = orth.sh_legendre(5).weight_func verify_gauss_quad(orth.ps_roots, orth.eval_sh_legendre, weightf, 0.0, 1.0, 5) verify_gauss_quad(orth.ps_roots, orth.eval_sh_legendre, weightf, 0.0, 1.0, 25, atol=1e-13) verify_gauss_quad(orth.ps_roots, orth.eval_sh_legendre, weightf, 0.0, 1.0, 100, atol=1e-12) x, w = orth.ps_roots(5, False) y, v, m = orth.ps_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.ps_roots, 0) assert_raises(ValueError, orth.ps_roots, 3.3)
def test_sh_legendre(self): # P*_n(x) = P_n(2x-1) psub = np.poly1d([2, -1]) Ps0 = orth.sh_legendre(0) Ps1 = orth.sh_legendre(1) Ps2 = orth.sh_legendre(2) Ps3 = orth.sh_legendre(3) Ps4 = orth.sh_legendre(4) Ps5 = orth.sh_legendre(5) pse0 = orth.legendre(0)(psub) pse1 = orth.legendre(1)(psub) pse2 = orth.legendre(2)(psub) pse3 = orth.legendre(3)(psub) pse4 = orth.legendre(4)(psub) pse5 = orth.legendre(5)(psub) assert_array_almost_equal(Ps0.c, pse0.c, 13) assert_array_almost_equal(Ps1.c, pse1.c, 13) assert_array_almost_equal(Ps2.c, pse2.c, 13) assert_array_almost_equal(Ps3.c, pse3.c, 13) assert_array_almost_equal(Ps4.c, pse4.c, 12) assert_array_almost_equal(Ps5.c, pse5.c, 12)
def test_sh_legendre(self): # P*_n(x) = P_n(2x-1) psub = np.poly1d([2,-1]) Ps0 = orth.sh_legendre(0) Ps1 = orth.sh_legendre(1) Ps2 = orth.sh_legendre(2) Ps3 = orth.sh_legendre(3) Ps4 = orth.sh_legendre(4) Ps5 = orth.sh_legendre(5) pse0 = orth.legendre(0)(psub) pse1 = orth.legendre(1)(psub) pse2 = orth.legendre(2)(psub) pse3 = orth.legendre(3)(psub) pse4 = orth.legendre(4)(psub) pse5 = orth.legendre(5)(psub) assert_array_almost_equal(Ps0.c,pse0.c,13) assert_array_almost_equal(Ps1.c,pse1.c,13) assert_array_almost_equal(Ps2.c,pse2.c,13) assert_array_almost_equal(Ps3.c,pse3.c,13) assert_array_almost_equal(Ps4.c,pse4.c,12) assert_array_almost_equal(Ps5.c,pse5.c,12)