§
    l¬¸j!  ã                   óV   — d dl mZmZ d dlmZ ddlmZ ddlmZ  G d„ de¦  «        Z	dS )	é    )Ú	np_compatÚarray_namespace)Úcached_propertyé   )ÚNestedFixedRule)ÚGaussLegendreQuadraturec                   óF   — e Zd ZdZdd„Zed„ ¦   «         Zed„ ¦   «         ZdS )ÚGaussKronrodQuadratureaz
  
    Gauss-Kronrod quadrature.

    Gauss-Kronrod rules consist of two quadrature rules, one higher-order and one
    lower-order. The higher-order rule is used as the estimate of the integral and the
    difference between them is used as an estimate for the error.

    Gauss-Kronrod is a 1D rule. To use it for multidimensional integrals, it will be
    necessary to use ProductNestedFixed and multiple Gauss-Kronrod rules. See Examples.

    For n-node Gauss-Kronrod, the lower-order rule has ``n//2`` nodes, which are the
    ordinary Gauss-Legendre nodes with corresponding weights. The higher-order rule has
    ``n`` nodes, ``n//2`` of which are the same as the lower-order rule and the
    remaining nodes are the Kronrod extension of those nodes.

    Parameters
    ----------
    npoints : int
        Number of nodes for the higher-order rule.

    xp : array_namespace, optional
        The namespace for the node and weight arrays. Default is None, where NumPy is
        used.

    Attributes
    ----------
    lower : Rule
        Lower-order rule.

    References
    ----------
    .. [1] R. Piessens, E. de Doncker, Quadpack: A Subroutine Package for Automatic
        Integration, files: dqk21.f, dqk15.f (1983).

    Examples
    --------
    Evaluate a 1D integral. Note in this example that ``f`` returns an array, so the
    estimates will also be arrays, despite the fact that this is a 1D problem.

    >>> import numpy as np
    >>> from scipy.integrate import cubature
    >>> from scipy.integrate._rules import GaussKronrodQuadrature
    >>> def f(x):
    ...     return np.cos(x)
    >>> rule = GaussKronrodQuadrature(21) # Use 21-point GaussKronrod
    >>> a, b = np.array([0]), np.array([1])
    >>> rule.estimate(f, a, b) # True value sin(1), approximately 0.84147
     array([0.84147098])
    >>> rule.estimate_error(f, a, b)
     array([1.11022302e-16])

    Evaluate a 2D integral. Note that in this example ``f`` returns a float, so the
    estimates will also be floats.

    >>> import numpy as np
    >>> from scipy.integrate import cubature
    >>> from scipy.integrate._rules import (
    ...     ProductNestedFixed, GaussKronrodQuadrature
    ... )
    >>> def f(x):
    ...     # f(x) = cos(x_1) + cos(x_2)
    ...     return np.sum(np.cos(x), axis=-1)
    >>> rule = ProductNestedFixed(
    ...     [GaussKronrodQuadrature(15), GaussKronrodQuadrature(15)]
    ... ) # Use 15-point Gauss-Kronrod
    >>> a, b = np.array([0, 0]), np.array([1, 1])
    >>> rule.estimate(f, a, b) # True value 2*sin(1), approximately 1.6829
     np.float64(1.682941969615793)
    >>> rule.estimate_error(f, a, b)
     np.float64(2.220446049250313e-16)
    Nc                 óæ   — |dk    r|dk    rt          d¦  «        ‚|| _        |€t          }t          |                     d¦  «        ¦  «        | _        t          |dz  | j        ¬¦  «        | _        d S )Né   é   zFGauss-Kronrod quadrature is currently onlysupported for 15 or 21 nodesr   é   )Úxp)ÚNotImplementedErrorÚnpointsr   r   Úemptyr   r   Úgauss)Úselfr   r   s      úu/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/scipy/integrate/_rules/_gauss_kronrod.pyÚ__init__zGaussKronrodQuadrature.__init__R   sz   € ð �bŠ=ˆ=˜W¨š]˜]Ý%ð 'Eñ Fô Fð Fð ˆŒàˆ:ÝˆBå! "§(¢(¨1¡+¤+Ñ.Ô.ˆŒå,¨W°a©Z¸D¼GÐDÑDÔDˆŒ
