
˽Xc           @` s5  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l	 m
 Z
 d  d l	 m Z d  d l m Z d d d	 d
 d d d d g Z d e f d     YZ d   Z e   e _ d d d  Z d e d  Z d d d d e d d  Z d   Z d d d d d  Z d   Z d d d d d  Z d d e d   Z d!   Z d"   Z  d#   Z! d d$ d$ e d% e d&  Z" i d d' d d g d d( f d 6d d) d d* d g d d+ f d' 6d) d, d d) d) d g d- d. f d) 6d' d/ d0 d1 d( d1 d0 g d2 d3 f d* 6d d4 d5 d6 d d d6 d5 g d7 d8 f d 6d d9 d: d; d< d= d< d; d: g d> d? f d@ 6d0 dA dB dC dD dE dE dD dC dB g dF dG f d0 6d* dH dI dJ dK dL dM dL dK dJ dI g	 dN dO f d, 6dP dQ dR dS dT dU dV dV dU dT dS dR g
 dW dX f dP 6d dY dZ d[ d\ d] d^ d_ d^ d] d\ d[ dZ g d` da f d% 6db dc dd de df dg dh di di dh dg df de dd g dj dk f db 6d dl dm dn do dp dq dr ds dr dq dp do dn dm g dt du f d( 6dv dw dx dy dz d{ d| d} d~ d~ d} d| d{ dz dy dx g d d f dv 6d0 d d d d d d d d d d d d d d d d g d d f d 6Z# d  d  Z$ d S(   i    (   t   divisiont   print_functiont   absolute_importN(   t   trapz(   t   roots_legendre(   t   gammaln(   t   xranget
   fixed_quadt
   quadraturet   rombergR   t   simpst   rombt   cumtrapzt   newton_cotest   AccuracyWarningc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR      s   c         C` s8   |  t  j k r t  j |  St |   t  j |  <t  j |  S(   sX   
    Cache roots_legendre results to speed up calls of the fixed_quad
    function.
    (   t   _cached_roots_legendret   cacheR   (   t   n(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR      s    i   c         C` s   t  |  \ } } t j |  } t j |  s? t j |  rN t d   n  | | | d d | } | | d t j | |  | |  d d d f S(   s  
    Compute a definite integral using fixed-order Gaussian quadrature.

    Integrate `func` from `a` to `b` using Gaussian quadrature of
    order `n`.

    Parameters
    ----------
    func : callable
        A Python function or method to integrate (must accept vector inputs).
        If integrating a vector-valued function, the returned array must have
        shape ``(..., len(x))``.
    a : float
        Lower limit of integration.
    b : float
        Upper limit of integration.
    args : tuple, optional
        Extra arguments to pass to function, if any.
    n : int, optional
        Order of quadrature integration. Default is 5.

    Returns
    -------
    val : float
        Gaussian quadrature approximation to the integral
    none : None
        Statically returned value of None


    See Also
    --------
    quad : adaptive quadrature using QUADPACK
    dblquad : double integrals
    tplquad : triple integrals
    romberg : adaptive Romberg quadrature
    quadrature : adaptive Gaussian quadrature
    romb : integrators for sampled data
    simps : integrators for sampled data
    cumtrapz : cumulative integration for sampled data
    ode : ODE integrator
    odeint : ODE integrator

    s8   Gaussian quadrature is only available for finite limits.i   g       @t   axisiN(   R   t   npt   realt   isinft
   ValueErrort   sumt   None(   t   funct   at   bt   argsR   t   xt   wt   y(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR   #   s    ,c         ` s1   | r    f d   } n    f d   } | S(   so  Vectorize the call to a function.

    This is an internal utility function used by `romberg` and
    `quadrature` to create a vectorized version of a function.

    If `vec_func` is True, the function `func` is assumed to take vector
    arguments.

    Parameters
    ----------
    func : callable
        User defined function.
    args : tuple, optional
        Extra arguments for the function.
    vec_func : bool, optional
        True if the function func takes vector arguments.

    Returns
    -------
    vfunc : callable
        A function that will take a vector argument and return the
        result.

    c         ` s    |     S(   N(    (   R   (   R   R   (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyt   vfuncr   s    c         ` s   t  j |   r  |     St  j |   }   |  d    } t |   } t | d t |   } t  j | f d | } | | d <x. t d |  D] }  |  |    | | <q W| S(   Ni    t   dtypei   (   R   t   isscalart   asarrayt   lent   getattrt   typet   emptyR   (   R   t   y0R   R#   t   outputt   i(   R   R   (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR"   u   s    
(    (   R   R   t   vec_funcR"   (    (   R   R   s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyt
   vectorize1X   s    g"\O>i2   i   c	         C` s   t  | t  s | f } n  t |  | d | }	 t j }
 t j } t | d |  } x t | | d  D]^ } t |	 | | d |  d } t | |
  } | }
 | | k  s | | t |
  k  ri Pqi qi Wt	 j
 d | | f t  |
 | f S(   s  
    Compute a definite integral using fixed-tolerance Gaussian quadrature.

    Integrate `func` from `a` to `b` using Gaussian quadrature
    with absolute tolerance `tol`.

    Parameters
    ----------
    func : function
        A Python function or method to integrate.
    a : float
        Lower limit of integration.
    b : float
        Upper limit of integration.
    args : tuple, optional
        Extra arguments to pass to function.
    tol, rtol : float, optional
        Iteration stops when error between last two iterates is less than
        `tol` OR the relative change is less than `rtol`.
    maxiter : int, optional
        Maximum order of Gaussian quadrature.
    vec_func : bool, optional
        True or False if func handles arrays as arguments (is
        a "vector" function). Default is True.
    miniter : int, optional
        Minimum order of Gaussian quadrature.

    Returns
    -------
    val : float
        Gaussian quadrature approximation (within tolerance) to integral.
    err : float
        Difference between last two estimates of the integral.

    See also
    --------
    romberg: adaptive Romberg quadrature
    fixed_quad: fixed-order Gaussian quadrature
    quad: adaptive quadrature using QUADPACK
    dblquad: double integrals
    tplquad: triple integrals
    romb: integrator for sampled data
    simps: integrator for sampled data
    cumtrapz: cumulative integration for sampled data
    ode: ODE integrator
    odeint: ODE integrator

    R-   i   i    s-   maxiter (%d) exceeded. Latest difference = %e(    (   t
   isinstancet   tupleR.   R   t   inft   maxR   R   t   abst   warningst   warnR   (   R   R   R   R   t   tolt   rtolt   maxiterR-   t   miniterR"   t   valt   errR   t   newval(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR      s     2		"c         C` s    t  |   } | | | <t |  S(   N(   t   listR0   (   t   tR,   t   valuet   l(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyt   tupleset   s    
g      ?ic         C` s  t  j |   }  | d	 k r$ | } n t  j |  } | j d k r} t  j |  } d g |  j } d | | <| j |  } nB t | j  t |  j  k r t d   n t  j | d | } | j | |  j | d k r t d   n  t |  j  } t	 t
 d	  f | | t
 d d	   } t	 t
 d	  f | | t
 d	 d   }	 t  j | |  | |  |	 d d | }
 | d	 k	 rt  j |  st d   n  t |
 j  } d | | <t  j t  j | d |
 j | |
 g d | }
 n  |
 S(
   s  
    Cumulatively integrate y(x) using the composite trapezoidal rule.

    Parameters
    ----------
    y : array_like
        Values to integrate.
    x : array_like, optional
        The coordinate to integrate along.  If None (default), use spacing `dx`
        between consecutive elements in `y`.
    dx : float, optional
        Spacing between elements of `y`.  Only used if `x` is None.
    axis : int, optional
        Specifies the axis to cumulate.  Default is -1 (last axis).
    initial : scalar, optional
        If given, uses this value as the first value in the returned result.
        Typically this value should be 0.  Default is None, which means no
        value at ``x[0]`` is returned and `res` has one element less than `y`
        along the axis of integration.

    Returns
    -------
    res : ndarray
        The result of cumulative integration of `y` along `axis`.
        If `initial` is None, the shape is such that the axis of integration
        has one less value than `y`.  If `initial` is given, the shape is equal
        to that of `y`.

    See Also
    --------
    numpy.cumsum, numpy.cumprod
    quad: adaptive quadrature using QUADPACK
    romberg: adaptive Romberg quadrature
    quadrature: adaptive Gaussian quadrature
    fixed_quad: fixed-order Gaussian quadrature
    dblquad: double integrals
    tplquad: triple integrals
    romb: integrators for sampled data
    ode: ODE integrators
    odeint: ODE integrators

    Examples
    --------
    >>> from scipy import integrate
    >>> import matplotlib.pyplot as plt

    >>> x = np.linspace(-2, 2, num=20)
    >>> y = x
    >>> y_int = integrate.cumtrapz(y, x, initial=0)
    >>> plt.plot(x, y_int, 'ro', x, y[0] + 0.5 * x**2, 'b-')
    >>> plt.show()

    i   is2   If given, shape of x must be 1-d or the same as y.R   s7   If given, length of x along axis must be the same as y.g       @s'   `initial` parameter should be a scalar.R#   N(   R   R%   R   t   ndimt   difft   reshapeR&   t   shapeR   RA   t   slicet   cumsumR$   R=   t   concatenatet   onesR#   (   R!   R   t   dxR   t   initialt   dRE   t   ndt   slice1t   slice2t   res(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR      s4    6	
(()
(c         C` s  t  |  j  } | d  k r$ d } n  d } t d   f | } t | | t | | |   }	 t | | t | d | d |   }
 t | | t | d | d |   } | d  k r t j | d |  |	 d |  |
 |  | d | } n t j | d | } t | | t | | |   } t | | t | d | d |   } | | } | | } | | } | | } | | } | d |  |	 d d | |  |
 | | | |  | d | } t j | d | } | S(	   Ni    i   i   g      @i   R   g      @g      ?(   R&   RE   R   RF   RA   R   R   RC   (   R!   t   startt   stopR   RJ   R   RM   t   stept	   slice_allt   slice0RN   RO   t   resultt   ht   sl0t   sl1t   h0t   h1t   hsumt   hprodt   h0divh1t   tmp(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyt   _basic_simps-  s0    	&&,&




't   avgc         C` s  t  j |   }  t |  j  } |  j | } | } | } d }	 | d k	 rt  j |  } t | j  d k r d g | }
 | j d |
 | <| j } d }	 | j t |
   } n- t | j  t |  j  k r t d   n  | j | | k rt d   qn  | d d k rd } d } t d  f | } t d  f | } | d k rat d
   n  | d k rt	 | | d  } t	 | | d  } | d k	 r| | | | } n  | d | |  | |  | 7} t
 |  d | d | | |  } n  | d k rt	 | | d  } t	 | | d  } | d k	 rO| t |  | t |  } n  | d | |  | |  | 7} | t
 |  d | d | | |  7} n  | d k r| d } | d } n  | | } n t
 |  d | d | | |  } |	 r| j |  } n  | S(   s  
    Integrate y(x) using samples along the given axis and the composite
    Simpson's rule.  If x is None, spacing of dx is assumed.

    If there are an even number of samples, N, then there are an odd
    number of intervals (N-1), but Simpson's rule requires an even number
    of intervals.  The parameter 'even' controls how this is handled.

    Parameters
    ----------
    y : array_like
        Array to be integrated.
    x : array_like, optional
        If given, the points at which `y` is sampled.
    dx : int, optional
        Spacing of integration points along axis of `y`. Only used when
        `x` is None. Default is 1.
    axis : int, optional
        Axis along which to integrate. Default is the last axis.
    even : str {'avg', 'first', 'last'}, optional
        'avg' : Average two results:1) use the first N-2 intervals with
                  a trapezoidal rule on the last interval and 2) use the last
                  N-2 intervals with a trapezoidal rule on the first interval.

        'first' : Use Simpson's rule for the first N-2 intervals with
                a trapezoidal rule on the last interval.

        'last' : Use Simpson's rule for the last N-2 intervals with a
               trapezoidal rule on the first interval.

    See Also
    --------
    quad: adaptive quadrature using QUADPACK
    romberg: adaptive Romberg quadrature
    quadrature: adaptive Gaussian quadrature
    fixed_quad: fixed-order Gaussian quadrature
    dblquad: double integrals
    tplquad: triple integrals
    romb: integrators for sampled data
    cumtrapz: cumulative integration for sampled data
    ode: ODE integrators
    odeint: ODE integrators

    Notes
    -----
    For an odd number of samples that are equally spaced the result is
    exact if the function is a polynomial of order 3 or less.  If
    the samples are not equally spaced, then the result is exact only
    if the function is a polynomial of order 2 or less.

    i    i   s2   If given, shape of x must be 1-d or the same as y.s7   If given, length of x along axis must be the same as y.i   g        Ra   t   lastt   firsts3   Parameter 'even' must be 'avg', 'last', or 'first'.iig      ?i   g       @N(   s   avgs   lasts   first(   s   avgs   first(   s   avgs   last(   R   R%   R&   RE   R   RD   R0   R   RF   RA   R`   (   R!   R   RJ   R   t   evenRM   t   Nt   last_dxt   first_dxt   returnshapet   shapext	   saveshapeR:   RV   RN   RO   (    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR
   L  s^    4	"!&
c         C` sQ  t  j |   }  t |  j  } |  j | } | d } d } d } x$ | | k  rg | d K} | d 7} qD W| | k r t d   n  i  }	 t d  f | }
 t |
 | d  } t |
 | d  } | t  j | d t } |  | |  | d | |	 d <|
 } | } } } x t	 d | d  D] } | d L} t | | t | | |   } | d L} d |	 | d d f | |  | j
 d |  |	 | d f <xi t	 d | d  D]T } |	 | | d f } | | |	 | d | d f d d	 | >d |	 | | f <qW| d } qW| rCt  j |	 d  s5t d
 d  qCy | d } Wn t t f k
 rbd } n Xy | d } Wn t t f k
 rd } n Xd | | f } d } t d | j d  d d d d d d xX t	 | d  D]F } x6 t	 | d  D]$ } t | |	 | | f d d qWt   qWt d d  t   n  |	 | | f S(   s  
    Romberg integration using samples of a function.

    Parameters
    ----------
    y : array_like
        A vector of ``2**k + 1`` equally-spaced samples of a function.
    dx : float, optional
        The sample spacing. Default is 1.
    axis : int, optional
        The axis along which to integrate. Default is -1 (last axis).
    show : bool, optional
        When `y` is a single 1-D array, then if this argument is True
        print the table showing Richardson extrapolation from the
        samples. Default is False.

    Returns
    -------
    romb : ndarray
        The integrated result for `axis`.

    See also
    --------
    quad : adaptive quadrature using QUADPACK
    romberg : adaptive Romberg quadrature
    quadrature : adaptive Gaussian quadrature
    fixed_quad : fixed-order Gaussian quadrature
    dblquad : double integrals
    tplquad : triple integrals
    simps : integrators for sampled data
    cumtrapz : cumulative integration for sampled data
    ode : ODE integrators
    odeint : ODE integrators

    i   i    s=   Number of samples must be one plus a non-negative power of 2.iR#   g       @g      ?R   i   s/   *** Printing table only supported for integralss    of a single data set.i   i   s   %%%d.%dfs6   Richardson Extrapolation Table for Romberg Integrationt    iD   t   =t   seps   
t   endt    N(   i    i    (   i    i    (   R   R%   R&   RE   R   RF   R   RA   t   floatR   R   R$   t   printt	   TypeErrort
   IndexErrort   center(   R!   RJ   R   t   showRM   t   Nsampst   NintervR   t   kt   RRT   RU   t   slicem1RW   t   slice_RRQ   RR   RS   R,   t   jt   prevt   precist   widtht   formstrt   title(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR     sd    $



:>

)"
c         C` s   | d k r t  d   n | d k rG d |  | d  |  | d  S| d } t | d | d  | } | d d | } | | t j |  } t j |  |  d d } | Sd S(   sX  
    Perform part of the trapezoidal rule to integrate a function.
    Assume that we had called difftrap with all lower powers-of-2
    starting with 1.  Calling difftrap only returns the summation
    of the new ordinates.  It does _not_ multiply by the width
    of the trapezoids.  This must be performed by the caller.
        'function' is the function to evaluate (must accept vector arguments).
        'interval' is a sequence with lower and upper limits
                   of integration.
        'numtraps' is the number of trapezoids to use (must be a
                   power-of-2).
    i    s#   numtraps must be > 0 in difftrap().i   g      ?i   R   N(   R   Rp   R   t   arangeR   (   t   functiont   intervalt   numtrapst   numtosumRW   t   loxt   pointst   s(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyt	   _difftrap   s     
c         C` s   d | } | | |  | d S(   s   
    Compute the differences for the Romberg quadrature corrections.
    See Forman Acton's "Real Computing Made Real," p 143.
    g      @g      ?(    (   R   t   cRx   R_   (    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyt   _romberg_diff:  s    
c         C` s#  d } } t  d t |   d d t  d |  t  d  t  d d  x t t |   D]y } t  d d | | d | d d | f d d x4 t | d  D]" } t  d | | | d d q Wt  d  q[ Wt  d  t  d | | | d d t  d d t |  d d d  d  S(   Ni    s   Romberg integration ofRn   Ro   t   fromRk   s   %6s %9s %9st   Stepst   StepSizet   Resultss   %6d %9fi   i   g       @s   %9fs   The final result ist   afters   function evaluations.(   R   R   R   (   Rq   t   reprR   R&   (   R   R   t   resmatR,   R|   (    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyt   _printresmatC  s    

2 
g`sbO>i
   c	      	   C` s  t  j |  s t  j |  r- t d   n  t |  | d | }	 d }
 | | g } | | } t |	 | |
  } | | } | g g } t  j } | d } xt d | d  D] } |
 d 9}
 | t |	 | |
  7} | | |
 g } x9 t |  D]+ } | j t | | | | | d   q W| | } | | d } | rN| j |  n  t	 | |  } | | k  s| | t	 |  k  rPn  | } q Wt
 j d | | f t  | rt |	 | |  n  | S(   so
  
    Romberg integration of a callable function or method.

    Returns the integral of `function` (a function of one variable)
    over the interval (`a`, `b`).

    If `show` is 1, the triangular array of the intermediate results
    will be printed.  If `vec_func` is True (default is False), then
    `function` is assumed to support vector arguments.

    Parameters
    ----------
    function : callable
        Function to be integrated.
    a : float
        Lower limit of integration.
    b : float
        Upper limit of integration.

    Returns
    -------
    results  : float
        Result of the integration.

    Other Parameters
    ----------------
    args : tuple, optional
        Extra arguments to pass to function. Each element of `args` will
        be passed as a single argument to `func`. Default is to pass no
        extra arguments.
    tol, rtol : float, optional
        The desired absolute and relative tolerances. Defaults are 1.48e-8.
    show : bool, optional
        Whether to print the results. Default is False.
    divmax : int, optional
        Maximum order of extrapolation. Default is 10.
    vec_func : bool, optional
        Whether `func` handles arrays as arguments (i.e whether it is a
        "vector" function). Default is False.

    See Also
    --------
    fixed_quad : Fixed-order Gaussian quadrature.
    quad : Adaptive quadrature using QUADPACK.
    dblquad : Double integrals.
    tplquad : Triple integrals.
    romb : Integrators for sampled data.
    simps : Integrators for sampled data.
    cumtrapz : Cumulative integration for sampled data.
    ode : ODE integrator.
    odeint : ODE integrator.

    References
    ----------
    .. [1] 'Romberg's method' http://en.wikipedia.org/wiki/Romberg%27s_method

    Examples
    --------
    Integrate a gaussian from 0 to 1 and compare to the error function.

    >>> from scipy import integrate
    >>> from scipy.special import erf
    >>> gaussian = lambda x: 1/np.sqrt(np.pi) * np.exp(-x**2)
    >>> result = integrate.romberg(gaussian, 0, 1, show=True)
    Romberg integration of <function vfunc at ...> from [0, 1]

    ::

       Steps  StepSize  Results
           1  1.000000  0.385872
           2  0.500000  0.412631  0.421551
           4  0.250000  0.419184  0.421368  0.421356
           8  0.125000  0.420810  0.421352  0.421350  0.421350
          16  0.062500  0.421215  0.421350  0.421350  0.421350  0.421350
          32  0.031250  0.421317  0.421350  0.421350  0.421350  0.421350  0.421350

    The final result is 0.421350396475 after 33 function evaluations.

    >>> print("%g %g" % (2*result, erf(1)))
    0.842701 0.842701

    s5   Romberg integration only available for finite limits.R-   i   i    i   s,   divmax (%d) exceeded. Latest difference = %e(   R   R   R   R.   R   R1   R   t   appendR   R3   R4   R5   R   R   (   R   R   R   R   R6   R7   Ru   t   divmaxR-   R"   R   R   t   intranget   ordsumRV   R   R;   t   last_rowR,   t   rowRx   t
   lastresult(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR	   T  s>    T

	

)
"
i   i   i   i   iZ   i   iiP   i-   i   i    ii  i   i   iK   ii@/  i   i)   i   i   i  iix  i   iC  i  i  i+  i  i	i  i_7  i  i   i`i )  iDii?# i	   i ^ i)  i}=  i8  iK  i  ii  ip i>  i< isBi( i:ih iii0	i   i 0iI"! i iiijmii I!l{I [7   iR0P i i@ i7i@!i!Nid7ipRi<ic] i   I ]   I   I=ȗ   IbTDI"V$   IbIJ0   I2SIbI LP   I@d     ii`ip`*ioIƳ    IuI\   I[I@W   IO	!I)  i   c         C` s  yW t  |   d } | r/ t j | d  }  n' t j t j |   d k  rV d } n  Wn& |  } t j | d  }  d } n X| r | t k r t | \ } } } } } | t j | d t | } | t |  | f S|  d d k s |  d | k rt d   n  |  t |  }	 d |	 d }
 t j | d  } |
 | d d  t j	 f } t j
 j |  } x4 t d  D]& } d | | j |  j |  } qxWd | d d d  d } | d d  d d d  f j |  | d } | d d k r| r| | d	 } | d } n | | d } | d } | t j |	 | |  } | d } | t j |  t |  } t j |  } | | | f S(
   s  
    Return weights and error coefficient for Newton-Cotes integration.

    Suppose we have (N+1) samples of f at the positions
    x_0, x_1, ..., x_N.  Then an N-point Newton-Cotes formula for the
    integral between x_0 and x_N is:

    :math:`\int_{x_0}^{x_N} f(x)dx = \Delta x \sum_{i=0}^{N} a_i f(x_i)
    + B_N (\Delta x)^{N+2} f^{N+1} (\xi)`

    where :math:`\xi \in [x_0,x_N]`
    and :math:`\Delta x = \frac{x_N-x_0}{N}` is the average samples spacing.

    If the samples are equally-spaced and N is even, then the error
    term is :math:`B_N (\Delta x)^{N+3} f^{N+2}(\xi)`.

    Parameters
    ----------
    rn : int
        The integer order for equally-spaced data or the relative positions of
        the samples with the first sample at 0 and the last at N, where N+1 is
        the length of `rn`.  N is the order of the Newton-Cotes integration.
    equal : int, optional
        Set to 1 to enforce equally spaced data.

    Returns
    -------
    an : ndarray
        1-D array of weights to apply to the function at the provided sample
        positions.
    B : float
        Error coefficient.

    Notes
    -----
    Normally, the Newton-Cotes rules are used on smaller integration
    regions and a composite rule is used to return the total integral.

    i   R#   i    is1   The sample positions must start at 0 and end at Ni   Ng       @g      @(   R&   R   R   t   allRC   t   _builtincoeffst   arrayRp   R   t   newaxist   linalgt   invt   ranget   dott   matht   logR   t   exp(   t   rnt   equalRe   t   nat   dat   vit   nbt   dbt   ant   yit   tit   nvect   Ct   CinvR,   t   vect   ait   BNt   powert   p1t   fac(    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyR   	  sF    (
 $0

(    (    (    (    (%   t
   __future__R    R   R   t   numpyR   R   R4   R   t   scipy.specialR   R   t   scipy._lib.sixR   t   __all__t   WarningR   R   t   dictR   R   t   FalseR.   t   TrueR   RA   R   R   R`   R
   R   R   R   R   R	   R   R   (    (    (    s9   /tmp/pip-build-7oUkmx/scipy/scipy/integrate/quadrature.pyt   <module>   sv   	
5-E	\	ki				"%(+.$			
