def array_complex_attr(context, builder, typ, value, attr):
 if ((attr not in ['real', 'imag']) or (typ.dtype not in types.complex_domain)):
  raise NotImplementedError('cannot get attribute `{}`'.format(attr))
 arrayty = make_array(typ)
 array = arrayty(context, builder, value)
 flty = typ.dtype.underlying_float
 sizeof_flty = context.get_abi_sizeof(context.get_data_type(flty))
 itemsize = array.itemsize.type(sizeof_flty)
 llfltptrty = context.get_value_type(flty).as_pointer()
 dataptr = builder.bitcast(array.data, llfltptrty)
 if (attr == 'imag'):
  dataptr = builder.gep(dataptr, [ir.IntType(32)(1)])
 resultty = typ.copy(dtype=flty, layout='A')
 result = make_array(resultty)(context, builder)
 repl = dict(data=dataptr, itemsize=itemsize)
 cgutils.copy_struct(result, array, repl)
 return impl_ret_borrowed(context, builder, resultty, result._getvalue())

def array_complex_attr ( context , builder , typ , value , attr ) : if ( ( attr not in [ 'real' , 'imag' ] ) or ( typ . dtype not in types . complex_domain ) ) : raise NotImplementedError ( 'cannot get attribute `{}`' . format ( attr ) ) arrayty = make_array ( typ ) array = arrayty ( context , builder , value ) flty = typ . dtype . underlying_float sizeof_flty = context . get_abi_sizeof ( context . get_data_type ( flty ) ) itemsize = array . itemsize . type ( sizeof_flty ) llfltptrty = context . get_value_type ( flty ) . as_pointer ( ) dataptr = builder . bitcast ( array . data , llfltptrty ) if ( attr == 'imag' ) : dataptr = builder . gep ( dataptr , [ ir . IntType ( 32 ) ( 1 ) ] ) resultty = typ . copy ( dtype = flty , layout = 'A' ) result = make_array ( resultty ) ( context , builder ) repl = dict ( data = dataptr , itemsize = itemsize ) cgutils . copy_struct ( result , array , repl ) return impl_ret_borrowed ( context , builder , resultty , result . _getvalue ( ) )
given a complex array .