
    i!(                     0   S SK rS SKJr  S SKJrJrJrJr  S SK	J
r
Jr  \S 5       r\S 5       r\S 5       r\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rg)    N)register_jitable)
UINT32_MAX
UINT64_MAX
UINT16_MAX	UINT8_MAX)next_uint32next_uint64c                     [         R                  " U 5      nXS-	  -  nXS-	  -  nXS-	  -  nXS-	  -  nXS-	  -  nXS-	  -  nU$ )N                   )npuint64)maxmasks     ]/var/www/html/trading/venv/lib/python3.13/site-packages/numba/np/random/new_random_methods.pygen_maskr      s\    99S>DAIDAIDAIDAIDBJDBJDK    c                 h    US:X  a  XU4$ U(       d  [        U 5      nSnO
US-  nUS-  nUS-  S:g  X44$ )Nr      r   )r   )bitgenoffrngbcntbufs        r   buffered_bounded_boolr      sJ    q#~&!		1WNT&&r   c                 p    U(       d  [        U 5      nSnO
US-  nUS-  n[        R                  " U5      X4$ )N   r   r   )r   r   uint8r   r   r   s      r   buffered_uint8r$   '   s9    &!		88C=$##r   c                 p    U(       d  [        U 5      nSnO
US-  nUS-  n[        R                  " U5      X4$ )Nr   r   )r   r   uint16r#   s      r   buffered_uint16r'   3   s9    &!
	99S>4$$r   c                    [         R                  " U5      [         R                  " S5      -   nUS:w  d   e[        XU5      u  pRn[         R                  " XT-  5      nUS-  nXt:  aX  [         R                  " [        5      U-
  U-  nXx:  a3  [        XU5      u  pRn[         R                  " XT-  5      nUS-  nXx:  a  M3  US-	  X#4$ )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   r   rng_exclnmleftover	thresholds	            r   buffered_bounded_lemire_uint8r0   A   s     xx}rxx{*H4KK "&4LAS
		!,A 4xHhhy)C/8;	#)&<LAS		!,'A4xH #
 64r   c                    [         R                  " U5      [         R                  " S5      -   nUS:w  d   e[        XU5      u  pRn[         R                  " XT-  5      nUS-  nXt:  aX  [         R                  " [        5      U-
  U-  nXx:  a3  [        XU5      u  pRn[         R                  " XT-  5      nUS-  nXx:  a  M3  US-	  X#4$ )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'   uint32r   r*   s	            r   buffered_bounded_lemire_uint16r4   e   s     yy~		!,H6MM #65LAS
		!,A 6zHii
+c1X=	#*6=LAS		!,'A6zH #
 7Dr   c                    [         R                  " U5      [         R                  " S5      -   nUS:w  d   e[         R                  " [        U 5      5      [         R                  " U5      -  nUS-  nXB:  aS  [        U-
  U-  nXE:  aB  [         R                  " [        U 5      5      [         R                  " U5      -  nUS-  nXE:  a  MB  US-	  $ )zf
Generates a random unsigned 32 bit integer bounded
within a given interval using Lemire's rejection.
r       r   )r   r3   r   r   r   )r   r   r+   r-   r.   r/   s         r   buffered_bounded_lemire_uint32r7      s     yy~		!,H: 			+f%&8)<<A :~H#%1	#		+f-.81DDA:~H # Gr   c                    [         R                  " U5      [         R                  " S5      -   nUS:w  d   e[        U 5      n[         R                  " U5      [         R                  " U5      -  nXB:  aP  [        U-
  U-  nXE:  a?  [        U 5      n[         R                  " U5      [         R                  " U5      -  nXE:  a  M?  U[         R                  " S5      -  nUS-	  nU[         R                  " S5      -  nUS-	  n	Xh-  n
Xx-  U
S-	  -   nU[         R                  " S5      -  nUS-	  nXU	-  -  nXy-  U-   US-	  -   nU$ )zf
Generates a random unsigned 64 bit integer bounded
within a given interval using Lemire's rejection.
r       r6   r   )r   r   r	   r   )r   r   r+   xr.   r/   x0x1	rng_excl0	rng_excl1w0tw1w2m1s                  r   bounded_lemire_uint64rD      s-    yy~		!,H%%&%FAyy|bii11H#%1	#F#Ayy|bii&99H # 
RYYz"	"B	
bB299Z00IBI	B
"(#A	
RYYz"	"B	
bBy.B	"	b	)BIr   c                    [         R                  " X4S9nUS:X  a#  [         R                  " U5       H  nXU'   M	     U$ US::  ae  US:X  a/  [         R                  " U5       H  nU[        U 5      -   XV'   M     U$ [         R                  " U5       H  nU[	        X5      -   XV'   M      U$ US:X  a/  [         R                  " U5       H  nU[        U 5      -   XV'   M     U$ [         R                  " U5       H  nU[        X5      -   XV'   M     U$ )zS
Returns a new array of given size with 64 bit integers
bounded by given interval.
dtyper   r6   r9   )r   emptyndindexr   r7   r	   rD   r   lowr   sizerG   outis          r   random_bounded_uint64_fillrO      s	    ((4
%C
axD!AF "" J 

	:ZZ%{622 & J ZZ%=fJJ & J #
#D!A;v..CF " J D!A0==CF " Jr   c                 D   [         R                  " X4S9nUS:X  a#  [         R                  " U5       H  nXU'   M	     U$ US:X  a/  [         R                  " U5       H  nU[        U 5      -   XV'   M     U$ [         R                  " U5       H  nU[	        X5      -   XV'   M     U$ )zS
Returns a new array of given size with 32 bit integers
bounded by given interval.
rF   r   r6   )r   rH   rI   r   r7   rJ   s          r   random_bounded_uint32_fillrQ      s     ((4
%C
axD!AF " J 

	D!A;v..CF "
 J D!A9&FFCF "Jr   c                 `   SnSn[         R                  " X4S9nUS:X  a#  [         R                  " U5       H  nXU'   M	     U$ US:X  a4  [         R                  " U5       H  n[        XU5      u  pnX-   Xx'   M     U$ [         R                  " U5       H  n[	        XXe5      u  pnX-   Xx'   M     U$ )zS
Returns a new array of given size with 16 bit integers
bounded by given interval.
r   rF   r2   )r   rH   rI   r'   r4   
r   rK   r   rL   rG   r   r   rM   rN   vals
             r   random_bounded_uint16_fillrU      s     CD
((4
%C
axD!AF " J 
D!A,V3?NCsYCF " J D!A.v/3: Cs YCF	 "
 Jr   c                 `   SnSn[         R                  " X4S9nUS:X  a#  [         R                  " U5       H  nXU'   M	     U$ US:X  a4  [         R                  " U5       H  n[        XU5      u  pnX-   Xx'   M     U$ [         R                  " U5       H  n[	        XXe5      u  pnX-   Xx'   M     U$ )zR
Returns a new array of given size with 8 bit integers
bounded by given interval.
r   rF   r)   )r   rH   rI   r$   r0   rS   s
             r   random_bounded_uint8_fillrW     s     CD
((4
%C
axD!AF " J 
D!A+F#>NCsYCF " J D!A-f.29 Cs YCF	 "
 Jr   c                     SnSn[         R                  " X4S9n[         R                  " U5       H  n[        XX&U5      u  pnX-   Xx'   M     U$ )z8
Returns a new array of given size with boolean values.
r   rF   )r   rH   rI   r   rS   s
             r   random_bounded_bool_fillrY   .  sQ    
 CD
((4
%CZZ.vCsK3  Jr   c                    X:  a  [        S5      eUS:  a  [        R                  " U5      nU(       d  U[        R                  " S5      -  n[        R                  " U5      nU S:  a  [        R                  " U 5      n X:  a  [        S5      eX:  a  [        S5      egX:  a  [        S5      eX:  a  [        S5      eg)zG
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   r   )rK   highendpointlower_boundupper_bounds        r   _randint_arg_checkr`   <  s     /00
 axyyBIIaL Dii,7))C.C455:IJJ  455:IJJ r   c                    US:X  a  g[         R                  " U5      n[         R                  " [        U5      5      nUS::  aQ  [         R                  " [        U 5      5      U-  nX1:  a)  [         R                  " [        U 5      5      U-  nX1:  a  M)  O([	        U 5      U-  nX1:  a  [	        U 5      U-  nX1:  a  M  [         R                  " U5      $ )Nr   r6   )r   r   r   r   r	   )r   max_valr   values       r   random_intervalrd   [  s    1ii G99Xg&'D:		+f-.5oIIk&12T9E o F#d*o'$.E o 99Ur   )numpyr   numba.core.extendingr   numba.np.random._constantsr   r   r   r   numba.np.random.generator_corer   r	   r   r   r$   r'   r0   r4   r7   rD   rO   rQ   rU   rW   rY   r`   rd    r   r   <module>rj      sI    1? ? C   
' 
' $ $ % %    F    F  4  D  6  &  6  4 
 
 K K<  r   