<s> """<STR_LIT>""" <EOL> from __future__ import print_function , absolute_import , division <EOL> import math <EOL> from llvmlite . llvmpy import core as lc <EOL> from . . import cgutils , typing , types , lowering , errors <EOL> from . import mathimpl , numbers <EOL> _NPY_LOG2E = <NUM_LIT> <EOL> _NPY_LOG10E = <NUM_LIT> <EOL> _NPY_LOGE2 = <NUM_LIT> <EOL> def _check_arity_and_homogeneity ( sig , args , arity , return_type = None ) : <EOL> """<STR_LIT>""" <EOL> assert len ( args ) == arity <EOL> assert len ( sig . args ) == arity <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> if return_type is None : <EOL> return_type = ty <EOL> if not ( all ( arg == ty for arg in sig . args ) and sig . return_type == return_type ) : <EOL> import inspect <EOL> fname = inspect . currentframe ( ) . f_back . f_code . co_name <EOL> msg = '<STR_LIT>' . format ( fname , sig ) <EOL> assert False , msg <EOL> def _call_func_by_name_with_cast ( context , builder , sig , args , <EOL> func_name , ty = types . float64 ) : <EOL> mod = builder . module <EOL> lty = context . get_argument_type ( ty ) <EOL> fnty = lc . Type . function ( lty , [ lty ] * len ( sig . args ) ) <EOL> fn = cgutils . insert_pure_function ( mod , fnty , name = func_name ) <EOL> cast_args = [ context . cast ( builder , arg , argty , ty ) <EOL> for arg , argty in zip ( args , sig . args ) ] <EOL> result = builder . call ( fn , cast_args ) <EOL> return context . cast ( builder , result , types . float64 , sig . return_type ) <EOL> def _dispatch_func_by_name_type ( context , builder , sig , args , table , user_name ) : <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> try : <EOL> func_name = table [ ty ] <EOL> except KeyError as e : <EOL> msg = "<STR_LIT>" . format ( user_name , str ( e ) ) <EOL> raise errors . LoweringError ( msg ) <EOL> mod = builder . module <EOL> if ty in types . complex_domain : <EOL> out = context . make_complex ( builder , ty ) <EOL> ptrargs = [ cgutils . alloca_once_value ( builder , arg ) <EOL> for arg in args ] <EOL> call_args = [ out . _getpointer ( ) ] + ptrargs <EOL> call_argtys = [ ty ] + list ( sig . args ) <EOL> call_argltys = [ context . get_value_type ( ty ) . as_pointer ( ) <EOL> for ty in call_argtys ] <EOL> fnty = lc . Type . function ( lc . Type . void ( ) , call_argltys ) <EOL> fn = mod . get_or_insert_function ( fnty , name = func_name ) <EOL> builder . call ( fn , call_args ) <EOL> retval = builder . load ( call_args [ <NUM_LIT:0> ] ) <EOL> else : <EOL> argtypes = [ context . get_argument_type ( aty ) for aty in sig . args ] <EOL> restype = context . get_argument_type ( sig . return_type ) <EOL> fnty = lc . Type . function ( restype , argtypes ) <EOL> fn = cgutils . insert_pure_function ( mod , fnty , name = func_name ) <EOL> retval = context . call_external_function ( builder , fn , sig . args , args ) <EOL> return retval <EOL> def np_int_sdiv_impl ( context , builder , sig , args ) : <EOL> num , den = args <EOL> lltype = num . type <EOL> assert all ( i . type == lltype for i in args ) , "<STR_LIT>" <EOL> ZERO = lc . Constant . int ( lltype , <NUM_LIT:0> ) <EOL> MINUS_ONE = lc . Constant . int ( lltype , - <NUM_LIT:1> ) <EOL> MIN_INT = lc . Constant . int ( lltype , <NUM_LIT:1> << ( den . type . width - <NUM_LIT:1> ) ) <EOL> den_is_zero = builder . icmp ( lc . ICMP_EQ , ZERO , den ) <EOL> den_is_minus_one = builder . icmp ( lc . ICMP_EQ , MINUS_ONE , den ) <EOL> num_is_min_int = builder . icmp ( lc . ICMP_EQ , MIN_INT , num ) <EOL> could_cause_sigfpe = builder . and_ ( den_is_minus_one , num_is_min_int ) <EOL> force_zero = builder . or_ ( den_is_zero , could_cause_sigfpe ) <EOL> with builder . if_else ( force_zero , likely = False ) as ( then , otherwise ) : <EOL> with then : <EOL> bb_then = builder . basic_block <EOL> with otherwise : <EOL> bb_otherwise = builder . basic_block <EOL> div = builder . sdiv ( num , den ) <EOL> mod = builder . srem ( num , den ) <EOL> num_gt_zero = builder . icmp ( lc . ICMP_SGT , num , ZERO ) <EOL> den_gt_zero = builder . icmp ( lc . ICMP_SGT , den , ZERO ) <EOL> not_same_sign = builder . xor ( num_gt_zero , den_gt_zero ) <EOL> mod_not_zero = builder . icmp ( lc . ICMP_NE , mod , ZERO ) <EOL> needs_fixing = builder . and_ ( not_same_sign , mod_not_zero ) <EOL> fix_value = builder . select ( needs_fixing , MINUS_ONE , ZERO ) <EOL> result_otherwise = builder . add ( div , fix_value ) <EOL> result = builder . phi ( lltype ) <EOL> result . add_incoming ( ZERO , bb_then ) <EOL> result . add_incoming ( result_otherwise , bb_otherwise ) <EOL> return result <EOL> def np_int_srem_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> num , den = args <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> lty = num . type <EOL> ZERO = context . get_constant ( ty , <NUM_LIT:0> ) <EOL> den_not_zero = builder . icmp ( lc . ICMP_NE , ZERO , den ) <EOL> bb_no_if = builder . basic_block <EOL> with cgutils . if_unlikely ( builder , den_not_zero ) : <EOL> bb_if = builder . basic_block <EOL> mod = builder . srem ( num , den ) <EOL> num_gt_zero = builder . icmp ( lc . ICMP_SGT , num , ZERO ) <EOL> den_gt_zero = builder . icmp ( lc . ICMP_SGT , den , ZERO ) <EOL> not_same_sign = builder . xor ( num_gt_zero , den_gt_zero ) <EOL> mod_not_zero = builder . icmp ( lc . ICMP_NE , mod , ZERO ) <EOL> needs_fixing = builder . and_ ( not_same_sign , mod_not_zero ) <EOL> fix_value = builder . select ( needs_fixing , den , ZERO ) <EOL> final_mod = builder . add ( fix_value , mod ) <EOL> result = builder . phi ( lty ) <EOL> result . add_incoming ( ZERO , bb_no_if ) <EOL> result . add_incoming ( final_mod , bb_if ) <EOL> return result <EOL> def np_int_udiv_impl ( context , builder , sig , args ) : <EOL> num , den = args <EOL> lltype = num . type <EOL> assert all ( i . type == lltype for i in args ) , "<STR_LIT>" <EOL> ZERO = lc . Constant . int ( lltype , <NUM_LIT:0> ) <EOL> div_by_zero = builder . icmp ( lc . ICMP_EQ , ZERO , den ) <EOL> with builder . if_else ( div_by_zero , likely = False ) as ( then , otherwise ) : <EOL> with then : <EOL> bb_then = builder . basic_block <EOL> with otherwise : <EOL> div = builder . udiv ( num , den ) <EOL> bb_otherwise = builder . basic_block <EOL> result = builder . phi ( lltype ) <EOL> result . add_incoming ( ZERO , bb_then ) <EOL> result . add_incoming ( div , bb_otherwise ) <EOL> return result <EOL> def np_int_urem_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> num , den = args <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> lty = num . type <EOL> ZERO = context . get_constant ( ty , <NUM_LIT:0> ) <EOL> den_not_zero = builder . icmp ( lc . ICMP_NE , ZERO , den ) <EOL> bb_no_if = builder . basic_block <EOL> with cgutils . if_unlikely ( builder , den_not_zero ) : <EOL> bb_if = builder . basic_block <EOL> mod = builder . srem ( num , den ) <EOL> result = builder . phi ( lty ) <EOL> result . add_incoming ( ZERO , bb_no_if ) <EOL> result . add_incoming ( mod , bb_if ) <EOL> return result <EOL> np_int_fmod_impl = np_int_urem_impl <EOL> def np_real_div_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> return builder . fdiv ( * args ) <EOL> def np_real_mod_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> in1 , in2 = args <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> ZERO = context . get_constant ( ty , <NUM_LIT:0.0> ) <EOL> res = builder . frem ( in1 , in2 ) <EOL> res_ne_zero = builder . fcmp ( lc . FCMP_ONE , res , ZERO ) <EOL> den_lt_zero = builder . fcmp ( lc . FCMP_OLT , in2 , ZERO ) <EOL> res_lt_zero = builder . fcmp ( lc . FCMP_OLT , res , ZERO ) <EOL> needs_fixing = builder . and_ ( res_ne_zero , <EOL> builder . xor ( den_lt_zero , res_lt_zero ) ) <EOL> fix_value = builder . select ( needs_fixing , in2 , ZERO ) <EOL> return builder . fadd ( res , fix_value ) <EOL> def np_real_fmod_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> return builder . frem ( * args ) <EOL> def _fabs ( context , builder , arg ) : <EOL> ZERO = lc . Constant . real ( arg . type , <NUM_LIT:0.0> ) <EOL> arg_negated = builder . fsub ( ZERO , arg ) <EOL> arg_is_negative = builder . fcmp ( lc . FCMP_OLT , arg , ZERO ) <EOL> return builder . select ( arg_is_negative , arg_negated , arg ) <EOL> def np_complex_div_impl ( context , builder , sig , args ) : <EOL> in1 , in2 = [ context . make_complex ( builder , sig . args [ <NUM_LIT:0> ] , value = arg ) <EOL> for arg in args ] <EOL> in1r = in1 . real <EOL> in1i = in1 . imag <EOL> in2r = in2 . real <EOL> in2i = in2 . imag <EOL> ftype = in1r . type <EOL> assert all ( [ i . type == ftype for i in [ in1r , in1i , in2r , in2i ] ] ) , "<STR_LIT>" <EOL> out = context . make_helper ( builder , sig . return_type ) <EOL> ZERO = lc . Constant . real ( ftype , <NUM_LIT:0.0> ) <EOL> ONE = lc . Constant . real ( ftype , <NUM_LIT:1.0> ) <EOL> in2r_abs = _fabs ( context , builder , in2r ) <EOL> in2i_abs = _fabs ( context , builder , in2i ) <EOL> in2r_abs_ge_in2i_abs = builder . fcmp ( lc . FCMP_OGE , in2r_abs , in2i_abs ) <EOL> with builder . if_else ( in2r_abs_ge_in2i_abs ) as ( then , otherwise ) : <EOL> with then : <EOL> in2r_is_zero = builder . fcmp ( lc . FCMP_OEQ , in2r_abs , ZERO ) <EOL> in2i_is_zero = builder . fcmp ( lc . FCMP_OEQ , in2i_abs , ZERO ) <EOL> in2_is_zero = builder . and_ ( in2r_is_zero , in2i_is_zero ) <EOL> with builder . if_else ( in2_is_zero ) as ( inn_then , inn_otherwise ) : <EOL> with inn_then : <EOL> out . real = builder . fdiv ( in1r , in2r_abs ) <EOL> out . imag = builder . fdiv ( in1i , in2i_abs ) <EOL> with inn_otherwise : <EOL> rat = builder . fdiv ( in2i , in2r ) <EOL> tmp1 = builder . fmul ( in2i , rat ) <EOL> tmp2 = builder . fadd ( in2r , tmp1 ) <EOL> scl = builder . fdiv ( ONE , tmp2 ) <EOL> tmp3 = builder . fmul ( in1i , rat ) <EOL> tmp4 = builder . fmul ( in1r , rat ) <EOL> tmp5 = builder . fadd ( in1r , tmp3 ) <EOL> tmp6 = builder . fsub ( in1i , tmp4 ) <EOL> out . real = builder . fmul ( tmp5 , scl ) <EOL> out . imag = builder . fmul ( tmp6 , scl ) <EOL> with otherwise : <EOL> rat = builder . fdiv ( in2r , in2i ) <EOL> tmp1 = builder . fmul ( in2r , rat ) <EOL> tmp2 = builder . fadd ( in2i , tmp1 ) <EOL> scl = builder . fdiv ( ONE , tmp2 ) <EOL> tmp3 = builder . fmul ( in1r , rat ) <EOL> tmp4 = builder . fmul ( in1i , rat ) <EOL> tmp5 = builder . fadd ( tmp3 , in1i ) <EOL> tmp6 = builder . fsub ( tmp4 , in1r ) <EOL> out . real = builder . fmul ( tmp5 , scl ) <EOL> out . imag = builder . fmul ( tmp6 , scl ) <EOL> return out . _getvalue ( ) <EOL> def np_real_logaddexp_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_logaddexp2_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_int_truediv_impl ( context , builder , sig , args ) : <EOL> num , den = args <EOL> lltype = num . type <EOL> assert all ( i . type == lltype for i in args ) , "<STR_LIT>" <EOL> numty , denty = sig . args <EOL> num = context . cast ( builder , num , numty , types . float64 ) <EOL> den = context . cast ( builder , den , denty , types . float64 ) <EOL> return builder . fdiv ( num , den ) <EOL> def np_real_floor_div_impl ( context , builder , sig , args ) : <EOL> res = np_real_div_impl ( context , builder , sig , args ) <EOL> s = typing . signature ( sig . return_type , sig . return_type ) <EOL> return np_real_floor_impl ( context , builder , s , ( res , ) ) <EOL> def np_complex_floor_div_impl ( context , builder , sig , args ) : <EOL> float_kind = sig . args [ <NUM_LIT:0> ] . underlying_float <EOL> floor_sig = typing . signature ( float_kind , float_kind ) <EOL> in1 , in2 = [ context . make_complex ( builder , sig . args [ <NUM_LIT:0> ] , value = arg ) <EOL> for arg in args ] <EOL> in1r = in1 . real <EOL> in1i = in1 . imag <EOL> in2r = in2 . real <EOL> in2i = in2 . imag <EOL> ftype = in1r . type <EOL> assert all ( [ i . type == ftype for i in [ in1r , in1i , in2r , in2i ] ] ) , "<STR_LIT>" <EOL> ZERO = lc . Constant . real ( ftype , <NUM_LIT:0.0> ) <EOL> out = context . make_helper ( builder , sig . return_type ) <EOL> out . imag = ZERO <EOL> in2r_abs = _fabs ( context , builder , in2r ) <EOL> in2i_abs = _fabs ( context , builder , in2i ) <EOL> in2r_abs_ge_in2i_abs = builder . fcmp ( lc . FCMP_OGE , in2r_abs , in2i_abs ) <EOL> with builder . if_else ( in2r_abs_ge_in2i_abs ) as ( then , otherwise ) : <EOL> with then : <EOL> rat = builder . fdiv ( in2i , in2r ) <EOL> tmp1 = builder . fmul ( in1i , rat ) <EOL> tmp2 = builder . fmul ( in2i , rat ) <EOL> tmp3 = builder . fadd ( in1r , tmp1 ) <EOL> tmp4 = builder . fadd ( in2r , tmp2 ) <EOL> tmp5 = builder . fdiv ( tmp3 , tmp4 ) <EOL> out . real = np_real_floor_impl ( context , builder , floor_sig , ( tmp5 , ) ) <EOL> with otherwise : <EOL> rat = builder . fdiv ( in2r , in2i ) <EOL> tmp1 = builder . fmul ( in1r , rat ) <EOL> tmp2 = builder . fmul ( in2r , rat ) <EOL> tmp3 = builder . fadd ( in1i , tmp1 ) <EOL> tmp4 = builder . fadd ( in2i , tmp2 ) <EOL> tmp5 = builder . fdiv ( tmp3 , tmp4 ) <EOL> out . real = np_real_floor_impl ( context , builder , floor_sig , ( tmp5 , ) ) <EOL> return out . _getvalue ( ) <EOL> def np_int_power_impl ( context , builder , sig , args ) : <EOL> assert len ( args ) == <NUM_LIT:2> <EOL> assert len ( sig . args ) == <NUM_LIT:2> <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> assert all ( arg == ty for arg in sig . args ) and sig . return_type == ty <EOL> return _call_func_by_name_with_cast ( context , builder , sig , args , <EOL> '<STR_LIT>' , types . float64 ) <EOL> def np_real_power_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_power_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> dispatch_table = { <EOL> types . complex64 : '<STR_LIT>' , <EOL> types . complex128 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_sign_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> op = args [ <NUM_LIT:0> ] <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> ZERO = context . get_constant ( float_ty , <NUM_LIT:0.0> ) <EOL> ONE = context . get_constant ( float_ty , <NUM_LIT:1.0> ) <EOL> MINUS_ONE = context . get_constant ( float_ty , - <NUM_LIT:1.0> ) <EOL> NAN = context . get_constant ( float_ty , float ( '<STR_LIT>' ) ) <EOL> result = context . make_complex ( builder , ty ) <EOL> result . real = ZERO <EOL> result . imag = ZERO <EOL> cmp_sig = typing . signature ( types . boolean , * [ ty ] * <NUM_LIT:2> ) <EOL> cmp_args = [ op , result . _getvalue ( ) ] <EOL> arg1_ge_arg2 = np_complex_ge_impl ( context , builder , cmp_sig , cmp_args ) <EOL> arg1_eq_arg2 = np_complex_eq_impl ( context , builder , cmp_sig , cmp_args ) <EOL> arg1_lt_arg2 = np_complex_lt_impl ( context , builder , cmp_sig , cmp_args ) <EOL> real_when_ge = builder . select ( arg1_eq_arg2 , ZERO , ONE ) <EOL> real_when_nge = builder . select ( arg1_lt_arg2 , MINUS_ONE , NAN ) <EOL> result . real = builder . select ( arg1_ge_arg2 , real_when_ge , real_when_nge ) <EOL> return result . _getvalue ( ) <EOL> def np_real_rint_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> return mathimpl . call_fp_intrinsic ( builder , '<STR_LIT>' , args ) <EOL> def np_complex_rint_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> in1 = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> inner_sig = typing . signature ( * [ float_ty ] * <NUM_LIT:2> ) <EOL> out . real = np_real_rint_impl ( context , builder , inner_sig , [ in1 . real ] ) <EOL> out . imag = np_real_rint_impl ( context , builder , inner_sig , [ in1 . imag ] ) <EOL> return out . _getvalue ( ) <EOL> def np_real_exp_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_exp_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . complex64 : '<STR_LIT>' , <EOL> types . complex128 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_exp2_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_exp2_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> in1 = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> tmp = context . make_complex ( builder , ty ) <EOL> loge2 = context . get_constant ( float_ty , _NPY_LOGE2 ) <EOL> tmp . real = builder . fmul ( loge2 , in1 . real ) <EOL> tmp . imag = builder . fmul ( loge2 , in1 . imag ) <EOL> return np_complex_exp_impl ( context , builder , sig , [ tmp . _getvalue ( ) ] ) <EOL> def np_real_log_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_log_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . complex64 : '<STR_LIT>' , <EOL> types . complex128 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_log2_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_log2_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> tmp = np_complex_log_impl ( context , builder , sig , args ) <EOL> tmp = context . make_complex ( builder , ty , value = tmp ) <EOL> log2e = context . get_constant ( float_ty , _NPY_LOG2E ) <EOL> tmp . real = builder . fmul ( log2e , tmp . real ) <EOL> tmp . imag = builder . fmul ( log2e , tmp . imag ) <EOL> return tmp . _getvalue ( ) <EOL> def np_real_log10_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_log10_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> tmp = np_complex_log_impl ( context , builder , sig , args ) <EOL> tmp = context . make_complex ( builder , ty , value = tmp ) <EOL> log10e = context . get_constant ( float_ty , _NPY_LOG10E ) <EOL> tmp . real = builder . fmul ( log10e , tmp . real ) <EOL> tmp . imag = builder . fmul ( log10e , tmp . imag ) <EOL> return tmp . _getvalue ( ) <EOL> def np_real_expm1_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_expm1_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> float_unary_sig = typing . signature ( * [ float_ty ] * <NUM_LIT:2> ) <EOL> MINUS_ONE = context . get_constant ( float_ty , - <NUM_LIT:1.0> ) <EOL> in1 = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> a = np_real_exp_impl ( context , builder , float_unary_sig , [ in1 . real ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> cos_imag = np_real_cos_impl ( context , builder , float_unary_sig , [ in1 . imag ] ) <EOL> sin_imag = np_real_sin_impl ( context , builder , float_unary_sig , [ in1 . imag ] ) <EOL> tmp = builder . fmul ( a , cos_imag ) <EOL> out . imag = builder . fmul ( a , sin_imag ) <EOL> out . real = builder . fadd ( tmp , MINUS_ONE ) <EOL> return out . _getvalue ( ) <EOL> def np_real_log1p_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_log1p_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> float_unary_sig = typing . signature ( * [ float_ty ] * <NUM_LIT:2> ) <EOL> float_binary_sig = typing . signature ( * [ float_ty ] * <NUM_LIT:3> ) <EOL> ONE = context . get_constant ( float_ty , <NUM_LIT:1.0> ) <EOL> in1 = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> real_plus_one = builder . fadd ( in1 . real , ONE ) <EOL> l = np_real_hypot_impl ( context , builder , float_binary_sig , <EOL> [ real_plus_one , in1 . imag ] ) <EOL> out . imag = np_real_atan2_impl ( context , builder , float_binary_sig , <EOL> [ in1 . imag , real_plus_one ] ) <EOL> out . real = np_real_log_impl ( context , builder , float_unary_sig , [ l ] ) <EOL> return out . _getvalue ( ) <EOL> def np_real_sqrt_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_sqrt_impl ( context , builder , sig , args ) : <EOL> dispatch_table = { <EOL> types . complex64 : '<STR_LIT>' , <EOL> types . complex128 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_int_square_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> return builder . mul ( args [ <NUM_LIT:0> ] , args [ <NUM_LIT:0> ] ) <EOL> def np_real_square_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> return builder . fmul ( args [ <NUM_LIT:0> ] , args [ <NUM_LIT:0> ] ) <EOL> def np_complex_square_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> binary_sig = typing . signature ( * [ sig . return_type ] * <NUM_LIT:3> ) <EOL> return numbers . complex_mul_impl ( context , builder , binary_sig , <EOL> [ args [ <NUM_LIT:0> ] , args [ <NUM_LIT:0> ] ] ) <EOL> def np_int_reciprocal_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . return_type <EOL> binary_sig = typing . signature ( * [ ty ] * <NUM_LIT:3> ) <EOL> in_as_float = context . cast ( builder , args [ <NUM_LIT:0> ] , ty , types . float64 ) <EOL> ONE = context . get_constant ( types . float64 , <NUM_LIT:1> ) <EOL> result_as_float = builder . fdiv ( ONE , in_as_float ) <EOL> return context . cast ( builder , result_as_float , types . float64 , ty ) <EOL> def np_real_reciprocal_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ONE = context . get_constant ( sig . return_type , <NUM_LIT:1.0> ) <EOL> return builder . fdiv ( ONE , args [ <NUM_LIT:0> ] ) <EOL> def np_complex_reciprocal_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> ZERO = context . get_constant ( float_ty , <NUM_LIT:0.0> ) <EOL> ONE = context . get_constant ( float_ty , <NUM_LIT:1.0> ) <EOL> in1 = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> in1r = in1 . real <EOL> in1i = in1 . imag <EOL> in1r_abs = _fabs ( context , builder , in1r ) <EOL> in1i_abs = _fabs ( context , builder , in1i ) <EOL> in1i_abs_le_in1r_abs = builder . fcmp ( lc . FCMP_OLE , in1i_abs , in1r_abs ) <EOL> with builder . if_else ( in1i_abs_le_in1r_abs ) as ( then , otherwise ) : <EOL> with then : <EOL> r = builder . fdiv ( in1i , in1r ) <EOL> tmp0 = builder . fmul ( in1i , r ) <EOL> d = builder . fadd ( in1r , tmp0 ) <EOL> inv_d = builder . fdiv ( ONE , d ) <EOL> minus_r = builder . fsub ( ZERO , r ) <EOL> out . real = inv_d <EOL> out . imag = builder . fmul ( minus_r , inv_d ) <EOL> with otherwise : <EOL> r = builder . fdiv ( in1r , in1i ) <EOL> tmp0 = builder . fmul ( in1r , r ) <EOL> d = builder . fadd ( tmp0 , in1i ) <EOL> inv_d = builder . fdiv ( ONE , d ) <EOL> out . real = builder . fmul ( r , inv_d ) <EOL> out . imag = builder . fsub ( ZERO , inv_d ) <EOL> return out . _getvalue ( ) <EOL> def np_real_sin_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_sin_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . complex64 : '<STR_LIT>' , <EOL> types . complex128 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_cos_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_cos_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . complex64 : '<STR_LIT>' , <EOL> types . complex128 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_tan_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_tan_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> float_unary_sig = typing . signature ( * [ float_ty ] * <NUM_LIT:2> ) <EOL> ONE = context . get_constant ( float_ty , <NUM_LIT:1.0> ) <EOL> x = context . make_complex ( builder , ty , args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> xr = x . real <EOL> xi = x . imag <EOL> sr = np_real_sin_impl ( context , builder , float_unary_sig , [ xr ] ) <EOL> cr = np_real_cos_impl ( context , builder , float_unary_sig , [ xr ] ) <EOL> shi = np_real_sinh_impl ( context , builder , float_unary_sig , [ xi ] ) <EOL> chi = np_real_cosh_impl ( context , builder , float_unary_sig , [ xi ] ) <EOL> rs = builder . fmul ( sr , chi ) <EOL> is_ = builder . fmul ( cr , shi ) <EOL> rc = builder . fmul ( cr , chi ) <EOL> ic = builder . fmul ( sr , shi ) <EOL> sqr_rc = builder . fmul ( rc , rc ) <EOL> sqr_ic = builder . fmul ( ic , ic ) <EOL> d = builder . fadd ( sqr_rc , sqr_ic ) <EOL> inv_d = builder . fdiv ( ONE , d ) <EOL> rs_rc = builder . fmul ( rs , rc ) <EOL> is_ic = builder . fmul ( is_ , ic ) <EOL> is_rc = builder . fmul ( is_ , rc ) <EOL> rs_ic = builder . fmul ( rs , ic ) <EOL> numr = builder . fsub ( rs_rc , is_ic ) <EOL> numi = builder . fadd ( is_rc , rs_ic ) <EOL> out . real = builder . fmul ( numr , inv_d ) <EOL> out . imag = builder . fmul ( numi , inv_d ) <EOL> return out . _getvalue ( ) <EOL> def np_real_asin_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def _complex_expand_series ( context , builder , ty , initial , x , coefs ) : <EOL> """<STR_LIT>""" <EOL> assert ty in types . complex_domain <EOL> binary_sig = typing . signature ( * [ ty ] * <NUM_LIT:3> ) <EOL> accum = context . make_complex ( builder , ty , value = initial ) <EOL> ONE = context . get_constant ( ty . underlying_float , <NUM_LIT:1.0> ) <EOL> for coef in reversed ( coefs ) : <EOL> constant = context . get_constant ( ty . underlying_float , coef ) <EOL> value = numbers . complex_mul_impl ( context , builder , binary_sig , <EOL> [ x , accum . _getvalue ( ) ] ) <EOL> accum . _setvalue ( value ) <EOL> accum . real = builder . fadd ( ONE , builder . fmul ( accum . real , constant ) ) <EOL> accum . imag = builder . fmul ( accum . imag , constant ) <EOL> return accum . _getvalue ( ) <EOL> def np_complex_asin_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> epsilon = context . get_constant ( float_ty , <NUM_LIT> ) <EOL> x = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> abs_r = _fabs ( context , builder , x . real ) <EOL> abs_i = _fabs ( context , builder , x . imag ) <EOL> abs_r_gt_epsilon = builder . fcmp ( lc . FCMP_OGT , abs_r , epsilon ) <EOL> abs_i_gt_epsilon = builder . fcmp ( lc . FCMP_OGT , abs_i , epsilon ) <EOL> any_gt_epsilon = builder . or_ ( abs_r_gt_epsilon , abs_i_gt_epsilon ) <EOL> complex_binary_sig = typing . signature ( * [ ty ] * <NUM_LIT:3> ) <EOL> with builder . if_else ( any_gt_epsilon ) as ( then , otherwise ) : <EOL> with then : <EOL> I = context . get_constant_generic ( builder , ty , <NUM_LIT> ) <EOL> ONE = context . get_constant_generic ( builder , ty , <NUM_LIT:1.0> + <NUM_LIT> ) <EOL> ZERO = context . get_constant_generic ( builder , ty , <NUM_LIT:0.0> + <NUM_LIT> ) <EOL> xx = np_complex_square_impl ( context , builder , sig , args ) <EOL> one_minus_xx = numbers . complex_sub_impl ( context , builder , <EOL> complex_binary_sig , <EOL> [ ONE , xx ] ) <EOL> sqrt_one_minus_xx = np_complex_sqrt_impl ( context , builder , sig , <EOL> [ one_minus_xx ] ) <EOL> ix = numbers . complex_mul_impl ( context , builder , <EOL> complex_binary_sig , <EOL> [ I , args [ <NUM_LIT:0> ] ] ) <EOL> log_arg = numbers . complex_add_impl ( context , builder , sig , <EOL> [ ix , sqrt_one_minus_xx ] ) <EOL> log = np_complex_log_impl ( context , builder , sig , [ log_arg ] ) <EOL> ilog = numbers . complex_mul_impl ( context , builder , <EOL> complex_binary_sig , <EOL> [ I , log ] ) <EOL> out . _setvalue ( numbers . complex_sub_impl ( context , builder , <EOL> complex_binary_sig , <EOL> [ ZERO , ilog ] ) ) <EOL> with otherwise : <EOL> coef_dict = { <EOL> types . complex64 : [ <NUM_LIT:1.0> / <NUM_LIT> , <NUM_LIT> / <NUM_LIT> ] , <EOL> types . complex128 : [ <NUM_LIT:1.0> / <NUM_LIT> , <NUM_LIT> / <NUM_LIT> , <NUM_LIT> / <NUM_LIT> ] , <EOL> } <EOL> xx = np_complex_square_impl ( context , builder , sig , args ) <EOL> ONE = context . get_constant_generic ( builder , ty , <NUM_LIT:1.0> + <NUM_LIT> ) <EOL> tmp = _complex_expand_series ( context , builder , ty , <EOL> ONE , xx , coef_dict [ ty ] ) <EOL> out . _setvalue ( numbers . complex_mul_impl ( context , builder , <EOL> complex_binary_sig , <EOL> [ args [ <NUM_LIT:0> ] , tmp ] ) ) <EOL> return out . _getvalue ( ) <EOL> def np_real_acos_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_atan_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_atan_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> epsilon = context . get_constant ( float_ty , <NUM_LIT> ) <EOL> x = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> abs_r = _fabs ( context , builder , x . real ) <EOL> abs_i = _fabs ( context , builder , x . imag ) <EOL> abs_r_gt_epsilon = builder . fcmp ( lc . FCMP_OGT , abs_r , epsilon ) <EOL> abs_i_gt_epsilon = builder . fcmp ( lc . FCMP_OGT , abs_i , epsilon ) <EOL> any_gt_epsilon = builder . or_ ( abs_r_gt_epsilon , abs_i_gt_epsilon ) <EOL> binary_sig = typing . signature ( * [ ty ] * <NUM_LIT:3> ) <EOL> with builder . if_else ( any_gt_epsilon ) as ( then , otherwise ) : <EOL> with then : <EOL> I = context . get_constant_generic ( builder , ty , <NUM_LIT:0.0> + <NUM_LIT> ) <EOL> I2 = context . get_constant_generic ( builder , ty , <NUM_LIT:0.0> + <NUM_LIT> ) <EOL> den = numbers . complex_sub_impl ( context , builder , binary_sig , <EOL> [ I , args [ <NUM_LIT:0> ] ] ) <EOL> num = numbers . complex_add_impl ( context , builder , binary_sig , <EOL> [ I , args [ <NUM_LIT:0> ] ] ) <EOL> div = np_complex_div_impl ( context , builder , binary_sig , <EOL> [ num , den ] ) <EOL> log = np_complex_log_impl ( context , builder , sig , [ div ] ) <EOL> res = numbers . complex_mul_impl ( context , builder , binary_sig , <EOL> [ I2 , log ] ) <EOL> out . _setvalue ( res ) <EOL> with otherwise : <EOL> coef_dict = { <EOL> types . complex64 : [ - <NUM_LIT:1.0> / <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ] , <EOL> types . complex128 : [ - <NUM_LIT:1.0> / <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ] , <EOL> } <EOL> xx = np_complex_square_impl ( context , builder , sig , args ) <EOL> ONE = context . get_constant_generic ( builder , ty , <NUM_LIT:1.0> + <NUM_LIT> ) <EOL> tmp = _complex_expand_series ( context , builder , ty , <EOL> ONE , xx , coef_dict [ ty ] ) <EOL> out . _setvalue ( numbers . complex_mul_impl ( context , builder , <EOL> binary_sig , <EOL> [ args [ <NUM_LIT:0> ] , tmp ] ) ) <EOL> return out . _getvalue ( ) <EOL> def np_real_atan2_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_hypot_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_sinh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_sinh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> fty = ty . underlying_float <EOL> fsig1 = typing . signature ( * [ fty ] * <NUM_LIT:2> ) <EOL> x = context . make_complex ( builder , ty , args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> xr = x . real <EOL> xi = x . imag <EOL> sxi = np_real_sin_impl ( context , builder , fsig1 , [ xi ] ) <EOL> shxr = np_real_sinh_impl ( context , builder , fsig1 , [ xr ] ) <EOL> cxi = np_real_cos_impl ( context , builder , fsig1 , [ xi ] ) <EOL> chxr = np_real_cosh_impl ( context , builder , fsig1 , [ xr ] ) <EOL> out . real = builder . fmul ( cxi , shxr ) <EOL> out . imag = builder . fmul ( sxi , chxr ) <EOL> return out . _getvalue ( ) <EOL> def np_real_cosh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_cosh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> fty = ty . underlying_float <EOL> fsig1 = typing . signature ( * [ fty ] * <NUM_LIT:2> ) <EOL> x = context . make_complex ( builder , ty , args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> xr = x . real <EOL> xi = x . imag <EOL> cxi = np_real_cos_impl ( context , builder , fsig1 , [ xi ] ) <EOL> chxr = np_real_cosh_impl ( context , builder , fsig1 , [ xr ] ) <EOL> sxi = np_real_sin_impl ( context , builder , fsig1 , [ xi ] ) <EOL> shxr = np_real_sinh_impl ( context , builder , fsig1 , [ xr ] ) <EOL> out . real = builder . fmul ( cxi , chxr ) <EOL> out . imag = builder . fmul ( sxi , shxr ) <EOL> return out . _getvalue ( ) <EOL> def np_real_tanh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_tanh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> fty = ty . underlying_float <EOL> fsig1 = typing . signature ( * [ fty ] * <NUM_LIT:2> ) <EOL> ONE = context . get_constant ( fty , <NUM_LIT:1.0> ) <EOL> x = context . make_complex ( builder , ty , args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> xr = x . real <EOL> xi = x . imag <EOL> si = np_real_sin_impl ( context , builder , fsig1 , [ xi ] ) <EOL> ci = np_real_cos_impl ( context , builder , fsig1 , [ xi ] ) <EOL> shr = np_real_sinh_impl ( context , builder , fsig1 , [ xr ] ) <EOL> chr_ = np_real_cosh_impl ( context , builder , fsig1 , [ xr ] ) <EOL> rs = builder . fmul ( ci , shr ) <EOL> is_ = builder . fmul ( si , chr_ ) <EOL> rc = builder . fmul ( ci , chr_ ) <EOL> ic = builder . fmul ( si , shr ) <EOL> sqr_rc = builder . fmul ( rc , rc ) <EOL> sqr_ic = builder . fmul ( ic , ic ) <EOL> d = builder . fadd ( sqr_rc , sqr_ic ) <EOL> inv_d = builder . fdiv ( ONE , d ) <EOL> rs_rc = builder . fmul ( rs , rc ) <EOL> is_ic = builder . fmul ( is_ , ic ) <EOL> is_rc = builder . fmul ( is_ , rc ) <EOL> rs_ic = builder . fmul ( rs , ic ) <EOL> numr = builder . fadd ( rs_rc , is_ic ) <EOL> numi = builder . fsub ( is_rc , rs_ic ) <EOL> out . real = builder . fmul ( numr , inv_d ) <EOL> out . imag = builder . fmul ( numi , inv_d ) <EOL> return out . _getvalue ( ) <EOL> def np_real_asinh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_asinh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> epsilon = context . get_constant ( float_ty , <NUM_LIT> ) <EOL> x = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> abs_r = _fabs ( context , builder , x . real ) <EOL> abs_i = _fabs ( context , builder , x . imag ) <EOL> abs_r_gt_epsilon = builder . fcmp ( lc . FCMP_OGT , abs_r , epsilon ) <EOL> abs_i_gt_epsilon = builder . fcmp ( lc . FCMP_OGT , abs_i , epsilon ) <EOL> any_gt_epsilon = builder . or_ ( abs_r_gt_epsilon , abs_i_gt_epsilon ) <EOL> binary_sig = typing . signature ( * [ ty ] * <NUM_LIT:3> ) <EOL> with builder . if_else ( any_gt_epsilon ) as ( then , otherwise ) : <EOL> with then : <EOL> ONE = context . get_constant_generic ( builder , ty , <NUM_LIT:1.0> + <NUM_LIT> ) <EOL> xx = np_complex_square_impl ( context , builder , sig , args ) <EOL> one_plus_xx = numbers . complex_add_impl ( context , builder , <EOL> binary_sig , [ ONE , xx ] ) <EOL> sqrt_res = np_complex_sqrt_impl ( context , builder , sig , <EOL> [ one_plus_xx ] ) <EOL> log_arg = numbers . complex_add_impl ( context , builder , <EOL> binary_sig , [ sqrt_res , args [ <NUM_LIT:0> ] ] ) <EOL> res = np_complex_log_impl ( context , builder , sig , [ log_arg ] ) <EOL> out . _setvalue ( res ) <EOL> with otherwise : <EOL> coef_dict = { <EOL> types . complex64 : [ - <NUM_LIT:1.0> / <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ] , <EOL> types . complex128 : [ - <NUM_LIT:1.0> / <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> , - <NUM_LIT> / <NUM_LIT> ] , <EOL> } <EOL> xx = np_complex_square_impl ( context , builder , sig , args ) <EOL> ONE = context . get_constant_generic ( builder , ty , <NUM_LIT:1.0> + <NUM_LIT> ) <EOL> tmp = _complex_expand_series ( context , builder , ty , <EOL> ONE , xx , coef_dict [ ty ] ) <EOL> out . _setvalue ( numbers . complex_mul_impl ( context , builder , <EOL> binary_sig , <EOL> [ args [ <NUM_LIT:0> ] , tmp ] ) ) <EOL> return out . _getvalue ( ) <EOL> def np_real_acosh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_acosh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> csig2 = typing . signature ( * [ ty ] * <NUM_LIT:3> ) <EOL> ONE = context . get_constant_generic ( builder , ty , <NUM_LIT:1.0> + <NUM_LIT> ) <EOL> x = args [ <NUM_LIT:0> ] <EOL> x_plus_one = numbers . complex_add_impl ( context , builder , csig2 , [ x , <EOL> ONE ] ) <EOL> x_minus_one = numbers . complex_sub_impl ( context , builder , csig2 , [ x , <EOL> ONE ] ) <EOL> sqrt_x_plus_one = np_complex_sqrt_impl ( context , builder , sig , [ x_plus_one ] ) <EOL> sqrt_x_minus_one = np_complex_sqrt_impl ( context , builder , sig , [ x_minus_one ] ) <EOL> prod_sqrt = numbers . complex_mul_impl ( context , builder , csig2 , <EOL> [ sqrt_x_plus_one , <EOL> sqrt_x_minus_one ] ) <EOL> log_arg = numbers . complex_add_impl ( context , builder , csig2 , [ x , <EOL> prod_sqrt ] ) <EOL> return np_complex_log_impl ( context , builder , sig , [ log_arg ] ) <EOL> def np_real_atanh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_complex_atanh_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> float_ty = ty . underlying_float <EOL> epsilon = context . get_constant ( float_ty , <NUM_LIT> ) <EOL> x = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> out = context . make_complex ( builder , ty ) <EOL> abs_r = _fabs ( context , builder , x . real ) <EOL> abs_i = _fabs ( context , builder , x . imag ) <EOL> abs_r_gt_epsilon = builder . fcmp ( lc . FCMP_OGT , abs_r , epsilon ) <EOL> abs_i_gt_epsilon = builder . fcmp ( lc . FCMP_OGT , abs_i , epsilon ) <EOL> any_gt_epsilon = builder . or_ ( abs_r_gt_epsilon , abs_i_gt_epsilon ) <EOL> binary_sig = typing . signature ( * [ ty ] * <NUM_LIT:3> ) <EOL> with builder . if_else ( any_gt_epsilon ) as ( then , otherwise ) : <EOL> with then : <EOL> ONE = context . get_constant_generic ( builder , ty , <NUM_LIT:1.0> + <NUM_LIT> ) <EOL> HALF = context . get_constant_generic ( builder , ty , <NUM_LIT:0.5> + <NUM_LIT> ) <EOL> den = numbers . complex_sub_impl ( context , builder , binary_sig , <EOL> [ ONE , args [ <NUM_LIT:0> ] ] ) <EOL> num = numbers . complex_add_impl ( context , builder , binary_sig , <EOL> [ ONE , args [ <NUM_LIT:0> ] ] ) <EOL> div = np_complex_div_impl ( context , builder , binary_sig , <EOL> [ num , den ] ) <EOL> log = np_complex_log_impl ( context , builder , sig , [ div ] ) <EOL> res = numbers . complex_mul_impl ( context , builder , binary_sig , <EOL> [ HALF , log ] ) <EOL> out . _setvalue ( res ) <EOL> with otherwise : <EOL> coef_dict = { <EOL> types . complex64 : [ <NUM_LIT:1.0> / <NUM_LIT> , <NUM_LIT> / <NUM_LIT> ] , <EOL> types . complex128 : [ <NUM_LIT:1.0> / <NUM_LIT> , <NUM_LIT> / <NUM_LIT> , <NUM_LIT> / <NUM_LIT> ] , <EOL> } <EOL> xx = np_complex_square_impl ( context , builder , sig , args ) <EOL> ONE = context . get_constant_generic ( builder , ty , <NUM_LIT:1.0> + <NUM_LIT> ) <EOL> tmp = _complex_expand_series ( context , builder , ty , <EOL> ONE , xx , coef_dict [ ty ] ) <EOL> out . _setvalue ( numbers . complex_mul_impl ( context , builder , <EOL> binary_sig , <EOL> [ args [ <NUM_LIT:0> ] , tmp ] ) ) <EOL> return out . _getvalue ( ) <EOL> def np_real_floor_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> return mathimpl . call_fp_intrinsic ( builder , '<STR_LIT>' , args ) <EOL> def np_real_ceil_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> return mathimpl . call_fp_intrinsic ( builder , '<STR_LIT>' , args ) <EOL> def np_real_trunc_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> return mathimpl . call_fp_intrinsic ( builder , '<STR_LIT>' , args ) <EOL> def np_real_fabs_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> return mathimpl . call_fp_intrinsic ( builder , '<STR_LIT>' , args ) <EOL> def np_complex_ge_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> in1 , in2 = [ context . make_complex ( builder , ty , value = arg ) for arg in args ] <EOL> xr = in1 . real <EOL> xi = in1 . imag <EOL> yr = in2 . real <EOL> yi = in2 . imag <EOL> xr_gt_yr = builder . fcmp ( lc . FCMP_OGT , xr , yr ) <EOL> no_nan_xi_yi = builder . fcmp ( lc . FCMP_ORD , xi , yi ) <EOL> xr_eq_yr = builder . fcmp ( lc . FCMP_OEQ , xr , yr ) <EOL> xi_ge_yi = builder . fcmp ( lc . FCMP_OGE , xi , yi ) <EOL> first_term = builder . and_ ( xr_gt_yr , no_nan_xi_yi ) <EOL> second_term = builder . and_ ( xr_eq_yr , xi_ge_yi ) <EOL> return builder . or_ ( first_term , second_term ) <EOL> def np_complex_le_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> in1 , in2 = [ context . make_complex ( builder , ty , value = arg ) for arg in args ] <EOL> xr = in1 . real <EOL> xi = in1 . imag <EOL> yr = in2 . real <EOL> yi = in2 . imag <EOL> xr_lt_yr = builder . fcmp ( lc . FCMP_OLT , xr , yr ) <EOL> no_nan_xi_yi = builder . fcmp ( lc . FCMP_ORD , xi , yi ) <EOL> xr_eq_yr = builder . fcmp ( lc . FCMP_OEQ , xr , yr ) <EOL> xi_le_yi = builder . fcmp ( lc . FCMP_OLE , xi , yi ) <EOL> first_term = builder . and_ ( xr_lt_yr , no_nan_xi_yi ) <EOL> second_term = builder . and_ ( xr_eq_yr , xi_le_yi ) <EOL> return builder . or_ ( first_term , second_term ) <EOL> def np_complex_gt_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> in1 , in2 = [ context . make_complex ( builder , ty , value = arg ) for arg in args ] <EOL> xr = in1 . real <EOL> xi = in1 . imag <EOL> yr = in2 . real <EOL> yi = in2 . imag <EOL> xr_gt_yr = builder . fcmp ( lc . FCMP_OGT , xr , yr ) <EOL> no_nan_xi_yi = builder . fcmp ( lc . FCMP_ORD , xi , yi ) <EOL> xr_eq_yr = builder . fcmp ( lc . FCMP_OEQ , xr , yr ) <EOL> xi_gt_yi = builder . fcmp ( lc . FCMP_OGT , xi , yi ) <EOL> first_term = builder . and_ ( xr_gt_yr , no_nan_xi_yi ) <EOL> second_term = builder . and_ ( xr_eq_yr , xi_gt_yi ) <EOL> return builder . or_ ( first_term , second_term ) <EOL> def np_complex_lt_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> in1 , in2 = [ context . make_complex ( builder , ty , value = arg ) for arg in args ] <EOL> xr = in1 . real <EOL> xi = in1 . imag <EOL> yr = in2 . real <EOL> yi = in2 . imag <EOL> xr_lt_yr = builder . fcmp ( lc . FCMP_OLT , xr , yr ) <EOL> no_nan_xi_yi = builder . fcmp ( lc . FCMP_ORD , xi , yi ) <EOL> xr_eq_yr = builder . fcmp ( lc . FCMP_OEQ , xr , yr ) <EOL> xi_lt_yi = builder . fcmp ( lc . FCMP_OLT , xi , yi ) <EOL> first_term = builder . and_ ( xr_lt_yr , no_nan_xi_yi ) <EOL> second_term = builder . and_ ( xr_eq_yr , xi_lt_yi ) <EOL> return builder . or_ ( first_term , second_term ) <EOL> def np_complex_eq_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> in1 , in2 = [ context . make_complex ( builder , ty , value = arg ) for arg in args ] <EOL> xr = in1 . real <EOL> xi = in1 . imag <EOL> yr = in2 . real <EOL> yi = in2 . imag <EOL> xr_eq_yr = builder . fcmp ( lc . FCMP_OEQ , xr , yr ) <EOL> xi_eq_yi = builder . fcmp ( lc . FCMP_OEQ , xi , yi ) <EOL> return builder . and_ ( xr_eq_yr , xi_eq_yi ) <EOL> def np_complex_ne_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> in1 , in2 = [ context . make_complex ( builder , ty , value = arg ) for arg in args ] <EOL> xr = in1 . real <EOL> xi = in1 . imag <EOL> yr = in2 . real <EOL> yi = in2 . imag <EOL> xr_ne_yr = builder . fcmp ( lc . FCMP_UNE , xr , yr ) <EOL> xi_ne_yi = builder . fcmp ( lc . FCMP_UNE , xi , yi ) <EOL> return builder . or_ ( xr_ne_yr , xi_ne_yi ) <EOL> def _complex_is_true ( context , builder , ty , val ) : <EOL> complex_val = context . make_complex ( builder , ty , value = val ) <EOL> re_true = cgutils . is_true ( builder , complex_val . real ) <EOL> im_true = cgutils . is_true ( builder , complex_val . imag ) <EOL> return builder . or_ ( re_true , im_true ) <EOL> def np_logical_and_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> a = cgutils . is_true ( builder , args [ <NUM_LIT:0> ] ) <EOL> b = cgutils . is_true ( builder , args [ <NUM_LIT:1> ] ) <EOL> return builder . and_ ( a , b ) <EOL> def np_complex_logical_and_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> a = _complex_is_true ( context , builder , sig . args [ <NUM_LIT:0> ] , args [ <NUM_LIT:0> ] ) <EOL> b = _complex_is_true ( context , builder , sig . args [ <NUM_LIT:1> ] , args [ <NUM_LIT:1> ] ) <EOL> return builder . and_ ( a , b ) <EOL> def np_logical_or_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> a = cgutils . is_true ( builder , args [ <NUM_LIT:0> ] ) <EOL> b = cgutils . is_true ( builder , args [ <NUM_LIT:1> ] ) <EOL> return builder . or_ ( a , b ) <EOL> def np_complex_logical_or_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> a = _complex_is_true ( context , builder , sig . args [ <NUM_LIT:0> ] , args [ <NUM_LIT:0> ] ) <EOL> b = _complex_is_true ( context , builder , sig . args [ <NUM_LIT:1> ] , args [ <NUM_LIT:1> ] ) <EOL> return builder . or_ ( a , b ) <EOL> def np_logical_xor_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> a = cgutils . is_true ( builder , args [ <NUM_LIT:0> ] ) <EOL> b = cgutils . is_true ( builder , args [ <NUM_LIT:1> ] ) <EOL> return builder . xor ( a , b ) <EOL> def np_complex_logical_xor_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> , return_type = types . boolean ) <EOL> a = _complex_is_true ( context , builder , sig . args [ <NUM_LIT:0> ] , args [ <NUM_LIT:0> ] ) <EOL> b = _complex_is_true ( context , builder , sig . args [ <NUM_LIT:1> ] , args [ <NUM_LIT:1> ] ) <EOL> return builder . xor ( a , b ) <EOL> def np_logical_not_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> return cgutils . is_false ( builder , args [ <NUM_LIT:0> ] ) <EOL> def np_complex_logical_not_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> a = _complex_is_true ( context , builder , sig . args [ <NUM_LIT:0> ] , args [ <NUM_LIT:0> ] ) <EOL> return builder . not_ ( a ) <EOL> def np_int_smax_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_sge_arg2 = builder . icmp ( lc . ICMP_SGE , arg1 , arg2 ) <EOL> return builder . select ( arg1_sge_arg2 , arg1 , arg2 ) <EOL> def np_int_umax_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_uge_arg2 = builder . icmp ( lc . ICMP_UGE , arg1 , arg2 ) <EOL> return builder . select ( arg1_uge_arg2 , arg1 , arg2 ) <EOL> def np_real_maximum_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_nan = builder . fcmp ( lc . FCMP_UNO , arg1 , arg1 ) <EOL> any_nan = builder . fcmp ( lc . FCMP_UNO , arg1 , arg2 ) <EOL> nan_result = builder . select ( arg1_nan , arg1 , arg2 ) <EOL> arg1_ge_arg2 = builder . fcmp ( lc . FCMP_OGE , arg1 , arg2 ) <EOL> non_nan_result = builder . select ( arg1_ge_arg2 , arg1 , arg2 ) <EOL> return builder . select ( any_nan , nan_result , non_nan_result ) <EOL> def np_real_fmax_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg2_nan = builder . fcmp ( lc . FCMP_UNO , arg2 , arg2 ) <EOL> any_nan = builder . fcmp ( lc . FCMP_UNO , arg1 , arg2 ) <EOL> nan_result = builder . select ( arg2_nan , arg1 , arg2 ) <EOL> arg1_ge_arg2 = builder . fcmp ( lc . FCMP_OGE , arg1 , arg2 ) <EOL> non_nan_result = builder . select ( arg1_ge_arg2 , arg1 , arg2 ) <EOL> return builder . select ( any_nan , nan_result , non_nan_result ) <EOL> def np_complex_maximum_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> bc_sig = typing . signature ( types . boolean , ty ) <EOL> bcc_sig = typing . signature ( types . boolean , * [ ty ] * <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_nan = np_complex_isnan_impl ( context , builder , bc_sig , [ arg1 ] ) <EOL> arg2_nan = np_complex_isnan_impl ( context , builder , bc_sig , [ arg2 ] ) <EOL> any_nan = builder . or_ ( arg1_nan , arg2_nan ) <EOL> nan_result = builder . select ( arg1_nan , arg1 , arg2 ) <EOL> arg1_ge_arg2 = np_complex_ge_impl ( context , builder , bcc_sig , args ) <EOL> non_nan_result = builder . select ( arg1_ge_arg2 , arg1 , arg2 ) <EOL> return builder . select ( any_nan , nan_result , non_nan_result ) <EOL> def np_complex_fmax_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> bc_sig = typing . signature ( types . boolean , ty ) <EOL> bcc_sig = typing . signature ( types . boolean , * [ ty ] * <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_nan = np_complex_isnan_impl ( context , builder , bc_sig , [ arg1 ] ) <EOL> arg2_nan = np_complex_isnan_impl ( context , builder , bc_sig , [ arg2 ] ) <EOL> any_nan = builder . or_ ( arg1_nan , arg2_nan ) <EOL> nan_result = builder . select ( arg2_nan , arg1 , arg2 ) <EOL> arg1_ge_arg2 = np_complex_ge_impl ( context , builder , bcc_sig , args ) <EOL> non_nan_result = builder . select ( arg1_ge_arg2 , arg1 , arg2 ) <EOL> return builder . select ( any_nan , nan_result , non_nan_result ) <EOL> def np_int_smin_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_sle_arg2 = builder . icmp ( lc . ICMP_SLE , arg1 , arg2 ) <EOL> return builder . select ( arg1_sle_arg2 , arg1 , arg2 ) <EOL> def np_int_umin_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_ule_arg2 = builder . icmp ( lc . ICMP_ULE , arg1 , arg2 ) <EOL> return builder . select ( arg1_ule_arg2 , arg1 , arg2 ) <EOL> def np_real_minimum_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_nan = builder . fcmp ( lc . FCMP_UNO , arg1 , arg1 ) <EOL> any_nan = builder . fcmp ( lc . FCMP_UNO , arg1 , arg2 ) <EOL> nan_result = builder . select ( arg1_nan , arg1 , arg2 ) <EOL> arg1_le_arg2 = builder . fcmp ( lc . FCMP_OLE , arg1 , arg2 ) <EOL> non_nan_result = builder . select ( arg1_le_arg2 , arg1 , arg2 ) <EOL> return builder . select ( any_nan , nan_result , non_nan_result ) <EOL> def np_real_fmin_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_nan = builder . fcmp ( lc . FCMP_UNO , arg1 , arg1 ) <EOL> any_nan = builder . fcmp ( lc . FCMP_UNO , arg1 , arg2 ) <EOL> nan_result = builder . select ( arg1_nan , arg2 , arg1 ) <EOL> arg1_le_arg2 = builder . fcmp ( lc . FCMP_OLE , arg1 , arg2 ) <EOL> non_nan_result = builder . select ( arg1_le_arg2 , arg1 , arg2 ) <EOL> return builder . select ( any_nan , nan_result , non_nan_result ) <EOL> def np_complex_minimum_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> bc_sig = typing . signature ( types . boolean , ty ) <EOL> bcc_sig = typing . signature ( types . boolean , * [ ty ] * <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_nan = np_complex_isnan_impl ( context , builder , bc_sig , [ arg1 ] ) <EOL> arg2_nan = np_complex_isnan_impl ( context , builder , bc_sig , [ arg2 ] ) <EOL> any_nan = builder . or_ ( arg1_nan , arg2_nan ) <EOL> nan_result = builder . select ( arg1_nan , arg1 , arg2 ) <EOL> arg1_le_arg2 = np_complex_le_impl ( context , builder , bcc_sig , args ) <EOL> non_nan_result = builder . select ( arg1_le_arg2 , arg1 , arg2 ) <EOL> return builder . select ( any_nan , nan_result , non_nan_result ) <EOL> def np_complex_fmin_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> ty = sig . args [ <NUM_LIT:0> ] <EOL> bc_sig = typing . signature ( types . boolean , ty ) <EOL> bcc_sig = typing . signature ( types . boolean , * [ ty ] * <NUM_LIT:2> ) <EOL> arg1 , arg2 = args <EOL> arg1_nan = np_complex_isnan_impl ( context , builder , bc_sig , [ arg1 ] ) <EOL> arg2_nan = np_complex_isnan_impl ( context , builder , bc_sig , [ arg2 ] ) <EOL> any_nan = builder . or_ ( arg1_nan , arg2_nan ) <EOL> nan_result = builder . select ( arg2_nan , arg1 , arg2 ) <EOL> arg1_le_arg2 = np_complex_le_impl ( context , builder , bcc_sig , args ) <EOL> non_nan_result = builder . select ( arg1_le_arg2 , arg1 , arg2 ) <EOL> return builder . select ( any_nan , nan_result , non_nan_result ) <EOL> def np_real_isnan_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> x , = args <EOL> return builder . fcmp ( lc . FCMP_UNO , x , x ) <EOL> def np_complex_isnan_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> x , = args <EOL> ty , = sig . args <EOL> complex_val = context . make_complex ( builder , ty , value = x ) <EOL> return builder . fcmp ( lc . FCMP_UNO , complex_val . real , complex_val . imag ) <EOL> def _real_is_not_finite ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> x , = args <EOL> ty , = sig . args <EOL> f_ff_sig = typing . signature ( * [ ty ] * <NUM_LIT:3> ) <EOL> sub = numbers . real_sub_impl ( context , builder , f_ff_sig , [ x , x ] ) <EOL> return np_real_isnan_impl ( context , builder , sig , [ sub ] ) <EOL> def np_real_isfinite_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> return builder . not_ ( _real_is_not_finite ( context , builder , sig , args ) ) <EOL> def np_complex_isfinite_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> x , = args <EOL> ty , = sig . args <EOL> fty = ty . underlying_float <EOL> b_f_sig = typing . signature ( types . boolean , fty ) <EOL> complex_val = context . make_complex ( builder , ty , value = x ) <EOL> real_isfinite = np_real_isfinite_impl ( context , builder , b_f_sig , <EOL> [ complex_val . real ] ) <EOL> imag_isfinite = np_real_isfinite_impl ( context , builder , b_f_sig , <EOL> [ complex_val . imag ] ) <EOL> return builder . and_ ( real_isfinite , imag_isfinite ) <EOL> def np_real_isinf_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> x , = args <EOL> not_finite = _real_is_not_finite ( context , builder , sig , args ) <EOL> not_nan = builder . fcmp ( lc . FCMP_ORD , x , x ) <EOL> return builder . and_ ( not_finite , not_nan ) <EOL> def np_complex_isinf_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> ty , = sig . args <EOL> fty = ty . underlying_float <EOL> b_f_sig = typing . signature ( types . boolean , fty ) <EOL> x = context . make_complex ( builder , ty , value = args [ <NUM_LIT:0> ] ) <EOL> real_isinf = np_real_isinf_impl ( context , builder , b_f_sig , [ x . real ] ) <EOL> imag_isinf = np_real_isinf_impl ( context , builder , b_f_sig , [ x . imag ] ) <EOL> return builder . or_ ( real_isinf , imag_isinf ) <EOL> def np_real_signbit_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> , return_type = types . boolean ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_copysign_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> return mathimpl . copysign_float_impl ( context , builder , sig , args ) <EOL> def np_real_nextafter_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:2> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_spacing_impl ( context , builder , sig , args ) : <EOL> _check_arity_and_homogeneity ( sig , args , <NUM_LIT:1> ) <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> return _dispatch_func_by_name_type ( context , builder , sig , args , <EOL> dispatch_table , '<STR_LIT>' ) <EOL> def np_real_ldexp_impl ( context , builder , sig , args ) : <EOL> dispatch_table = { <EOL> types . float32 : '<STR_LIT>' , <EOL> types . float64 : '<STR_LIT>' , <EOL> } <EOL> x1 , x2 = args <EOL> ty1 , ty2 = sig . args <EOL> x2 = context . cast ( builder , x2 , ty2 , types . intc ) <EOL> f_fi_sig = typing . signature ( ty1 , ty1 , types . intc ) <EOL> return _dispatch_func_by_name_type ( context , builder , f_fi_sig , [ x1 , x2 ] , <EOL> dispatch_table , '<STR_LIT>' ) </s>
