
    (phV                     *   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	J
r
   " S S\R                  5      r " S S5      r " S S5      rS	 rS
 r " S S5      r  SSS.S jjrS rS rS\l        S\l        S rS rS\l        S rS\l        g)    N)
MapWrapper_FunctionWrapperc                   4   ^  \ rS rSrS rU 4S jrS rSrU =r$ )LRUDict   c                     Xl         g N)_LRUDict__max_size)selfmax_sizes     L/var/www/html/venv/lib/python3.13/site-packages/scipy/integrate/_quad_vec.py__init__LRUDict.__init__   s    "    c                    > X;   n[         TU ]  X5        U(       a  U R                  U5        g [        U 5      U R                  :  a  U R                  SS9  g g )NF)last)super__setitem__move_to_endlenr
   popitem)r   keyvalueexisting_key	__class__s       r   r   LRUDict.__setitem__   sK    C'S!Y(LLeL$ )r   c                     [        5       er	   )NotImplementedError)r   others     r   updateLRUDict.update   s    !##r   )
__max_size)	__name__
__module____qualname____firstlineno__r   r   r    __static_attributes____classcell__)r   s   @r   r   r      s    #%$ $r   r   c                   *    \ rS rSrSrS rS rS rSrg)SemiInfiniteFunc   z1
Argument transform from (start, +-oo) to (0, 1)
c                 ~    Xl         X l        US:  a  SOSU l        [        R                  R
                  S-  U l        g )Nr            ?)_func_start_sgnsys
float_infomin_tmin)r   funcstartinftys       r   r   SemiInfiniteFunc.__init__"   s3    
!)B	 ^^'',
r   c                 t    U R                   XR                  -
  -  S-   nUS:X  a  [        R                  $ SU-  $ )Nr.   r   )r2   r1   npinf)r   xzs      r   get_tSemiInfiniteFunc.get_t*   s4    II[[)A-666M1ur   c                     XR                   :  a  gU R                  U R                  SU-
  -  U-  -   nU R                  U5      nU R                  X1-  -  U-  $ N        r.   )r6   r1   r2   r0   r   tr>   fs       r   __call__SemiInfiniteFunc.__call__1   sQ    zz>dii1q51A55A

1A99&**r   )r0   r2   r1   r6   N	r#   r$   r%   r&   __doc__r   r@   rH   r'    r   r   r*   r*      s    -+r   r*   c                   *    \ rS rSrSrS rS rS rSrg)DoubleInfiniteFunc:   z.
Argument transform from (-oo, oo) to (-1, 1)
c                 T    Xl         [        R                  R                  S-  U l        g )Nr/   )r0   r3   r4   r5   r6   )r   r7   s     r   r   DoubleInfiniteFunc.__init__>   s    
 ^^'',
r   c                 8    US:  a  SOSnU[        U5      S-   -  $ )Nr   r-   r.   )abs)r   r>   ss      r   r@   DoubleInfiniteFunc.get_tD   s"    a%BQCFQJr   c                     [        U5      U R                  :  a  gS[        U5      -
  U-  nU R                  U5      nX1-  U-  $ rC   )rS   r6   r0   rE   s       r   rH   DoubleInfiniteFunc.__call__H   s@    q6DJJSVq A

