§
    1@Äjü)  ã                   ó(  — d dl Z d dlmZmZmZmZmZmZmZm	Z	m
Z
 d dlZ ej        dej        fdej        fgd¬¦  «        Z e	e¦  «        Zej        xZZej         Z e
eee¬¦  «        d„ ¦   «         Z e
eee¬¦  «        d	„ ¦   «         Z e
eee¬¦  «        d
„ ¦   «         Z e
eee¬¦  «        d„ ¦   «         Z e
eee¬¦  «        d„ ¦   «         Z e
eee¬¦  «        d„ ¦   «         Z e
eee¬¦  «        d„ ¦   «         Z e
eee¬¦  «        d„ ¦   «         Z ej        de j        z  ¦  «        Z ej        de j        z  ¦  «        Z e
eee¬¦  «        d„ ¦   «         Z e
eee¬¦  «        d„ ¦   «         Z  e
eee¬¦  «        d„ ¦   «         Z!dd„Z"dd„Z#dS )é    N)	ÚconfigÚcudaÚfloat32Úfloat64Úuint32Úint64Úuint64Ú
from_dtypeÚjitÚs0Ús1T)Úalign)ÚforceobjÚloopliftÚnopythonc                 óP  — t          |¦  «        }t          |¦  «        }|t          d¦  «        z   }||t          d¦  «        z	  z  t          d¦  «        z  }||t          d¦  «        z	  z  t          d¦  «        z  }||t          d¦  «        z	  z  }|| |         d<   || |         d<   d	S )
aÁ  Use SplitMix64 to generate an xoroshiro128p state from 64-bit seed.

    This ensures that manually set small seeds don't result in a predictable
    initial sequence from the random number generator.

    :type states: 1D array, dtype=xoroshiro128p_dtype
    :param states: array of RNG states
    :type index: uint64
    :param index: offset in states to update
    :type seed: int64
    :param seed: seed value to use when initializing state
    l   |”~åf»q	 é   l   ¹eÉ9´Âz é   l   ëb&ì&‚&	 é   r   r   N)r   r	   r   )ÚstatesÚindexÚseedÚzs       úBC:\Projects\Historical\venv\Lib\site-packages\numba/cuda/random.pyÚinit_xoroshiro128p_stater   .   s§   € õ �%‰LŒL€EÝ�$‰<Œ<€Dà�vÐ(Ñ)Ô)Ñ)€AØ	
ˆa•6˜"‘:”:‰oÑ	¥&Ð);Ñ"<Ô"<Ñ<€AØ	
ˆa•6˜"‘:”:‰oÑ	¥&Ð);Ñ"<Ô"<Ñ<€AØ	ˆQ•&˜‘*”*‰_Ñ€Aà€Fˆ5„M�$ÑØ€Fˆ5„M�$ÑÐÐó    c                 ót   — t          | ¦  «        } t          |¦  «        }| |z  | t          d|z
  ¦  «        z	  z  S )zLeft rotate x by k bits.é@   )r	   r   )ÚxÚks     r   Úrotlr!   H   s8   € õ 	ˆq‰	Œ	€AÝˆq‰	Œ	€AØ�‰F�q�F 2¨¡6™NœNÑ*Ñ+Ð+r   c                 óh  — t          |¦  «        }| |         d         }| |         d         }||z   }||z  }t          t          |t          d¦  «        ¦  «        ¦  «        |z  |t          d¦  «        z  z  | |         d<   t          t          |t          d¦  «        ¦  «        ¦  «        | |         d<   |S )zýReturn the next random uint64 and advance the RNG in states[index].

    :type states: 1D array, dtype=xoroshiro128p_dtype
    :param states: array of RNG states
    :type index: int64
    :param index: offset in states to update
    :rtype: uint64
    r   r   é7   é   é$   )r   r	   r!   r   )r   r   r   r   Úresults        r   Úxoroshiro128p_nextr'   P   s£   € õ �%‰LŒL€EØ	�Œ�tÔ	€BØ	�Œ�tÔ	€BØ�"‰W€Fàˆ"�H€BÝ ¥ b­&°©*¬*Ñ!5Ô!5Ñ6Ô6¸Ñ;¸rÅVÈBÁZÄZÑ?OÑP€Fˆ5„M�$ÑÝ ¥ b­&°©*¬*Ñ!5Ô!5Ñ6Ô6€Fˆ5„M�$Ñà€Mr   c                 óÄ  — t          |¦  «        }t          d¦  «        t          d¦  «        f}t          d¦  «        }t          d¦  «        }t          d¦  «        D ]n}t          d¦  «        D ]\}||         t          d¦  «        t          |¦  «        z  z  r"|| |         d         z  }|| |         d         z  }t	          | |¦  «         Œ]Œo|| |         d<   || |         d<   d	S )
