Ë
    âQ(hŒ  ã                   óX   — 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
y)é    N)Úcached_property)Úarray_namespaceÚ	np_compat)ÚNestedFixedRulec                   ó8   — e Zd ZdZdd„Zed„ «       Zed„ «       Zy)Ú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k7  s|dk7  rt        d«      ‚|| _        || _        || _        |€t
        }t        |j                  d«      «      | _        y )Né   z1Genz-Malik cubature is only defined for ndim >= 2é   é   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        ú`/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/integrate/_rules/_genz_malik.pyÚ__init__zGenzMalikCubature.__init__;   sn   € Ø�!Š8ÜÐPÓQÐQà�QŠ;˜,¨!Ò+Ü%ð 'Eó 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                  j                  t        t        |Ž «      | j                  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                  | j                  j                  |gdz  | j                  j                  ¬«      | j                  j                  |	gd| j                  z  z  | j                  j                  ¬«      | j                  j                  |
gd| j                  z  z  | j                  j                  ¬«      | j                  j                  |gd| j                  dz
  z  | j                  z  z  | j                  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‰i˜‹oˆÜ�i‰i˜‹oˆÜ�i‰i˜‹oˆÜ�i‰i˜‹oˆä�o‰oØ�D—I‘IÑÐÜ" C 6¨D°D·I±IÀ±MÑ,BÑ#BÓCÜ" S D 7¨T°T·Y±YÀ±]Ñ-CÑ#CÓDÜ" C 6¨D°D·I±IÀ±MÑ,BÑ#BÓCÜ" S D 7¨T°T·Y±YÀ±]Ñ-CÑ#CÓDÜ" C¨ :°¸¿	¹	ÀA¹Ñ0FÑ#FÓGÜ" C¨#¨ ;°¸¿¹ÀQ¹Ñ1GÑ#GÓHÜ" S D¨3¨$ <°$¸$¿)¹)Àa¹-Ñ2HÑ#HÓIÜ×Ñ˜s S D˜k°$·)±)Ô<ó

ˆð ˜!˜tŸy™y¨1™}Ñ-°·	±	Ñ9Ñ:¸QÀÇ	Á	¹\ÑIˆ
à—‘—‘Ü”�c�‹OØ—'‘'—/‘/ð  ó 
ˆð
 —‘—‘ ¨¯	©	°:Ð'>Ó?ˆð
 —‘ˆð �—	‘	‰\˜e d¨4¯9©9¡nÑ4¸¸d¿i¹iÈ¹lÑ8JÑKÑLÈuÑTð 	ð �$—)‘)‰|˜sÑ" 4Ñ'ˆØ�$—)‘)‰|  s¨T¯Y©Y¡Ñ 6Ñ7¸%Ñ?ˆØ�$—)‘)‰| Ñ,ˆØˆà—'‘'—.‘.Ø�G‰G�O‰O˜S˜E A™I¨T¯W©W¯_©_ˆOÓ=Ø�G‰G�O‰O˜S˜E Q¨¯©¡]Ñ3¸4¿7¹7¿?¹?ˆOÓKØ�G‰G�O‰O˜S˜E Q¨¯©¡]Ñ3¸4¿7¹7¿?¹?ˆOÓKØ�G‰G�O‰OØ�˜˜dŸi™i¨!™mÑ,¨t¯y©yÑ8Ñ9Ø—g‘g—o‘oð ó ð �G‰G�O‰O˜S˜E Q¨¯	©	¡\Ñ2¸$¿'¹'¿/¹/ˆOÓ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                  j                  t        t        |Ž «      | j                  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                  | j                  j                  |gdz  | j                  j                  ¬«      | j                  j                  |gd| j                  z  z  | j                  j                  ¬«      | j                  j                  |	gd| j                  z  z  | j                  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‰i˜‹oˆÜ�i‰i˜‹oˆÜ�i‰i˜‹oˆä�o‰oØ�D—I‘IÑÐÜ" C 6¨D°D·I±IÀ±MÑ,BÑ#BÓCÜ" S D 7¨T°T·Y±YÀ±]Ñ-CÑ#CÓDÜ" C 6¨D°D·I±IÀ±MÑ,BÑ#BÓCÜ" S D 7¨T°T·Y±YÀ±]Ñ-CÑ#CÓDÜ" C¨ :°¸¿	¹	ÀA¹Ñ0FÑ#FÓGÜ" C¨#¨ ;°¸¿¹ÀQ¹Ñ1GÑ#GÓHÜ" S D¨3¨$ <°$¸$¿)¹)Àa¹-Ñ2HÑ#HÓIó	
ˆð ˜!˜tŸy™y¨1™}Ñ-°·	±	Ñ9Ñ:ˆ
à—‘—‘¤¤S¨# Y£°t·w±w·±�ÓGˆØ—‘—‘ ¨¯	©	°:Ð'>Ó?ˆØ—‘ˆð �$—)‘)‰|  c¨$¯)©)¡mÑ 3°b¸¿¹ÀA¹±oÑ EÑFÈÑLˆØ�$—)‘)‰| 	Ñ*ˆØ�$—)‘)‰|  c¨$¯)©)¡mÑ 3Ñ4°tÑ;ˆØ�$—)‘)‰| Ñ)ˆà—'‘'—.‘.Ø�G‰G�O‰O˜S˜E A™I¨T¯W©W¯_©_ˆOÓ=Ø�G‰G�O‰O˜S˜E Q¨¯©¡]Ñ3¸4¿7¹7¿?¹?ˆOÓKØ�G‰G�O‰O˜S˜E Q¨¯©¡]Ñ3¸4¿7¹7¿?¹?ˆOÓKØ�G‰G�O‰OØ�˜˜dŸi™i¨!™mÑ,¨t¯y©yÑ8Ñ9Ø—g‘g—o‘oð ó ð	"
ó ˆð �gˆ~Ðr   )r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r:   r>   © r   r   r   r      s6   „ ñ-ó^/ð" ñ5ó ð5ðn ñ+ó ñ+r   r   c              #   ó(  K  — t        | «      }t        |«      }	 t        |«      –— t        |dz
  dd«      D ]  }||   ||dz      k  sŒ n yt        |dz
  |d«      D ]  }||   ||   k  sŒ n |   ||   c||<   ||<   |d||z
  d…   ||dz   d Œx­w)zM
    Find the number of distinct permutations of elements of `iterable`.
    r
   éÿÿÿÿr   N)ÚsortedÚlenÚtupleÚrange)ÚiterableÚitemsÚsizeÚiÚjs        r   r$   r$   ³   sÔ   è ø€ ô �8Ó€EÜˆu‹:€Dà
ä�E‹lÒô �t˜a‘x  RÓ(ò 	ˆAØ�Q‰x˜%  A¡™,Ó&Ùð	ð ô �t˜a‘x  BÓ'ò 	ˆAØ�Q‰x˜% ™(Ó"Ùð	ð # 1™X u¨Q¡xÐˆˆa‰�%˜‘(Ø˜J˜Q˜t™V B˜JÑ'ˆˆa�‰cˆdˆð+ ùs   ‚ABÁ	"BÁ,&B)r    r"   Ú	functoolsr   Úscipy._lib._array_apir   r   Úscipy.integrate._rulesr   r   r$   rC   r   r   ú<module>rR      s(   ðÛ Û å %ç <å 2ôe˜ô eóP(r   