
    xKg'                     H   d dl Zd dlmZmZmZmZ d dlmZ d dl	m
Z
mZmZmZ d dlmZmZ ed        Zed        Zed        Zed	        Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zy)    N)uint64uint32uint16uint8)register_jitable)
UINT32_MAX
UINT64_MAX
UINT16_MAX	UINT8_MAX)next_uint32next_uint64c                 |    t        |       }||dz	  z  }||dz	  z  }||dz	  z  }||dz	  z  }||dz	  z  }||dz	  z  }|S )N                   )r   )maxmasks     b/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/np/random/random_methods.pygen_maskr      sd    #;DDAIDDAIDDAIDDAIDDBJDDBJDK    c                 `    |dk(  r|||fS |st        |       }d}n
|dz  }|dz  }|dz  dk7  ||fS )Nr      r   )r   )bitgenoffrngbcntbufs        r   buffered_bounded_boolr!      sN    qD#~&!		1WNT3&&r   c                 R    |st        |       }d}n
|dz  }|dz  }t        |      ||fS )N   r   r   )r   r   r   r   r    s      r   buffered_uint8r%   (   s7    &!		:tS  r   c                 R    |st        |       }d}n
|dz  }|dz  }t        |      ||fS )Nr   r   )r   r   r$   s      r   buffered_uint16r'   4   s7    &!
	#;c!!r   c                 (   t        |      t        d      z   }|dk7  sJ t        | ||      \  }}}t        ||z        }|dz  }||k  rDt        t              |z
  |z  }||k  r*t        | ||      \  }}}t        ||z        }|dz  }||k  r*|dz	  ||fS )a?  
    Generates a random unsigned 8 bit integer bounded
    within a given interval using Lemire's rejection.

    The buffer acts as storage for a 32 bit integer
    drawn from the associated BitGenerator so that
    multiple integers of smaller bitsize can be generated
    from a single draw of the BitGenerator.
    r      r   )r   r%   r   r   	r   r   r   r    rng_exclnmleftover	thresholds	            r   buffered_bounded_lemire_uint8r0   B   s     SzE!H$H4KK "&$4LAtSq8|A 4xH8I&,8	)#)&$<LAtSq8|$A4xH )#
 64r   c                 (   t        |      t        d      z   }|dk7  sJ t        | ||      \  }}}t        ||z        }|dz  }||k  rDt        t              |z
  |z  }||k  r*t        | ||      \  }}}t        ||z        }|dz  }||k  r*|dz	  ||fS )a@  
    Generates a random unsigned 16 bit integer bounded
    within a given interval using Lemire's rejection.

    The buffer acts as storage for a 32 bit integer
    drawn from the associated BitGenerator so that
    multiple integers of smaller bitsize can be generated
    from a single draw of the BitGenerator.
    r     r   )r   r'   r   r
   r*   s	            r   buffered_bounded_lemire_uint16r3   f   s     c{VAY&H6MM #645LAtSq8|A 6zH8Z(3.(:	)#*64=LAtSq8|$A6zH )#
 7D#r   c                    t        |      t        d      z   }|dk7  sJ t        t        |             t        |      z  }|dz  }||k  r<t        |z
  |z  }||k  r+t        t        |             t        |      z  }|dz  }||k  r+|dz	  S )zr
    Generates a random unsigned 32 bit integer bounded
    within a given interval using Lemire's rejection.
    r       r   )r   r   r   r   )r   r   r+   r-   r.   r/   s         r   buffered_bounded_lemire_uint32r6      s     c{VAY&H: 	{6"#fX&66A :~H8#%1	)#{6*+fX.>>A:~H )# Gr   c                    t        |      t        d      z   }|dk7  sJ t        |       }t        |      t        |      z  }||k  r9t        |z
  |z  }||k  r(t        |       }t        |      t        |      z  }||k  r(|t        d      z  }|dz	  }|t        d      z  }|dz	  }	||z  }
