Esempio n. 1
0
def _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points):
    infbounds = 0
    if (b != Inf and a != -Inf):
        pass   # standard integration
    elif (b == Inf and a != -Inf):
        infbounds = 1
        bound = a
    elif (b == Inf and a == -Inf):
        infbounds = 2
        bound = 0     # ignored
    elif (b != Inf and a == -Inf):
        infbounds = -1
        bound = b
    else:
        raise RuntimeError, "Infinity comparisons don't work for you."

    if points is None:
        if infbounds == 0:
            return _quadpack._qagse(func,a,b,args,full_output,epsabs,epsrel,limit)
        else:
            return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)
    else:
        if infbounds !=0:
            raise ValueError, "Infinity inputs cannot be used with break points."
        else:
            nl = len(points)
            the_points = numpy.zeros((nl+2,), float)
            the_points[:nl] = points
            return _quadpack._qagpe(func,a,b,the_points,args,full_output,epsabs,epsrel,limit)
Esempio n. 2
0
def _quad(func, a, b, args, full_output, epsabs, epsrel, limit, points):
    infbounds = 0
    if (b != Inf and a != -Inf):
        pass  # standard integration
    elif (b == Inf and a != -Inf):
        infbounds = 1
        bound = a
    elif (b == Inf and a == -Inf):
        infbounds = 2
        bound = 0  # ignored
    elif (b != Inf and a == -Inf):
        infbounds = -1
        bound = b
    else:
        raise RuntimeError("Infinity comparisons don't work for you.")

    if points is None:
        if infbounds == 0:
            return _quadpack._qagse(func, a, b, args, full_output, epsabs,
                                    epsrel, limit)
        else:
            return _quadpack._qagie(func, bound, infbounds, args, full_output,
                                    epsabs, epsrel, limit)
    else:
        if infbounds != 0:
            raise ValueError(
                "Infinity inputs cannot be used with break points.")
        else:
            nl = len(points)
            the_points = numpy.zeros((nl + 2, ), float)
            the_points[:nl] = points
            return _quadpack._qagpe(func, a, b, the_points, args, full_output,
                                    epsabs, epsrel, limit)