#NEWLINE# def _gamma_complex( x ) : #NEWLINE# #INDENT# if ( not x . imag ) : #NEWLINE# #INDENT# return complex ( _gamma_real ( x . real ) ) #NEWLINE# #UNINDENT# if ( x . real < 0.5 ) : #NEWLINE# #INDENT# return ( pi / ( _sinpi_complex ( x ) * _gamma_complex ( ( 1 - x ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# x -= 1.0 #NEWLINE# r = _lanczos_p [ 0 ] #NEWLINE# for i in range ( 1 , ( _lanczos_g + 2 ) ) : #NEWLINE# #INDENT# r += ( _lanczos_p [ i ] / ( x + i ) ) #NEWLINE# #UNINDENT# t = ( ( x + _lanczos_g ) + 0.5 ) #NEWLINE# return ( ( ( 2.5066282746310007 * ( t ** ( x + 0.5 ) ) ) * cmath . exp ( ( - t ) ) ) * r )