||z  |
dz	  z   }|t        d      z  }|dz	  }|||	z  z  }||	z  |z   |dz	  z   }|S )zr
    Generates a random unsigned 64 bit integer bounded
    within a given interval using Lemire's rejection.
    r       r5   r   )r   r   r	   )r   r   r+   xr.   r/   x0x1	rng_excl0	rng_excl1w0tw1w2m1s                  r   bounded_lemire_uint64rC      s    c{VAY&H%%&%FAay6(++H8#%1	)#F#Aay6(#33H )# 
VJ	B	
bB6*--IBI	iB
Y"(#A	
VJ	B	
bB"y.B	i"	b	)BIr   c                    t        j                  ||      }|dk(  r!t        j                  |      D ]  }|||<   	 |S |dk  r`|dk(  r-t        j                  |      D ]  }|t        |       z   ||<    |S t        j                  |      D ]  }|t	        | |      z   ||<    |S |dk(  r-t        j                  |      D ]  }|t        |       z   ||<    |S t        j                  |      D ]  }|t        | |      z   ||<    |S )z_
    Returns a new array of given size with 64 bit integers
    bounded by given interval.
    dtyper   r5   r8   )npemptyndindexr   r6   r   rC   r   lowr   sizerF   outis          r   random_bounded_uint64_fillrO      s    ((4u
%C
axD!ACF "" J 

	:ZZ%{622A & J ZZ%=fcJJA & J #
#D!A;v..CF " J D!A0==CF " Jr   c                 <   t        j                  ||      }|dk(  r!t        j                  |      D ]  }|||<   	 |S |dk(  r-t        j                  |      D ]  }|t        |       z   ||<    |S t        j                  |      D ]  }|t	        | |      z   ||<    |S )z_
    Returns a new array of given size with 32 bit integers
    bounded by given interval.
    rE   r   r5   )rG   rH   rI   r   r6   rJ   s          r   random_bounded_uint32_fillrQ      s     ((4u
%C
axD!ACF " J 

	D!A;v..CF "
 J D!A9&#FFCF "Jr   c                 d   d}d}t        j                  ||      }|dk(  r!t        j                  |      D ]  }|||<   	 |S |dk(  r5t        j                  |      D ]  }t        | ||      \  }	}}||	z   ||<    |S t        j                  |      D ]  }t	        | |||      \  }	}}||	z   ||<    |S )z_
    Returns a new array of given size with 16 bit integers
    bounded by given interval.
    r   rE   r2   )rG   rH   rI   r'   r3   
r   rK   r   rL   rF   r    r   rM   rN   vals
             r   random_bounded_uint16_fillrU      s     CD
((4u
%C
axD!ACF " J 
D!A,VT3?NCs3YCF " J D!A.vs/3S: Cs 3YCF	 "
 Jr   c                 d   d}d}t        j                  ||      }|dk(  r!t        j                  |      D ]  }|||<   	 |S |dk(  r5t        j                  |      D ]  }t        | ||      \  }	}}||	z   ||<    |S t        j                  |      D ]  }t	        | |||      \  }	}}||	z   ||<    |S )z^
    Returns a new array of given size with 8 bit integers
    bounded by given interval.
    r   rE   r)   )rG   rH   rI   r%   r0   rS   s
             r   random_bounded_uint8_fillrW     s     CD
((4u
%C
axD!ACF " J 
D!A+FD#>NCs3YCF " J D!A-fc.2C9 Cs 3YCF	 "
 Jr   c                     d}d}t        j                  ||      }t        j                  |      D ]  }t        | ||||      \  }	}}||	z   ||<    |S )z@
    Returns a new array of given size with boolean values.
    r   rE   )rG   rH   rI   r!   rS   s
             r   random_bounded_bool_fillrY   /  s]    
 CD
((4u
%CZZ.vsCsKT3sA  Jr   c                    | |k  rt        d      |dkD  rWt        |      }|s|t        d      z  }t        |      }| dkD  rt        |       } ||kD  rt        d      | |kD  rt        d      y||kD  rt        d      | |kD  rt        d      y)zS
    Check that low and high are within the bounds
    for the given datatype.
    zlow is out of boundsr   r   zhigh is out of boundsz*low is greater than high in given intervalN)
ValueErrorr   )rK   highendpointlower_boundupper_bounds        r   _randint_arg_checkr`   =  s     [/00
 axd|F1ID[)7+C+455:IJJ  +455:IJJ r   c                 B   |dk(  ryt        |      }t        t        |            }|dk  rDt        t        |             |z  }||kD  rOt        t        |             |z  }||kD  rt        |      S t        |       |z  }||kD  rt        |       |z  }||kD  rt        |      S )Nr   r5   )r   r   r   r   )r   max_valr   values       r   random_intervalrd   \  s    1WoG(7#$D:{6*+d2go;v./$6E go %=	 F#d*go'$.E go %=r   ) numpyrG   numbar   r   r   r   numba.core.extendingr   numba.np.random._constantsr   r	   r
   r   numba.np.random.generator_corer   r   r   r!   r%   r'   r0   r3   r6   rC   rO   rQ   rU   rW   rY   r`   rd    r   r   <module>rk      sO    / / 1? ? C   
' 
' ! ! " "    F    F  4  D  6  &  6  4 
 
 K K<  r   