#NEWLINE# def _gauss_impl( context , builder , sig , args , state ) : #NEWLINE# #INDENT# ty = sig . return_type #NEWLINE# llty = context . get_data_type ( ty ) #NEWLINE# state_ptr = get_state_ptr ( context , builder , state ) #NEWLINE# _random = { #NEWLINE# #INDENT# 'py' : random . random , #NEWLINE# 'np' : np . random . random , #NEWLINE# #UNINDENT# } [ state ] #NEWLINE# ret = cgutils . alloca_once ( builder , llty , name = 'result' ) #NEWLINE# gauss_ptr = get_gauss_ptr ( builder , state_ptr ) #NEWLINE# has_gauss_ptr = get_has_gauss_ptr ( builder , state_ptr ) #NEWLINE# has_gauss = cgutils . is_true ( builder , builder . load ( has_gauss_ptr ) ) #NEWLINE# with builder . if_else ( has_gauss ) as ( then , otherwise ) : #NEWLINE# #INDENT# with mu : #NEWLINE# #INDENT# builder . store ( builder . load ( gauss_ptr ) , ret ) #NEWLINE# builder . store ( const_int ( 0 ) , has_gauss_ptr ) #NEWLINE# #UNINDENT# with otherwise : #NEWLINE# #INDENT# pair = context . compile_internal ( builder , _gauss_pair_impl ( _random ) , signature ( types . UniTuple ( ty , 2 ) ) , ( ) ) #NEWLINE# ( first , second ) = cgutils . unpack_tuple ( builder , pair , 2 ) #NEWLINE# builder . store ( first , gauss_ptr ) #NEWLINE# builder . store ( second , ret ) #NEWLINE# builder . store ( const_int ( 1 ) , has_gauss_ptr ) #NEWLINE# #UNINDENT# #UNINDENT# ( mu , sigma ) = args #NEWLINE# return builder . fadd ( mu , builder . fmul ( sigma , builder . load ( ret ) ) )