1AEQ;r   )r0   r6   NrJ   rL   r   r   rN   rN   :   s    - r   rN   c                 @    [         R                  " [        U 5      5      $ r	   )r<   amaxrS   )r>   s    r   	_max_normrZ   Q   s    773q6?r   c                      [         R                  " U 5      $ ! [         a/    [        U S5      (       a  [	        U R                  5       5      s $  gf = f)N
__sizeof__@   )r3   	getsizeof	TypeErrorhasattrintr\   )objs    r   _get_sizeofrc   U   sG    }}S!! 3%%s~~'((	s    4AAc                        \ rS rSrS rS rSrg)_Bunch_   c                 f    UR                  5       U l        U R                  R                  " S0 UD6  g )NrL   )keys_Bunch__keys__dict__r    )r   kwargss     r   r   _Bunch.__init__`   s$    kkm&v&r   c                 Z   ^  SR                  U 4S jT R                   5       5      nSU S3$ )Nz, c              3   \   >#    U  H!  o S [        TR                  U   5       3v   M#     g7f)=N)reprrj   ).0kr   s     r   	<genexpr>"_Bunch.__repr__.<locals>.<genexpr>e   s,      $
5@c4a()*+[s   ),z_Bunch())joinri   )r   key_value_pairss   ` r   __repr___Bunch.__repr__d   s4    )) $
59[[$
 
 )++r   )__keysN)r#   r$   r%   r&   r   rx   r'   rL   r   r   re   re   _   s    ',r   re   rL   )argsc                ^  ^A [        U5      n[        U5      nU(       a#  [        U[        5      (       d  U4n[        X5      n [	        UUUUUUU	U
c  SOU
US9	n[
        R                  " U5      (       aN  [
        R                  " U5      (       a3  [        XUS9mAU	b  [        UA4S jU	 5       5      US'   [        TASS40 UD6$ [
        R                  " U5      (       a[  [
        R                  " U5      (       a@  [        XUS9mAU	b  [        UA4S	 jU	 5       5      US'   [        TASS40 UD6nUS   * 4USS -   $ [
        R                  " U5      (       a  [
        R                  " U5      (       ai  X!:  a  S
OSn[        U 5      mAU	b  S[        UA4S jU	 5       5      -   US'   OSUS'   X:w  a  [        TAS
S40 UD6nO[        TASS40 UD6nUS   U-  4USS -   $ [
        R                  " U5      (       a  [
        R                  " U5      (       d  [        SU SU 35      e[        [        [
        R                  R                  S.n[        U5      (       a  UnOUU   nSnSn [         [         ["        [$        [$        S.U
   nU
S:X  a  Sn[(        R*                  " U[,        SS9  U	c  X4/nOaUn/ n[/        U	5       H;  n[        U5      nUUs=:  a  U:  a	  O  OUU:X  a  M&  UR1                  UU45        UnM=     UR1                  UU45        SnSnSnSn/ nSnU H  u  n n!U" U U!U U5      u  n"n#n$UUR2                  -  nUcw  [        U"[         [4        45      (       a*  U[        [
        R                  R                  4;   a  [6        nU"n[        U#5      n[        U$5      nU[9        U"5      -  n%[;        U%5      nOUU"-  nUU#-  nUU$-  n[<        R<                  " U"5      UU U!4'   UR1                  U#* U U!45        M     [>        R@                  " U5        Sn&Sn'Sn(Sn)U&SU'SU(SU)S0n*[C        U5       n+U'n,U(       Ga  [E        U5      U:  Ga  [G        X4U" U5      -  5      n-/ n.Sn/[I        U5       Hm  n0U(       d    OeU0S:  a  U/UU-S-  -
  :  a    OQ[>        RJ                  " U5      n1U1u  n2pURM                  X4S5      n3U.R1                  U2* XU34U UU45        U/U2* -  n/Mo     U+" [N        U.5       HQ  n4U4u  n5n6n7n8n9UU9-  nUU5-  nUU6-  nUU7-  nU8 H,  n:U:u  n n!n"n#U"UU U!4'   [>        RP                  " UU#* U U!45        M.     MS     [E        U5      U:  a)  [G        X4U" U5      -  5      n-UU-S-  :  a  U&n,O[UU:  a  U(n,OR[
        R                  " U5      (       a  [
        R                  " U5      (       d  U)n,OU(       a  [E        U5      U:  a  GM  SSS5        UnUU-   n#U(       Ga
  [
        RR                  " U5      n;[
        RT                  " U;RV                  [
        RX                  U;RZ                  S9n<[
        R\                  " U V=s/ s H  n=UR_                  U=S   U=S   4U<5      PM     sn=U;RZ                  S9n>[
        R\                  " U V=s/ s H	  n=U=S   * PM     sn=5      n?[
        R\                  " U V=s/ s H  n=U=S   U=S   /PM     sn=5      n[a        UW,U&:H  U,U*U,   UU>U?S9n@UU#U@4$ UU#4$ ! [&         a  n[        SU
< 35      UeSnAff = f! , (       d  f       GNN= fs  sn=f s  sn=f s  sn=f )a  Adaptive integration of a vector-valued function.

Parameters
----------
f : callable
    Vector-valued function f(x) to integrate.
a : float
    Initial point.
b : float
    Final point.
epsabs : float, optional
    Absolute tolerance.
epsrel : float, optional
    Relative tolerance.
norm : {'max', '2'}, optional
    Vector norm to use for error estimation.
cache_size : int, optional
    Number of bytes to use for memoization.
limit : float or int, optional
    An upper bound on the number of subintervals used in the adaptive
    algorithm.
workers : int or map-like callable, optional
    If `workers` is an integer, part of the computation is done in
    parallel subdivided to this many tasks (using
    :class:`python:multiprocessing.pool.Pool`).
    Supply `-1` to use all cores available to the Process.
    Alternatively, supply a map-like callable, such as
    :meth:`python:multiprocessing.pool.Pool.map` for evaluating the
    population in parallel.
    This evaluation is carried out as ``workers(func, iterable)``.
points : list, optional
    List of additional breakpoints.
quadrature : {'gk21', 'gk15', 'trapezoid'}, optional
    Quadrature rule to use on subintervals.
    Options: 'gk21' (Gauss-Kronrod 21-point rule),
    'gk15' (Gauss-Kronrod 15-point rule),
    'trapezoid' (composite trapezoid rule).
    Default: 'gk21' for finite intervals and 'gk15' for (semi-)infinite
full_output : bool, optional
    Return an additional ``info`` dictionary.
args : tuple, optional
    Extra arguments to pass to function, if any.

    .. versionadded:: 1.8.0

Returns
-------
res : {float, array-like}
    Estimate for the result
err : float
    Error estimate for the result in the given norm
info : dict
    Returned only when ``full_output=True``.
    Info dictionary. Is an object with the attributes:

        success : bool
            Whether integration reached target precision.
        status : int
            Indicator for convergence, success (0),
            failure (1), and failure due to rounding error (2).
        neval : int
            Number of function evaluations.
        intervals : ndarray, shape (num_intervals, 2)
            Start and end points of subdivision intervals.
        integrals : ndarray, shape (num_intervals, ...)
            Integral for each interval.
            Note that at most ``cache_size`` values are recorded,
            and the array may contains *nan* for missing items.
        errors : ndarray, shape (num_intervals,)
            Estimated integration error for each interval.

Notes
-----
The algorithm mainly follows the implementation of QUADPACK's
DQAG* algorithms, implementing global error control and adaptive
subdivision.

The algorithm here has some differences to the QUADPACK approach:

Instead of subdividing one interval at a time, the algorithm
subdivides N intervals with largest errors at once. This enables
(partial) parallelization of the integration.

The logic of subdividing "next largest" intervals first is then
not implemented, and we rely on the above extension to avoid
concentrating on "small" intervals only.

The Wynn epsilon table extrapolation is not used (QUADPACK uses it
for infinite intervals). This is because the algorithm here is
supposed to work on vector-valued functions, in an user-specified
norm, and the extension of the epsilon algorithm to this case does
not appear to be widely agreed. For max-norm, using elementwise
Wynn epsilon could be possible, but we do not do this here with
the hope that the epsilon extrapolation is mainly useful in
special cases.

References
----------
[1] R. Piessens, E. de Doncker, QUADPACK (1983).

Examples
--------
We can compute integrations of a vector-valued function:

>>> from scipy.integrate import quad_vec
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> alpha = np.linspace(0.0, 2.0, num=30)
>>> f = lambda x: x**alpha
>>> x0, x1 = 0, 2
>>> y, err = quad_vec(f, x0, x1)
>>> plt.plot(alpha, y)
>>> plt.xlabel(r"$\alpha$")
>>> plt.ylabel(r"$\int_{0}^{2} x^\alpha dx$")
>>> plt.show()

When using the argument `workers`, one should ensure
that the main module is import-safe, for instance
by rewriting the example above as:

.. code-block:: python

    from scipy.integrate import quad_vec
    import numpy as np
    import matplotlib.pyplot as plt

    alpha = np.linspace(0.0, 2.0, num=30)
    x0, x1 = 0, 2
    def f(x):
        return x**alpha

    if __name__ == "__main__":
        y, err = quad_vec(f, x0, x1, workers=2)
Ngk15)	epsabsepsrelnorm
cache_sizelimitworkerspoints
quadraturefull_output)r8   r9   c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr	   r@   rq   xpf2s     r   rs   quad_vec.<locals>.<genexpr>       $CFbRXXb\\F   !r   r   r.   c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr	   r   r   s     r   rs   r     r   r   r-   )r   c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr	   r   r   s     r   rs   r     s     +J6RBHHRLL6r   zinvalid integration bounds a=z, b=)Nmax2      )Ngk21r}   trapz	trapezoidzunknown quadrature r   zz`quadrature='trapz'` is deprecated in favour of `quadrature='trapezoid' and will raise an error from SciPy 1.16.0 onwards.)
stacklevel   zTarget precision reached.zTarget precision not reached.z<Target precision could not be reached due to rounding error.zNon-finite values encountered.   )dtype)nevalsuccessstatusmessage	intervals	integralserrors)1float
isinstancetupler   dictr<   isfiniteisinfr*   quad_vecrN   
ValueErrorrZ   linalgr   callable_quadrature_gk21_quadrature_gk15_quadrature_trapezoidKeyErrorwarningswarnDeprecationWarningsortedappendnum_evalcomplexrS   rc   r   copyheapqheapifyr   r   r   rangeheappoppop_subdivide_intervalheappushasarrayfullshapenanr   arraygetre   )BrG   abr~   r   r   r   r   r   r   r   r   r{   rk   ressgn
norm_funcs	norm_funcparallel_countmin_intervals_quadratureemsginitial_intervalsprevpglobal_integralglobal_errorrounding_errorinterval_cacher   r   x1x2igerrrndcache_count	CONVERGEDNOT_CONVERGEDROUNDING_ERRORNOT_A_NUMBER
status_msg
mapwrapperiertol
to_processerr_sumjintervalneg_old_errold_intpartsdintderr
dround_errsubintdnevalr>   res_arrdummyr?   r   r   infor   sB                                                                    @r   r   r   k   s^   R 	aAaA$&&7D Q% '!'1'9Vz)+F 
{{1~~"((1++a2$$CF$CCF8Aq+F++	QBHHQKKa2$$CF$CCF8r1a*6*QzCG##	!!Ebq  "#e+J6+J&JJF8#F862r1//C2q!.v.CAs
}s12w&&kk!nnQ84sCDD YY^^J
 ~~	t$	NMF-// 5$9	; <F	G W 	c-!< ~VHAaAIAI!t)$$dAY/D   	  $+OLNNIE#B"2r1i8C%%%""ug.//BIINN ;; #I O :L"3ZN$B7K$[1Nr!OCLc!N#'99R=Bx 3$B(- $0 
MM)IMNL 	.6V6	J 
G	
C	NU2fY%??@CJG>* q5W|c!e';; ==3$,!Q(,,aVT:!!"lA'2Ay+N K<' +$ $$7D9>6dJ4'$*,A&'OBB/1NB8,NN9tRn=   E 9~.&?)C"CD#a%'#C.0(CKK--"++n2M2M"a C	NU2 
j C

'C**S/rvvW]]CHH/8:/8! -00!A$!uE/8:AHP	)4)QAaD5)45HHI>IqqtQqTlI>?	E"i/ (o ) )#% S$Sz]  F.zn=>AEFJ 
	v:4>s7    [, ,F\ $\ \%3\*,
\6\\
\c                    U u  pp4Uu  pVpxSXg-   -  n	[        USS5      S:  a&  [        R                  " UR                  5      " U5      nU" XiX#5      u  pnUR                  nU" XX#5      u  pnXR                  -  nUc  U" XgX#5      u  n  nXR                  -  n[        USS5      S:  a  UR                  5       R                  nX-   U-
  nX-   U-
  nUU-   nXiX4XX44nUUUUU4$ )Nr/   r   r   )getattr	functools	lru_cacher   r   
cache_infomisses)r{   r   rG   r   r   old_errr   r   r   cs1err1round1r   s2err2round2_r   r   r   subintervalss                         r   r   r     s   *.'H%GquA {L!,q0 6 67:"16Bf!!F"16Bf
"""F#A!7A&&&{L!,q0&&7WD; D&J2$qR&67Lz<77r   c                 J   SX-   -  nU" U 5      nU" U5      nU" U5      nSX-
  -  USU-  -   U-   -  nS[        X-
  5      -  [        U" U5      5      S[        U" U5      5      -  -   [        U" U5      5      -   -  S-  n	SX-
  -  XV-   -  n
S[        U" X-
  5      5      -  nXU	4$ )z 
Composite trapezoid quadrature
r/   g      ?r   gؗҬ<gUUUUUU?)rS   r   )r   r   rG   r   x3f1r   f3r   	round_errr   r   s               r   r   r     s     
bgB	
2B	
2B	
2B		R!B$Y^	,Bs27|#uYr]';)*52+?)?(@).y})=(> ?AFGI 
BG	$B
i()
)CIr   	   r   c                    S/[        U5      -  nSX-   -  nSX-
  -  n	Sn
Sn[        [        U5      5       H1  nU" XXL   -  -   5      nXU'   Xl   nXU-  -  n
X[        U5      -  -  nM3     Sn[        [        U5      5       H  nXU   USU-  S-      -  -  nM     SnU
S-  n[        [        U5      5       H  nUXl   [        X|   U-
  5      -  -  nM     [        U" X-
  U	-  5      5      n[        U" UU	-  5      5      nUS:w  a  US:w  a  U[	        SSU-  U-  S	-  5      -  n[
        R                  R                  n[        U" S
U-  U	-  U-  5      5      nU[
        R                  R                  :  a  [        UU5      nX-  UU4$ )z"
Generic Gauss-Kronrod quadrature
rD   r/   r   r.   g       @r   g      ?   g      ?2   )	r   r   rS   r   r5   r3   r4   epsilonr   )r   r   rG   r   r>   wvfvr   hs_ks_k_absiffvvs_gs_k_dabsy0r   dabsepsr	  s                         r   _quadrature_gkr    s   
 s1vBquAquA CG3q6]qQT6z]1T 	BwB<  C3q6]tb1qk!!  H	sB3q6]AD3rurz?** 
 	39/*
+C8a<()DqySAXSsSy4/#566
..
 
 CiS1w 678I3>>%%%#y!7C""r   c           	      *    SnSnSn[        XX#XEU5      $ )z1
Gauss-Kronrod 21 quadrature with error estimate
)g*'il?g*>*?g?g^?gbltu?g"?g @?gj	?g7^)U?gzxP?r   gzxPÿg7^)Uҿgj	ۿg @g"gbltug^gg*>*g*'il)
b_?x8!?1 ?Uz;?p?r#  r"  r!  r   r  )?[?B@v?碙?"75?牳׷?珁 ?-]+?Hi&>?la{F?o?g|+!?r-  r,  r+  r*  r)  r(  r'  r&  r%  r$  r  r   r   rG   r   r>   r  r  s          r   r   r   4  s*    
	/A.		.A	.A, !aA66r      c           	      *    SnSnSn[        XX#XEU5      $ )z1
Gauss-Kronrod 15 quadrature with error estimate
)g	M ?g)b|_?g>'?g֡㛟?g$:?gb]?gw.?rD   gw.ʿgb]ٿg$:g֡㛟g>'g)b|_g	M )Wm?D=q?=+No?g/<׿?r4  r3  r2  )ptg[|?a{&?HӺ?F ?\}f?ah]?؜*?g	O?r;  r:  r9  r8  r7  r6  r5  r.  r/  s          r   r   r   x  s*    
	/A"	.A	.A  !aA66r      )	gN~hg:0yE>r   g    חAi'  r.   NNF)r3   r   r   collectionsr   r   numpyr<   scipy._lib._utilr   r   OrderedDictr   r*   rN   rZ   rc   re   r   r   r   r   r   r  r   r   rL   r   r   <module>rA     s    
       9$k%% $"+ +8 .	, 	, HMOT^^B8:( $)   !"  0#f>7B   /7d   r   