§
    l¬¸jŒ  ã                   ó`   — d dl Z d dlZd dlmZ d dlmZmZ d dlmZ  G d„ de¦  «        Z	d„ Z
dS )é    N)Úcached_property)Úarray_namespaceÚ	np_compat)ÚNestedFixedRulec                   óF   — e Zd ZdZdd„Zed„ ¦   «         Zed„ ¦   «         ZdS )	ÚGenzMalikCubaturea†  
    Genz-Malik cubature.

    Genz-Malik is only defined for integrals of dimension >= 2.

    Parameters
    ----------
    ndim : int
        The spatial dimension of the integrand.

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

    Attributes
    ----------
    higher : Cubature
        Higher-order rule.

    lower : Cubature
        Lower-order rule.

    References
    ----------
    .. [1] A.C. Genz, A.A. Malik, Remarks on algorithm 006: An adaptive algorithm for
        numerical integration over an N-dimensional rectangular region, Journal of
        Computational and Applied Mathematics, Volume 6, Issue 4, 1980, Pages 295-302,
        ISSN 0377-0427, https://doi.org/10.1016/0771-050X(80)90039-X.

    Examples
    --------
    Evaluate a 3D integral:

    >>> import numpy as np
    >>> from scipy.integrate import cubature
    >>> from scipy.integrate._rules import GenzMalikCubature
    >>> def f(x):
    ...     # f(x) = cos(x_1) + cos(x_2) + cos(x_3)
    ...     return np.sum(np.cos(x), axis=-1)
    >>> rule = GenzMalikCubature(3) # Use 3D Genz-Malik
    >>> a, b = np.array([0, 0, 0]), np.array([1, 1, 1])
    >>> rule.estimate(f, a, b) # True value 3*sin(1), approximately 2.5244
     np.float64(2.5244129547230862)
    >>> rule.estimate_error(f, a, b)
     np.float64(1.378269656626685e-06)
    é   é   Nc                 óð   — |dk     rt          d¦  «        ‚|dk    s|dk    rt          d¦  «        ‚|| _        || _        || _        |€t
          }t          |                     d¦  «        ¦  «        | _        d S )Né   z1Genz-Malik cubature is only defined for ndim >= 2r	   r
   zKGenz-Malik cubature is currently only supportedfor degree=7, lower_degree=5r   )	Ú
ValueErrorÚNotImplementedErrorÚndimÚdegreeÚlower_degreer   r   ÚemptyÚxp)Úselfr   r   r   r   s        úr/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/scipy/integrate/_rules/_genz_malik.pyÚ__init__zGenzMalikCubature.__init__;   s‡   € Ø�!Š8ˆ8ÝÐPÑQÔQÐQà�QŠ;ˆ;˜,¨!Ò+Ð+Ý%ð 'Eñ Fô Fð Fð ˆŒ	ØˆŒØ(ˆÔàˆ:ÝˆBå! "§(¢(¨1¡+¤+Ñ.Ô.ˆŒˆˆó    c                 óº  — t          j        d¦  «        }t          j        d¦  «        }t          j        d¦  «        }t          j        d¦  «        }t          j        d| j        z  gt          |fd| j        dz
  z  z   ¦  «        t          | fd| j        dz
  z  z   ¦  «        t          |fd| j        dz
  z  z   ¦  «        t          | fd| j        dz
  z  z   ¦  «        t          ||fd| j        dz
  z  z   ¦  «        t          || fd| j        dz
  z  z   ¦  «        t          | | fd| j        dz
  z  z   ¦  «        t          j        || f| j        ¬¦  «        ¦	  «	        }dd| j        dz   z  | j        z  z   d| j        z  z   }| j                             t          t          |Ž ¦  «        | j        j        ¬¦  «        }| j                             || j        |f¦  «        }|j        }d| j        z  d	d
| j        z  z
  d| j        dz  z  z   z  dz  }d| j        z  dz  dz  }	d| j        z  dd| j        z  z
  z  dz  }
d| j        z  dz  }d}| j                             | j                             |gdz  | j        j        ¬¦  «        | j                             |	gd| j        z  z  | j        j        ¬¦  «        | j                             |
gd| j        z  z  | j        j        ¬¦  «        | j                             |gd| j        dz
  z  | j        z  z  | j        j        ¬¦  «        | j                             |gd| j        z  z  | j        j        ¬¦  «        g¦  «        }||fS )NçPuPuÀ?çÍÌÌÌÌÌì?gå5”×PÞ?©r   é   r   )Úrepeat©Údtypei2  i #  i�  iãL  iÔ  i¡  i  gûSÍgQÏ„?g�ºöbMÖ?)ÚmathÚsqrtÚ	itertoolsÚchainr   Ú_distinct_permutationsÚproductr   ÚasarrayÚlistÚzipÚfloat64ÚreshapeÚTÚconcat)r   Úl_2Úl_3Úl_4Úl_5ÚitsÚ
nodes_sizeÚnodesÚw_1Úw_2Úw_3Úw_4Úw_5Úweightss                 r   Únodes_and_weightsz#GenzMalikCubature.nodes_and_weightsL   s?  € õ Œi˜‰oŒoˆÝŒi˜‰oŒoˆÝŒi˜‰oŒoˆÝŒi˜‰oŒoˆåŒoØ�D”IÑÐÝ" C 6¨D°D´IÀ±MÑ,BÑ#BÑCÔCÝ" S D 7¨T°T´YÀ±]Ñ-CÑ#CÑDÔDÝ" C 6¨D°D´IÀ±MÑ,BÑ#BÑCÔCÝ" S D 7¨T°T´YÀ±]Ñ-CÑ#CÑDÔDÝ" C¨ :°¸¼	ÀA¹Ñ0FÑ#FÑGÔGÝ" C¨#¨ ;°¸¼ÀQ¹Ñ1GÑ#GÑHÔHÝ" S D¨3¨$ <°$¸$¼)Àa¹-Ñ2HÑ#HÑIÔIÝÔ˜s S D˜k°$´)Ð<Ñ<Ô<ñ

ô 

ˆð ˜!˜tœy¨1™}Ñ-°´	Ñ9Ñ:¸QÀÄ	¹\ÑIˆ
à”—’Ý•�c�‰OŒOØ”'”/ð  ñ 
ô 
ˆð
 ”—’ ¨¬	°:Ð'>Ñ?Ô?ˆð
 ”ˆð �”	‰\˜e d¨4¬9¡nÑ4¸¸d¼iÈ¹lÑ8JÑKÑLÈuÑTð 	ð �$”)‰|˜sÑ" 4Ñ'ˆØ�$”)‰|  s¨T¬Y¡Ñ 6Ñ7¸%Ñ?ˆØ�$”)‰| Ñ,ˆØˆà”'—.’.ØŒG�OŠO˜S˜E A™I¨T¬W¬_ˆOÑ=Ô=ØŒG�OŠO˜S˜E Q¨¬¡]Ñ3¸4¼7¼?ˆOÑKÔKØŒG�OŠO˜S˜E Q¨¬¡]Ñ3¸4¼7¼?ˆOÑKÔKØŒG�OŠOØ�˜˜dœi¨!™mÑ,¨t¬yÑ8Ñ9Ø”g”oð ñ ô ð ŒG�OŠO˜S˜E Q¨¬	¡\Ñ2¸$¼'¼/ˆOÑJÔJð	"
ñ 	ô 	ˆð �gˆ~Ðr   c                 óÖ  — t          j        d¦  «        }t          j        d¦  «        }t          j        d¦  «        }t          j        d| j        z  gt          |fd| j        dz
  z  z   ¦  «        t          | fd| j        dz
  z  z   ¦  «        t          |fd| j        dz
  z  z   ¦  «        t          | fd| j        dz
  z  z   ¦  «        t          ||fd| j        dz
  z  z   ¦  «        t          || fd| j        dz
  z  z   ¦  «        t          | | fd| j        dz
  z  z   ¦  «        ¦  «        }dd| j        dz   z  | j        z  z   }| j                             t          t          |Ž ¦  «        | j        j
        ¬¦  «        }| j                             || j        |f¦  «        }|j        }d| j        z  dd| j        z  z
  d	| j        dz  z  z   z  dz  }d| j        z  d
z  }d| j        z  dd| j        z  z
  z  dz  }	d| j        z  dz  }
| j                             | j                             |gdz  | j        j
        ¬¦  «        | j                             |gd| j        z  z  | j        j
        ¬¦  «        | j                             |	gd| j        z  z  | j        j
        ¬¦  «        | j                             |
gd| j        dz
  z  | j        z  z  | j        j
        ¬¦  «        g¦  «        }||fS )Nr   r   r   r   r   r   iÙ  i¶  é2   g�QA¶!à?i	  éd   i²  gÜ>•¯ìŽ¡?)r    r!   r"   r#   r   r$   r   r&   r'   r(   r)   r*   r+   r,   )r   r-   r.   r/   r1   r2   r3   r4   r5   r6   r7   r9   s               r   Úlower_nodes_and_weightsz)GenzMalikCubature.lower_nodes_and_weights„   sÇ  € õ Œi˜‰oŒoˆÝŒi˜‰oŒoˆÝŒi˜‰oŒoˆåŒoØ�D”IÑÐÝ" C 6¨D°D´IÀ±MÑ,BÑ#BÑCÔCÝ" S D 7¨T°T´YÀ±]Ñ-CÑ#CÑDÔDÝ" C 6¨D°D´IÀ±MÑ,BÑ#BÑCÔCÝ" S D 7¨T°T´YÀ±]Ñ-CÑ#CÑDÔDÝ" C¨ :°¸¼	ÀA¹Ñ0FÑ#FÑGÔGÝ" C¨#¨ ;°¸¼ÀQ¹Ñ1GÑ#GÑHÔHÝ" S D¨3¨$ <°$¸$¼)Àa¹-Ñ2HÑ#HÑIÔIñ	
ô 	
ˆð ˜!˜tœy¨1™}Ñ-°´	Ñ9Ñ:ˆ
à”—’¥¥S¨# Y¡¤°t´w´�ÑGÔGˆØ”—’ ¨¬	°:Ð'>Ñ?Ô?ˆØ”ˆð �$”)‰|  c¨$¬)¡mÑ 3°b¸¼ÀA¹±oÑ EÑFÈÑLˆØ�$”)‰| 	Ñ*ˆØ�$”)‰|  c¨$¬)¡mÑ 3Ñ4°tÑ;ˆØ�$”)‰| Ñ)ˆà”'—.’.ØŒG�OŠO˜S˜E A™I¨T¬W¬_ˆOÑ=Ô=ØŒG�OŠO˜S˜E Q¨¬¡]Ñ3¸4¼7¼?ˆOÑKÔKØŒG�OŠO˜S˜E Q¨¬¡]Ñ3¸4¼7¼?ˆOÑKÔKØŒG�OŠOØ�˜˜dœi¨!™mÑ,¨t¬yÑ8Ñ9Ø”g”oð ñ ô ð	"
ñ ô ˆð �gˆ~Ðr   )r	   r
   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r:   r>   © r   r   r   r      sj   € € € € € ð-ð -ð^/ð /ð /ð /ð" ð5ð 5ñ „_ð5ðn ð+ð +ñ „_ð+ð +ð +r   r   c              #   óx  K  — t          | ¦  «        }t          |¦  «        }	 t          |¦  «        V — t          |dz
  dd¦  «        D ]}||         ||dz            k     r nŒdS t          |dz
  |d¦  «        D ]}||         ||         k     r nŒ||         ||         c||<   ||<   |d||z
  d…         ||dz   d…<   Œš)zM
    Find the number of distinct permutations of elements of `iterable`.
    Tr   éÿÿÿÿr   N)ÚsortedÚlenÚtupleÚrange)ÚiterableÚitemsÚsizeÚiÚjs        r   r$   r$   ³   s  è è € õ �8ÑÔ€EÝˆu‰:Œ:€Dð(å�E‰lŒlÐÐÐõ �t˜a‘x  RÑ(Ô(ð 	ð 	ˆAØ�QŒx˜%  A¡œ,Ò&Ð&Ø�ð 'ð
 ˆFõ �t˜a‘x  BÑ'Ô'ð 	ð 	ˆAØ�QŒx˜% œ(Ò"Ð"Ø�ð #ð
 # 1œX u¨Q¤xÐˆˆa‰�%˜‘(Ø˜J˜Q˜t™V B˜JÔ'ˆˆa�‰cˆdˆd‰ð+(r   )r    r"   Ú	functoolsr   Úscipy._lib._array_apir   r   Úscipy.integrate._rulesr   r   r$   rC   r   r   ú<module>rR      s¢   ðØ €€€Ø Ð Ð Ð à %Ð %Ð %Ð %Ð %Ð %à <Ð <Ð <Ð <Ð <Ð <Ð <Ð <à 2Ð 2Ð 2Ð 2Ð 2Ð 2ðeð eð eð eð e˜ñ eô eð eðP(ð (ð (ð (ð (r   