ó
    Eñiá  ã                   ó    • S SK r  " S S5      rg)é    Nc            	       ó  • \ rS rSrSrSrSrSS jr   SS\S\	R                  S-  S	\	R                  S-  S
\	R                  4S jjr  SS\S\	R                  S-  S	\	R                  S-  S
\	R                  4S jjrS rS rS rS rSrg)ÚSobolEngineé   aŸ  
The :class:`torch.quasirandom.SobolEngine` is an engine for generating
(scrambled) Sobol sequences. Sobol sequences are an example of low
discrepancy quasi-random sequences.

This implementation of an engine for Sobol sequences is capable of
sampling sequences up to a maximum dimension of 21201. It uses direction
numbers from https://web.maths.unsw.edu.au/~fkuo/sobol/ obtained using the
search criterion D(6) up to the dimension 21201. This is the recommended
choice by the authors.

References:
  - Art B. Owen. Scrambling Sobol and Niederreiter-Xing points.
    Journal of Complexity, 14(4):466-489, December 1998.

  - I. M. Sobol. The distribution of points in a cube and the accurate
    evaluation of integrals.
    Zh. Vychisl. Mat. i Mat. Phys., 7:784-802, 1967.

Args:
    dimension (Int): The dimensionality of the sequence to be drawn
    scramble (bool, optional): Setting this to ``True`` will produce
                               scrambled Sobol sequences. Scrambling is
                               capable of producing better Sobol
                               sequences. Default: ``False``.
    seed (Int, optional): This is the seed for the scrambling. The seed
                          of the random number generator is set to this,
                          if specified. Otherwise, it uses a random seed.
                          Default: ``None``

Examples::

    >>> # xdoctest: +SKIP("unseeded random state")
    >>> soboleng = torch.quasirandom.SobolEngine(dimension=5)
    >>> soboleng.draw(3)
    tensor([[0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
            [0.5000, 0.5000, 0.5000, 0.5000, 0.5000],
            [0.7500, 0.2500, 0.2500, 0.2500, 0.7500]])
é   iÑR  Nc                 óÞ  • XR                   :”  d  US:  a  [        SU R                    S35      eX0l        X l        Xl        [
        R                  " S5      n[
        R                  " XR                  U[
        R                  S9U l
        [
        R                  " U R                  U R                  5        U R                  (       d4  [
        R                  " U R                  U[
        R                  S9U l        OU R                  5         U R                  R                  [
        R                  S9U l        U R                   SU R                  -  -  R#                  SS5      U l        S	U l        g )
Né   z9Supported range of dimensionality for SobolEngine is [1, Ú]Úcpu)ÚdeviceÚdtype)Úmemory_formaté   éÿÿÿÿr   )ÚMAXDIMÚ
ValueErrorÚseedÚscrambleÚ	dimensionÚtorchr   ÚzerosÚMAXBITÚlongÚ
sobolstateÚ_sobol_engine_initialize_state_ÚshiftÚ	_scrambleÚcloneÚcontiguous_formatÚquasiÚreshapeÚ_first_pointÚnum_generated)Úselfr   r   r   r
   s        ÚN/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/quasirandom.pyÚ__init__ÚSobolEngine.__init__2   s  € Ø—{‘{Ó" i°!£mÜð*Ø*.¯+©+¨°að9óð ð
 Œ	Ø ŒØ"Œä�lŠl˜5Ó!ˆäŸ+š+Ø—{‘{¨3´e·j±jñ
ˆŒô 	×-Ò-¨d¯o©o¸t¿~¹~ÔNà�}�}ÜŸš T§^¡^¸CÄuÇzÁzÑRˆD�Jà�N‰NÔà—Z‘Z×%Ñ%´E×4KÑ4KÐ%ÐLˆŒ
Ø!ŸZ™Z¨!¨T¯[©[©.Ñ8×AÑAÀ!ÀRÓHˆÔØˆÕó    ÚnÚoutr   Úreturnc           	      óœ  • Uc  [         R                  " 5       nU R                  S:X  až  US:X  a  U R                  R	                  U5      nOÇ[         R
                  " U R                  US-
  U R                  U R                  U R                  US9u  o@l        [         R                  " U R                  R	                  U5      U4SS9nOK[         R
                  " U R                  UU R                  U R                  U R                  S-
  US9u  o@l        U =R                  U-  sl        Ub"  UR                  U5      R                  U5        U$ U$ )a  
Function to draw a sequence of :attr:`n` points from a Sobol sequence.
Note that the samples are dependent on the previous samples. The size
of the result is :math:`(n, dimension)`.

Args:
    n (Int, optional): The length of sequence of points to draw.
                       Default: 1
    out (Tensor, optional): The output tensor
    dtype (:class:`torch.dtype`, optional): the desired data type of the
                                            returned tensor.
                                            Default: ``None``
r   r   )r   éþÿÿÿ)Údim)r   Úget_default_dtyper"   r!   ÚtoÚ_sobol_engine_drawr   r   r   ÚcatÚ
resize_as_Úcopy_)r#   r(   r)   r   Úresults        r$   ÚdrawÚSobolEngine.drawM   s  € ð& ‰=Ü×+Ò+Ó-ˆEà×Ñ Ó"Ø�A‹vØ×*Ñ*×-Ñ-¨eÓ4‘ä%*×%=Ò%=Ø—J‘JØ˜‘EØ—O‘OØ—N‘NØ×&Ñ&Øñ&Ñ"�œ
ô Ÿš D×$5Ñ$5×$8Ñ$8¸Ó$?ÀÐ#HÈbÑQ‘ä!&×!9Ò!9Ø—
‘
ØØ—‘Ø—‘Ø×"Ñ" QÑ&Øñ"ÑˆF”Jð 	×Ò˜aÑÕà‰?Ø�N‰N˜6Ó"×(Ñ(¨Ô0ØˆJàˆr'   Úmc                 ó¸   • SU-  nU R                   U-   nXUS-
  -  S:X  d,  [        SU R                    SU R                    SU SU S3	5      eU R                  XBUS	9$ )
aù  
Function to draw a sequence of :attr:`2**m` points from a Sobol sequence.
Note that the samples are dependent on the previous samples. The size
of the result is :math:`(2**m, dimension)`.

Args:
    m (Int): The (base2) exponent of the number of points to draw.
    out (Tensor, optional): The output tensor
    dtype (:class:`torch.dtype`, optional): the desired data type of the
                                            returned tensor.
                                            Default: ``None``
r   r   r   zFThe balance properties of Sobol' points require n to be a power of 2. z0 points have been previously generated, then: n=z+2**Ú=zH. If you still want to do this, please use 'SobolEngine.draw()' instead.)r(   r)   r   )r"   r   r5   )r#   r7   r)   r   r(   Útotal_ns         r$   Ú
draw_base2ÚSobolEngine.draw_base2‚   s‡   € ð$ ˆq‰DˆØ×$Ñ$ qÑ(ˆØ Q™;Ñ'¨1Ó,Üð)Ø)-×);Ñ);Ð(<ð =1Ø15×1CÑ1CÐ0DÀDÈÈÈ1ÈWÈIð V0ð0óð ð �y‰y˜1¨UˆyÐ3Ð3r'   c                 ó^   • U R                   R                  U R                  5        SU l        U $ )z6
Function to reset the ``SobolEngine`` to base state.
r   )r   r3   r   r"   )r#   s    r$   ÚresetÚSobolEngine.reset    s'   € ð 	�
‰
×Ñ˜Ÿ™Ô$ØˆÔØˆr'   c                 ód  • U R                   S:X  aF  [        R                  " U R                  US-
  U R                  U R
                  U R                   5        OD[        R                  " U R                  XR                  U R
                  U R                   S-
  5        U =R                   U-  sl         U $ )zÖ
Function to fast-forward the state of the ``SobolEngine`` by
:attr:`n` steps. This is equivalent to drawing :attr:`n` samples
without using the samples.

Args:
    n (Int): The number of steps to fast-forward by.
r   r   )r"   r   Ú_sobol_engine_ff_r   r   r   )r#   r(   s     r$   Úfast_forwardÚSobolEngine.fast_forward¨   sŠ   € ð ×Ñ Ó"Ü×#Ò#Ø—
‘
˜A ™E 4§?¡?°D·N±NÀD×DVÑDVõô ×#Ò#Ø—
‘
˜AŸ™°·±À×@RÑ@RÐUVÑ@Vôð 	×Ò˜aÑÕØˆr'   c                 óˆ  • S nU R                   b0  [        R                  " 5       nUR                  U R                   5        [        R                  " S5      n[        R
                  " SU R                  U R                  4X!S9n[        R                  " U[        R                  " S[        R                  " SU R                  US95      5      U l        U R                  U R                  U R                  4n[        R
                  " SXBUS9R                  5       n[        R                  " U R                  XPR                  5        g )Nr
   r   )r   Ú	generatorr   )r   )r   r   Ú	GeneratorÚmanual_seedr   Úrandintr   r   ÚmvÚpowÚaranger   ÚtrilÚ_sobol_engine_scramble_r   )r#   Úgr
   Ú