zÛAdvance the RNG in ``states[index]`` by 2**64 steps.

    :type states: 1D array, dtype=xoroshiro128p_dtype
    :param states: array of RNG states
    :type index: int64
    :param index: offset in states to update
    l   ËzKWŸ`u l   "U.XC r   é   r   é   r   r   N)r   r	   Úranger   r'   )r   r   Újumpr   r   ÚiÚbs          r   Úxoroshiro128p_jumpr/   f   sï   € õ �%‰LŒL€EåÐ%Ñ&Ô&­Ð/AÑ(BÔ(BÐC€Då	�‰Œ€BÝ	�‰Œ€Bå�1‰XŒXð .ð .ˆÝ�r‘”ð 	.ð 	.ˆAØ�AŒw�& ™)œ)¥v¨a¡y¤yÑ0Ñ1ð *Ø�f˜U”m DÔ)Ñ)�Ø�f˜U”m DÔ)Ñ)�Ý˜v uÑ-Ô-Ð-Ð-ð		.ð €Fˆ5„M�$ÑØ€Fˆ5„M�$ÑÐÐr   c                 ó¤   — t          | ¦  «        } | t          d¦  «        z	  t          d¦  «        t          d¦  «        t          d¦  «        z  z  z  S )z7Convert uint64 to float64 value in the range [0.0, 1.0)é   r*   é5   )r	   r   r   ©r   s    r   Úuint64_to_unit_float64r4   �   s@   € õ 	ˆq‰	Œ	€AØ•˜‘”‰O¥¨¡
¤
­f°Q©i¬i½6À"¹:¼:Ñ.EÑ FÑGÐGr   c                 óX   — t          | ¦  «        } t          t          | ¦  «        ¦  «        S )z7Convert uint64 to float32 value in the range [0.0, 1.0))r	   r   r4   r3   s    r   Úuint64_to_unit_float32r6   ˆ   s&   € õ 	ˆq‰	Œ	€AÝÕ)¨!Ñ,Ô,Ñ-Ô-Ð-r   c                 óZ   — t          |¦  «        }t          t          | |¦  «        ¦  «        S )zþReturn a float32 in range [0.0, 1.0) and advance ``states[index]``.

    :type states: 1D array, dtype=xoroshiro128p_dtype
    :param states: array of RNG states
    :type index: int64
    :param index: offset in states to update
    :rtype: float32
    )r   r6   r'   ©r   r   s     r   Úxoroshiro128p_uniform_float32r9   �   ó(   € õ �%‰LŒL€EÝ!Õ"4°V¸UÑ"CÔ"CÑDÔDÐDr   c                 óZ   — t          |¦  «        }t          t          | |¦  «        ¦  «        S )zþReturn a float64 in range [0.0, 1.0) and advance ``states[index]``.

    :type states: 1D array, dtype=xoroshiro128p_dtype
    :param states: array of RNG states
    :type index: int64
    :param index: offset in states to update
    :rtype: float64
    )r   r4   r'   r8   s     r   Úxoroshiro128p_uniform_float64r<   �   r:   r   r)   c                 ó  — t          |¦  «        }t          | |¦  «        }t          | |¦  «        }t          j        t	          d¦  «         t          j        |¦  «        z  ¦  «        t          j        t          |z  ¦  «        z  }|S )a–  Return a normally distributed float32 and advance ``states[index]``.

    The return value is drawn from a Gaussian of mean=0 and sigma=1 using the
    Box-Muller transform.  This advances the RNG sequence by two steps.

    :type states: 1D array, dtype=xoroshiro128p_dtype
    :param states: array of RNG states
    :type index: int64
    :param index: offset in states to update
    :rtype: float32
    ç       @)r   r9   ÚmathÚsqrtr   ÚlogÚcosÚTWO_PI_FLOAT32©r   r   Úu1Úu2Úz0s        r   Úxoroshiro128p_normal_float32rH   ¯   ól   € õ �%‰LŒL€Eå	& v¨uÑ	5Ô	5€BÝ	& v¨uÑ	5Ô	5€Bå	Œ•G˜C‘L”L�=¥4¤8¨B¡<¤<Ñ/Ñ	0Ô	0µ4´8½NÈRÑ<OÑ3PÔ3PÑ	P€Bð €Ir   c                 ó  — t          |¦  «        }t          | |¦  «        }t          | |¦  «        }t          j        t	          d¦  «         t          j        |¦  «        z  ¦  «        t          j        t          |z  ¦  «        z  }|S )a–  Return a normally distributed float32 and advance ``states[index]``.

    The return value is drawn from a Gaussian of mean=0 and sigma=1 using the
    Box-Muller transform.  This advances the RNG sequence by two steps.

    :type states: 1D array, dtype=xoroshiro128p_dtype
    :param states: array of RNG states
    :type index: int64
    :param index: offset in states to update
    :rtype: float64
    r>   )r   r9   r?   r@   r   rA   rB   ÚTWO_PI_FLOAT64rD   s        r   Úxoroshiro128p_normal_float64rL   È   rI   r   c                 ó4  — | j         d         }t          |¦  «        }t          |¦  «        }|dk    rdt          | d|¦  «         t          |¦  «        D ]}t	          | d¦  «         Œt          d|¦  «        D ]"}| |dz
           | |<   t	          | |¦  «         Œ!d S d S )Nr   r*   )Úshaper	   r   r+   r/   )r   r   Úsubsequence_startÚnÚ_r-   s         r   Úinit_xoroshiro128p_states_cpurR   á   s½   € àŒ�QŒ€AÝ�$‰<Œ<€DÝÐ0Ñ1Ô1ÐàˆA‚v€vÝ  ¨¨DÑ1Ô1Ð1õ Ð(Ñ)Ô)ð 	*ð 	*ˆAÝ˜v qÑ)Ô)Ð)Ð)õ �q˜!‘”ð 	*ð 	*ˆAØ˜q 1™uœˆF�1‰IÝ˜v qÑ)Ô)Ð)Ð)ð €vð	*ð 	*r   c                 ó–   — t          j        | j        t          ¬¦  «        }t	          |||¦  «         |                      ||¬¦  «         dS )aµ  Initialize RNG states on the GPU for parallel generators.

    This initializes the RNG states so that each state in the array corresponds
    subsequences in the separated by 2**64 steps from each other in the main
    sequence.  Therefore, as long no CUDA thread requests more than 2**64
    random numbers, all of the RNG states produced by this function are
    guaranteed to be independent.

    The subsequence_start parameter can be used to advance the first RNG state
    by a multiple of 2**64 steps.

    :type states: 1D DeviceNDArray, dtype=xoroshiro128p_dtype
    :param states: array of RNG states
    :type seed: uint64
    :param seed: starting seed for list of generators
    )rN   Údtype)ÚstreamN)ÚnpÚemptyrN   Úxoroshiro128p_dtyperR   Úcopy_to_device)r   r   rO   rU   Ú
states_cpus        r   Úinit_xoroshiro128p_statesr[   ô   sM   € õ& ” ¤Õ4GÐHÑHÔH€JÝ! *¨dÐ4EÑFÔFÐFà
×Ò˜*¨VÐÑ4Ô4Ð4Ð4Ð4r   c                 ób   — t          j        | t          |¬¦  «        }t          ||||¦  «         |S )a5  Returns a new device array initialized for n random number generators.

    This initializes the RNG states so that each state in the array corresponds
    subsequences in the separated by 2**64 steps from each other in the main
    sequence.  Therefore, as long no CUDA thread requests more than 2**64
    random numbers, all of the RNG states produced by this function are
    guaranteed to be independent.

    The subsequence_start parameter can be used to advance the first RNG state
    by a multiple of 2**64 steps.

    :type n: int
    :param n: number of RNG states to create
    :type seed: uint64
    :param seed: starting seed for list of generators
    :type subsequence_start: uint64
    :param subsequence_start:
    :type stream: CUDA stream
    :param stream: stream to run initialization kernel on
    )rT   rU   )r   Údevice_arrayrX   r[   )rP   r   rO   rU   r   s        r   Úcreate_xoroshiro128p_statesr^     s6   € õ* Ô˜qÕ(;ÀFÐKÑKÔK€FÝ˜f dÐ,=¸vÑFÔFÐFØ€Mr   )r   r   )$r?   Únumbar   r   r   r   r   r   r	   r
   r   ÚnumpyrV   rT   rX   Úxoroshiro128p_typeÚENABLE_CUDASIMÚ	_forceobjÚ	_loopliftÚ	_nopythonr   r!   r'   r/   r4   r6   r9   r<   ÚpirC   rK   rH   rL   rR   r[   r^   © r   r   ú<module>rh      sM  ðØ €€€ð$ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð $ð Ð Ð Ð ð4 �b”h  r¤yÐ 1°D¸"¼)Ð3DÐEØ%)ð+ñ +ô +Ð à�ZÐ 3Ñ4Ô4Ð ð Ô-Ð -€	ˆIØÔ%Ð%€	ð €ˆi )°iÐ@Ñ@Ô@ðð ñ AÔ@ðð2 €ˆi )°iÐ@Ñ@Ô@ð,ð ,ñ AÔ@ð,ð €ˆi )°iÐ@Ñ@Ô@ðð ñ AÔ@ðð* €ˆi )°iÐ@Ñ@Ô@ðð ñ AÔ@ðð4 €ˆi )°iÐ@Ñ@Ô@ðHð Hñ AÔ@ðHð €ˆi )°iÐ@Ñ@Ô@ð.ð .ñ AÔ@ð.ð €ˆi )°iÐ@Ñ@Ô@ð
Eð 
Eñ AÔ@ð
Eð €ˆi )°iÐ@Ñ@Ô@ð
Eð 
Eñ AÔ@ð
Eð �”˜A ¤™KÑ(Ô(€Ø�”˜A ¤™KÑ(Ô(€ð €ˆi )°iÐ@Ñ@Ô@ðð ñ AÔ@ðð0 €ˆi )°iÐ@Ñ@Ô@ðð ñ AÔ@ðð0 €ˆi )°iÐ@Ñ@Ô@ð*ð *ñ AÔ@ð*ð$5ð 5ð 5ð 5ð2ð ð ð ð ð r   