ó
    EñiŒ  ã                   óX   • S SK r S SKrS SKJr  S SKJrJr  S SKJr   " S S\5      r	S r
g)é    N)Úcached_property)Úarray_namespaceÚ	np_compat)ÚNestedFixedRulec                   óB   • \ rS rSrSrSS jr\S 5       r\S 5       rSr	g)	ÚGenzMalikCubatureé   aò  
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                 óÈ   • US:  a  [        S5      eUS:w  d  US:w  a  [        S5      eXl        X l        X0l        Uc  [
        n[        UR                  S5      5      U l        g )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        Ú_/home/mande/repo/quber/.venv/lib/python3.13/site-packages/scipy/integrate/_rules/_genz_malik.pyÚ__init__ÚGenzMalikCubature.__init__;   sh   € Ø�!‹8ÜÐPÓQÐQà�Q‹;˜,¨!Ó+Ü%ð 'Eó Fð Fð Œ	ØŒØ(Ôà‰:ÜˆBä! "§(¡(¨1£+Ó.ˆ�ó    c                 óè  • [         R                  " S5      n[         R                  " S5      n[         R                  " S5      n[         R                  " S5      n[        R                  " SU R                  -  /[        U4SU R                  S-
  -  -   5      [        U* 4SU R                  S-
  -  -   5      [        U4SU R                  S-
  -  -   5      [        U* 4SU R                  S-
  -  -   5      [        X34SU R                  S-
  -  -   5      [        X3* 4SU R                  S-
  -  -   5      [        U* U* 4SU R                  S-
  -  -   5      [        R                  " XD* 4U R                  S95	      nSSU R                  S-   -  U R                  -  -   SU R                  -  -   nU R                  R                  [        [        U6 5      U R                  R                  S9nU R                  R                  XpR                  U45      nUR                  nSU R                  -  S	S
U R                  -  -
  SU R                  S-  -  -   -  S-  nSU R                  -  S-  S-  n	SU R                  -  SSU R                  -  -
  -  S-  n
SU R                  -  S-  nSnU R                  R                  U R                  R                  U/S-  U R                  R                  S9U R                  R                  U	/SU R                  -  -  U R                  R                  S9U R                  R                  U
/SU R                  -  -  U R                  R                  S9U R                  R                  U/SU R                  S-
  -  U R                  -  -  U R                  R                  S9U R                  R                  U/SU R                  -  -  U R                  R                  S9/5      nX}4$ )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_weightsÚ#GenzMalikCubature.nodes_and_weightsL   sV  € ô �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 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ð	"
ó 	ˆð ˆ~Ðr   c                 óÖ  • [         R                  " S5      n[         R                  " S5      n[         R                  " S5      n[        R                  " SU R                  -  /[        U4SU R                  S-
  -  -   5      [        U* 4SU R                  S-
  -  -   5      [        U4SU R                  S-
  -  -   5      [        U* 4SU R                  S-
  -  -   5      [        X34SU R                  S-
  -  -   5      [        X3* 4SU R                  S-
  -  -   5      [        U* U* 4SU R                  S-
  -  -   5      5      nSSU R                  S-   -  U R                  -  -   nU R                  R                  [        [        U6 5      U R                  R                  S9nU R                  R                  X`R                  U45      nUR                  nSU R                  -  SSU R                  -  -
  S	U R                  S-  -  -   -  S-  nSU R                  -  S
-  nSU R                  -  SSU R                  -  -
  -  S-  n	SU R                  -  S-  n
U R                  R                  U R                  R                  U/S-  U R                  R                  S9U R                  R                  U/SU R                  -  -  U R                  R                  S9U R                  R                  U	/SU R                  -  -  U R                  R                  S9U R                  R                  U
/SU R                  S-
  -  U R                  -  -  U R                  R                  S9/5      nXk4$ )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/   r0   r1   r3   r4   r5   r6   r7   r8   r9   r;   s               r   Úlower_nodes_and_weightsÚ)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ð ð ð	"
ó ˆð ˆ~Ðr   )r   r   r   r   )r   r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r<   rA   Ú__static_attributes__© r   r   r   r      s6   † ñ-ô^/ð" ñ5ó ð5ðn ñ+ó ó+r   r   c              #   ó$  #   • [        U 5      n[        U5      n [        U5      v •  [        US-
  SS5       H  nX   XS-      :  d  M    O   g[        US-
  US5       H  nX   X   :  d  M    O   UW   X   sX'   X'   USX2-
  S2   XS-   S& Mv  7f)zE
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Ø‰x˜% A¡™,Õ&Ùñ )ð ô �t˜a‘x  BÖ'ˆAØ‰x˜%™(Õ"Ùñ (ð # 1™X u¡xÐˆ‰�%‘(Ø˜J˜Q™V B˜JÑ'ˆ�‰cˆdˆñ+ ùs   ‚ABÁ	 BÁ-#B)r"   r$   Ú	functoolsr   Úscipy._lib._array_apir   r   Úscipy.integrate._rulesr   r   r&   rI   r   r   Ú<module>rX      s(   ðÛ Û å %ç <å 2ôe˜ô eóP(r   