shift_intsÚltm_dimsÚltms         r$   r   ÚSobolEngine._scramble¼   sß   € Ø$(ˆØ�9‰9Ñ Ü—’Ó!ˆAØ�M‰M˜$Ÿ)™)Ô$ä�lŠl˜5Ó!ˆô —]’]Ø�—‘ §¡Ð,°Sñ
ˆ
ô —X’XØœŸ	š	 !¤U§\¢\°!°T·[±[ÈÑ%MÓNó
ˆŒ
ð
 —N‘N D§K¡K°·±Ð=ˆÜ�mŠm˜A˜x¸qÑA×FÑFÓHˆä×%Ò% d§o¡o°s¿N¹NÕKr'   c                 óì   • SU R                    3/nU R                  (       a  US/-  nU R                  b  USU R                   3/-  nU R                  R                  S-   SR                  U5      -   S-   $ )Nz
dimension=zscramble=Truezseed=Ú(z, Ú))r   r   r   Ú	__class__Ú__name__Újoin)r#   Ú
fmt_strings     r$   Ú__repr__ÚSobolEngine.__repr__Ò   st   € Ø" 4§>¡>Ð"2Ð3Ð4ˆ
Ø�=�=Ø˜?Ð+Ñ+ˆJØ�9‰9Ñ Ø˜U 4§9¡9 +Ð.Ð/Ñ/ˆJØ�~‰~×&Ñ&¨Ñ,¨t¯y©y¸Ó/DÑDÀsÑJÐJr'   )r!   r   r"   r   r   r   r   r   )FN)r   NN)NN)rW   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r%   Úintr   ÚTensorr   r5   r;   r>   rB   r   rZ   Ú__static_attributes__© r'   r$   r   r      sÅ   † ñ&ðP €FØ€Fôð: Ø#'Ø$(ñ	3àð3ð �\‰\˜DÑ ð3ð �{‰{˜TÑ!ð	3ð
 
�‰õ3ðp $(Ø$(ñ	4àð4ð �\‰\˜DÑ ð4ð �{‰{˜TÑ!ð	4ð
 
�‰õ4ò<òò(Lõ,Kr'   r   )r   r   rc   r'   r$   Ú<module>rd      s   ðó ÷RKò RKr'   