#NEWLINE# def _triangular_impl_3( context , builder , sig , low , high , mode , state ) : #NEWLINE# #INDENT# fltty = sig . return_type #NEWLINE# state_ptr = get_state_ptr ( context , builder , state ) #NEWLINE# randval = get_next_double ( context , builder , state_ptr ) #NEWLINE# def triangular_impl_3( randval , low , high , mode ) : #NEWLINE# #INDENT# if ( high == low ) : #NEWLINE# #INDENT# return low #NEWLINE# #UNINDENT# u = randval #NEWLINE# c = ( ( mode - low ) / ( high - low ) ) #NEWLINE# if ( u > c ) : #NEWLINE# #INDENT# u = ( 1.0 - u ) #NEWLINE# c = ( 1.0 - c ) #NEWLINE# ( low , high ) = ( high , low ) #NEWLINE# #UNINDENT# return ( low + ( ( high - low ) * math . sqrt ( ( u * c ) ) ) ) #NEWLINE# #UNINDENT# return context . compile_internal ( builder , triangular_impl_3 , signature ( * ( ( fltty , ) * 5 ) ) , ( randval , low , high , mode ) )