Ë
    ßGìj+  ã            	       óž   — d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z d dlmZ ej                  ddd d dd	ej                  d
œd„Zy)é    N)Úvmap)Úrandom)Údtypes)Ú
split_list)Úsparsegš™™™™™É?TF)ÚdtypeÚindices_dtypeÚnseÚn_batchÚn_denseÚunique_indicesÚsorted_indicesÚ	generatorc                ó@  ‡‡‡‡‡‡— t        t        t        j                  |«      «      }t        j                  |«      }t        j                  |«      }|dk  s|dk  s||z   t	        |«      kD  rt        d|›d|›d|›�«      ‚t	        |«      |z
  |z
  Št        t         t        ||‰g«      «      \  }Š}t        j                  |«      }t        j                  ‰«      Šd‰cxk  r‰k  sn t        d‰›d‰› �«      ‚d‰cxk  rdk  r$n n!t        t        j                  ‰‰z  «      «      Št        j                  ‰«      Š|‰fz   |z   }|‰‰fz   }‰€t        j                  «       Š‰t        j                  ‰«      j                  kD  rt        d	‰›d
‰› d�«      ‚t         ˆˆˆˆˆˆfd„«       }t#        j$                  | |dz   «      }|d   |dd }} |	|f||dœ|
¤Ž} ||«      j'                  |«      }t)        j*                  ||f|¬«      }|r|j-                  «       S |S )a²  Generate a random BCOO matrix.

  Args:
    key : PRNG key to be passed to ``generator`` function.
    shape : tuple specifying the shape of the array to be generated.
    dtype : dtype of the array to be generated.
    indices_dtype: dtype of the BCOO indices.
    nse : number of specified elements in the matrix, or if 0 < nse < 1, a
      fraction of sparse dimensions to be specified (default: 0.2).
    n_batch : number of batch dimensions. must satisfy ``n_batch >= 0`` and
      ``n_batch + n_dense <= len(shape)``.
    n_dense : number of batch dimensions. must satisfy ``n_dense >= 0`` and
      ``n_batch + n_dense <= len(shape)``.
    unique_indices : boolean specifying whether indices should be unique
      (default: True).
    sorted_indices : boolean specifying whether indices should be row-sorted in
      lexicographical order (default: False).
    generator : function for generating random values accepting a key, shape,
      and dtype. It defaults to :func:`jax.random.uniform`, and may be any
      function with a similar signature.
    **kwds : additional keyword arguments to pass to ``generator``.

  Returns:
    arr : a sparse.BCOO array with the specified properties.
  r   zInvalid n_batch=z
, n_dense=z for shape=zgot nse=z, expected to be between 0 and é   Nzindices_dtype=z? does not have enough range to generate sparse indices of size Ú.c                 óà   •— ‰st        j                  ‰‰f‰¬«      S t        j                  | ‰‰f‰ ¬«      j	                  ‰«      }t        j
                  t        j                  |‰«      «      S )N)r   )ÚshapeÚreplace)ÚjnpÚemptyr   ÚchoiceÚastypeÚcolumn_stackÚunravel_index)ÚkeyÚflat_indr	   Ún_sparser
   Úsparse_shapeÚsparse_sizer   s     €€€€€€úbC:\Users\Stabi\Downloads\virtual-tryon(1)\venv\Lib\site-packages\jax/experimental/sparse/random.pyÚ_indiceszrandom_bcoo.<locals>._indicesL   sb   ø€ áÜ�Y‰Y˜˜X�¨mÔ<Ð<Ü�}‰}˜S +°c°VØ)7Ð%7ô9ß9?¹ÀÓ9Nð ä×ÑœC×-Ñ-¨h¸ÓEÓFÐFó    )r   r   )r   )ÚtupleÚmapÚoperatorÚindexÚlenÚ
ValueErrorr   ÚmathÚprodÚintÚceilr   Údefault_int_dtyper   ÚiinfoÚmaxr   r   ÚsplitÚreshaper   ÚBCOOÚsort_indices)r   r   r   r	   r
   r   r   r   r   r   ÚkwdsÚbatch_shapeÚdense_shapeÚ
batch_sizeÚ
data_shapeÚindices_shaper"   ÚkeysÚdata_keyÚ
index_keysÚdataÚindicesÚmatr   r   r    s      ``  `               @@@r!   Úrandom_bcoorA      s  ý€ ô8 ””H—N‘N EÓ*Ó
+€%Ü�N‰N˜7Ó#€'Ü�N‰N˜7Ó#€'Øˆq‚[�G˜a’K 7¨WÑ#4´s¸5³zÒ#AÜ
Ð( ˜z¨¨G¨:°\¸5¸(ÐCÓ
DÐDÜ�‹Z˜'Ñ! GÑ+€(Ü+.¬u´jÀÈÐRZÐH[Ó6\Ó+]Ñ(€+ˆ|˜[Ü�y‰y˜Ó%€*Ü—	‘	˜,Ó'€+Ø	
ˆcÔ	�KÔ	Ü
�y˜C˜6Ð!@ÀÀÐNÓ
OÐOØˆ„[ˆq…[Ü
Œd�i‰i˜˜kÑ)Ó*Ó
+€CÜ�‰�sÓ€#à˜c˜VÑ# kÑ1€*Ø  h Ñ/€-ØÐÜ×,Ñ,Ó.€MØ”3—9‘9˜]Ó+×/Ñ/Ò/Ü
˜˜Ð'ð (/Ø/:¨m¸1ð>ó ?ð ?ä÷Gð Gó ðGô 
�‰�c˜:¨™>Ó	*€$Ø˜a™ $ q r (ˆJ€(Ù	�8Ð	C :°UÑ	C¸dÑ	C€$Ù�ZÓ ×(Ñ(¨Ó7€'Ü�‰�T˜7�O¨5Ô1€#Ù-ˆ×	Ñ	Ó	Ð6°3Ð6r#   )r*   r&   Újaxr   r   Újax._srcr   Újax._src.utilr   Ú	jax.numpyÚnumpyr   Újax.experimentalr   Úfloat_ÚuniformrA   © r#   r!   Ú<module>rK      sA   ðó Û å Ý Ý Ý $Ý Ý #ð &)§Z¡Z¸tØ ¨A¸dØ$°·±õ?7r#   