#NEWLINE# def complex_div_impl( context , builder , sig , args ) : #NEWLINE# #INDENT# def complex_div( a , b ) : #NEWLINE# #INDENT# areal = a . real #NEWLINE# aimag = a . imag #NEWLINE# breal = b . real #NEWLINE# bimag = b . imag #NEWLINE# if ( ( not breal ) and ( not bimag ) ) : #NEWLINE# #INDENT# raise ZeroDivisionError ( 'complex division by zero' ) #NEWLINE# #UNINDENT# if ( abs ( breal ) >= abs ( bimag ) ) : #NEWLINE# #INDENT# if ( not breal ) : #NEWLINE# #INDENT# return complex ( NAN , NAN ) #NEWLINE# #UNINDENT# ratio = ( bimag / breal ) #NEWLINE# denom = ( breal + ( bimag * ratio ) ) #NEWLINE# return complex ( ( ( areal + ( aimag * ratio ) ) / denom ) , ( ( aimag - ( areal * ratio ) ) / denom ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not bimag ) : #NEWLINE# #INDENT# return complex ( NAN , NAN ) #NEWLINE# #UNINDENT# ratio = ( breal / bimag ) #NEWLINE# denom = ( ( breal * ratio ) + bimag ) #NEWLINE# return complex ( ( ( ( a . real * ratio ) + a . imag ) / denom ) , ( ( ( a . imag * ratio ) - a . real ) / denom ) ) #NEWLINE# #UNINDENT# #UNINDENT# res = context . compile_internal ( builder , complex_div , sig , args ) #NEWLINE# return impl_ret_untracked ( context , builder , sig . return_type , args )