def op(i, j, x, y): # scaling = "monic" scaling = "classical" iterator = orthopy.c1.jacobi.Eval((x - y) / (x + y), scaling, 0, 0) val1 = get_nth(iterator, i) # val1 = numpy.polyval(scipy.special.jacobi(i, 0, 0), (x - y) / (x + y)) # treat x==0, y==0 separately if isinstance(val1, numpy.ndarray): idx = numpy.where(numpy.logical_and(x == 0, y == 0))[0] val1[idx] = numpy.polyval(scipy.special.jacobi(i, 0, 0), 0.0) else: if numpy.isnan(val1): val1 = numpy.polyval(scipy.special.jacobi(i, 0, 0), 0.0) iterator = orthopy.c1.jacobi.Eval(1 - 2 * (x + y), scaling, 2 * i + 1, 0) val2 = get_nth(iterator, j) # val2 = numpy.polyval(scipy.special.jacobi(j, 2*i+1, 0), 1-2*(x+y)) flt = numpy.vectorize(float) return flt( numpy.sqrt(2 * i + 1) * val1 * (x + y)**i * numpy.sqrt(2 * j + 2 * i + 2) * val2)
def test_chebyshev2_normal(n, y): x = numpy.array([0, S(1) / 2, 1]) scaling = "normal" y0 = get_nth(orthopy.c1.chebyshev2.Eval(x[0], scaling, symbolic=True), n) assert y0 == y[0] val = get_nth(orthopy.c1.chebyshev2.Eval(x, scaling, symbolic=True), n) assert all(val == y)
def test_chebyshev1_monic(n, y): x = numpy.array([0, Rational(1, 2), 1]) # Test evaluation of one value y0 = get_nth(orthopy.c1.chebyshev1.Eval(x[0], "monic", symbolic=True), n) assert y0 == y[0] # Test evaluation of multiple values val = get_nth(orthopy.c1.chebyshev1.Eval(x, "monic", symbolic=True), n) assert all(val == y)
def test_legendre_monic(scaling, n, y): x = numpy.array([0, S(1) / 2, 1]) # Test evaluation of one value y0 = get_nth(orthopy.c1.legendre.Eval(x[0], scaling, symbolic=True), n) assert y0 == y[0] # Test evaluation of multiple values val = get_nth(orthopy.c1.legendre.Eval(x, scaling, symbolic=True), n) assert all(val == y)
def test_gegenbauer_monic(n, y): x = numpy.array([0, Rational(1, 2), 1]) lmbda = -Rational(1, 2) # Test evaluation of one value y0 = get_nth( orthopy.c1.gegenbauer.Eval(x[0], "monic", lmbda, symbolic=True), n) assert y0 == y[0] # Test evaluation of multiple values val = get_nth(orthopy.c1.gegenbauer.Eval(x, "monic", lmbda, symbolic=True), n) assert all(val == y)
def test_chebyshev2_p11(n, y): x = numpy.array([0, Rational(1, 2), 1]) scaling = "classical" y0 = get_nth(orthopy.c1.chebyshev2.Eval(x[0], scaling, symbolic=True), n) assert y0 == y[0] alpha = Rational(1, 2) assert sympy.binomial(n + alpha, n) == y[2] val = get_nth(orthopy.c1.chebyshev2.Eval(x, scaling, symbolic=True), n) assert all(val == y)
def test_jacobi_monic(scaling, n, y): x = numpy.array([0, S(1) / 2, 1]) alpha = 3 beta = 2 y2 = get_nth( orthopy.c1.jacobi.Eval(x[2], scaling, alpha, beta, symbolic=True), n) assert y2 == y[2] val = get_nth( orthopy.c1.jacobi.Eval(x, scaling, alpha, beta, symbolic=True), n) assert all(val == y)
def test_eval(t, ref, tol=1.0e-14): n = 5 value = get_nth(orthopy.c1.legendre.Eval(t, "monic", symbolic=True), n) assert numpy.all(value == ref) # Evaluating the Legendre polynomial in this way is rather unstable, so don't go too # far with n. approx_ref = numpy.polyval(scipy.special.legendre(n, monic=True), t) assert numpy.all(numpy.abs(value - approx_ref) < tol)
def test_eval(t, ref): n = 5 value = get_nth(orthopy.c1.chebyshev2.Eval(t, "monic", symbolic=True), n) assert numpy.all(value == ref)
def test_eval(t, ref, tol=1.0e-14): n = 5 value = get_nth(orthopy.c1.chebyshev1.Eval(t, "monic"), n) assert numpy.all(value == ref)