예제 #1
0
    def test_gegenbauer(self):
        a = 5 * np.random.random() - 0.5
        if np.any(a == 0):
            a = -0.2
        Ca0 = orth.gegenbauer(0, a)
        Ca1 = orth.gegenbauer(1, a)
        Ca2 = orth.gegenbauer(2, a)
        Ca3 = orth.gegenbauer(3, a)
        Ca4 = orth.gegenbauer(4, a)
        Ca5 = orth.gegenbauer(5, a)

        assert_array_almost_equal(Ca0.c, array([1]), 13)
        assert_array_almost_equal(Ca1.c, array([2 * a, 0]), 13)
        assert_array_almost_equal(Ca2.c, array([2 * a * (a + 1), 0, -a]), 13)
        assert_array_almost_equal(
            Ca3.c,
            array([4 * orth.poch(a, 3), 0, -6 * a * (a + 1), 0]) / 3.0, 11)
        assert_array_almost_equal(
            Ca4.c,
            array([
                4 * orth.poch(a, 4), 0, -12 * orth.poch(a, 3), 0, 3 * a *
                (a + 1)
            ]) / 6.0, 11)
        assert_array_almost_equal(
            Ca5.c,
            array([
                4 * orth.poch(a, 5), 0, -20 * orth.poch(a, 4), 0,
                15 * orth.poch(a, 3), 0
            ]) / 15.0, 11)
예제 #2
0
    def test_gegenbauer(self):
        a = 5*rand()-0.5
        if np.any(a==0): a = -0.2
        Ca0 = orth.gegenbauer(0,a)
        Ca1 = orth.gegenbauer(1,a)
        Ca2 = orth.gegenbauer(2,a)
        Ca3 = orth.gegenbauer(3,a)
        Ca4 = orth.gegenbauer(4,a)
        Ca5 = orth.gegenbauer(5,a)

        assert_array_almost_equal(Ca0.c,array([1]),13)
        assert_array_almost_equal(Ca1.c,array([2*a,0]),13)
        assert_array_almost_equal(Ca2.c,array([2*a*(a+1),0,-a]),13)
        assert_array_almost_equal(Ca3.c,array([4*orth.poch(a,3),0,-6*a*(a+1),
                                               0])/3.0,11)
        assert_array_almost_equal(Ca4.c,array([4*orth.poch(a,4),0,-12*orth.poch(a,3),
                                               0,3*a*(a+1)])/6.0,11)
        assert_array_almost_equal(Ca5.c,array([4*orth.poch(a,5),0,-20*orth.poch(a,4),
                                               0,15*orth.poch(a,3),0])/15.0,11)