def _broadcast_onto(src_ndim, src_shape, dest_ndim, dest_shape):
 if (src_ndim > dest_ndim):
  return 0
 else:
  src_index = 0
  dest_index = (dest_ndim - src_ndim)
  while (src_index < src_ndim):
   src_dim_size = src_shape[src_index]
   dest_dim_size = dest_shape[dest_index]
   if (dest_dim_size != 1):
    if ((src_dim_size != dest_dim_size) and (src_dim_size != 1)):
     return (- (dest_index + 1))
   elif (src_dim_size != 1):
    dest_shape[dest_index] = src_dim_size
   src_index += 1
   dest_index += 1
 return dest_index

def _broadcast_onto ( src_ndim , src_shape , dest_ndim , dest_shape ) : if ( src_ndim > dest_ndim ) : return 0 else : src_index = 0 dest_index = ( dest_ndim - src_ndim ) while ( src_index < src_ndim ) : src_dim_size = src_shape [ src_index ] dest_dim_size = dest_shape [ dest_index ] if ( dest_dim_size != 1 ) : if ( ( src_dim_size != dest_dim_size ) and ( src_dim_size != 1 ) ) : return ( - ( dest_index + 1 ) ) elif ( src_dim_size != 1 ) : dest_shape [ dest_index ] = src_dim_size src_index += 1 dest_index += 1 return dest_index
low-level utility function used in calculating a shape for an implicit output array .