ˆ
ˆ
ó    c                 óx  — | j         dk    rQ| j                             g d¢| j        j        ¬¦  «        }| j                             g d¢| j        j        ¬¦  «        }n[| j         dk    rP| j                             g d¢| j        j        ¬¦  «        }| j                             g d¢| j        j        ¬¦  «        }||fS )Nr   )gå*'ilÜï?gØò*>*ï?gÆ°¤ÙÃí?gó²œ^™®ë?gblútuüè?g˜á�"¹½å?g Á@â?gÜj	À¼Û?g7¡^)U×Ò?gzâ‘xPÃ?r   gzâ‘xPÃ¿g7¡^)U×Ò¿gÜj	À¼Û¿g Á@â¿g˜á�"¹½å¿gblútuüè¿gó²œ^™®ë¿gÆ°¤ÙÃí¿gØò*>*ï¿gå*'ilÜï¿)Údtype)ç?ˆÊÛ[ó‡?çB@©¤v« ?ç¢™÷¬?çå"7ÕÌ5³?ç‰³ÜÝ×·?ç��¨ýË ¼?çÞ-]�+�¿?çÔHiÑ&>Á?çla{FÂ?çµòoéÂ?gÑ|+!Ã?r#   r"   r!   r    r   r   r   r   r   r   r   )g±	M� ºï?g)b|Ž_î?g>»¹'ø¬ë?gÖ¡ã›Ÿºç?g$ú�:Áâ?gbýñ]ùÙ?gw.‰²˜Ê?g        gw.‰²˜Ê¿gbýñ]ùÙ¿g$ú�:Áâ¿gÖ¡ã›Ÿºç¿g>»¹'ø¬ë¿g)b|Ž_î¿g±	M� ºï¿)çptÕg[|—?çÄa{ªÍ&°?çÆH£„Óº?çÁèFí Â?ç\}äfò¡Å?ç±Èah]È?çØœìËÛ*Ê?g	‡�OÐÊ?r*   r)   r(   r'   r&   r%   r$   )r   r   ÚasarrayÚfloat64)r   ÚnodesÚweightss      r   Únodes_and_weightsz(GaussKronrodQuadrature.nodes_and_weightsb   sú   € ð Œ<˜2ÒÐØ”G—O’Oðð ð ð. ”g”oð1 $ñ ô ˆEð6 ”g—o’oðð ð ð. ”g”oð1 &ñ ô ˆGˆGð4 Œ\˜RÒÐØ”G—O’Oðð ð ð" ”g”oð% $ñ ô ˆEð* ”g—o’oðð ð ð" ”g”oð% &ñ ô ˆGð* �gˆ~Ðr   c                 ó   — | j         j        S ©N)r   r/   )r   s    r   Úlower_nodes_and_weightsz.GaussKronrodQuadrature.lower_nodes_and_weightsÈ   s   € àŒzÔ+Ð+r   r1   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r/   Úpropertyr2   © r   r   r
   r
   	   ss   € € € € € ðFð FðPEð Eð Eð Eð  ðcð cñ „_ðcðJ ð,ð ,ñ „Xð,ð ,ð ,r   r
   N)
Úscipy._lib._array_apir   r   Ú	functoolsr   Ú_baser   Ú_gauss_legendrer   r
   r8   r   r   ú<module>r=      s‘   ðØ <Ð <Ð <Ð <Ð <Ð <Ð <Ð <à %Ð %Ð %Ð %Ð %Ð %à "Ð "Ð "Ð "Ð "Ð "Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4ðA,ð A,ð A,ð A,ð A,˜_ñ A,ô A,ð A,ð A,ð A,r   