def test_gq_integrate_2d(): from quadrature import GQIntegrate gqi = GQIntegrate() func = lambda x,y: 2*x*x + y*y intf = lambda x,y: 2/3*x**3*y + 1/3*y**3*x x1, x2, y1, y2 = numpy.random.rand(4) ref = (intf(x2,y2) - intf(x1,y2)) - (intf(x2,y1) - intf(x1,y1)) aa_equal(ref, gqi.gq_integrate_2d(x1, x2, y1, y2, func), 15)
def test_gq_integrate_legendre(): from quadrature import GQIntegrate gqi = GQIntegrate() func = lambda x: 2*x*x intf = lambda x: 2/3*x**3 x1, x2 = numpy.random.rand(2) ref = intf(x2) - intf(x1) aa_equal(ref, gqi.gq_integrate(x1, x2, func, qtype='legendre'), 15)