def tile(A, reps):
 try:
  tup = tuple(reps)
 except TypeError:
  tup = (reps,)
 d = len(tup)
 if ((tup.count(1) == len(tup)) and isinstance(A, cupy.ndarray)):
  return cupy.array(A, copy=True, ndmin=d)
 else:
  c = cupy.array(A, copy=False, ndmin=d)
 if (d < c.ndim):
  tup = (((1,) * (c.ndim - d)) + tup)
 shape_out = tuple(((s * t) for (s, t) in zip(c.shape, tup)))
 if (c.size == 0):
  return cupy.empty(shape_out, dtype=c.dtype)
 c_shape = []
 ret_shape = []
 for (dim_in, nrep) in zip(c.shape, tup):
  if (nrep == 1):
   c_shape.append(dim_in)
   ret_shape.append(dim_in)
  elif (dim_in == 1):
   c_shape.append(dim_in)
   ret_shape.append(nrep)
  else:
   c_shape.append(1)
   c_shape.append(dim_in)
   ret_shape.append(nrep)
   ret_shape.append(dim_in)
 ret = cupy.empty(ret_shape, dtype=c.dtype)
 if ret.size:
  ret[...] = c.reshape(c_shape)
 return ret.reshape(shape_out)

def tile ( A , reps ) : try : tup = tuple ( reps ) except TypeError : tup = ( reps , ) d = len ( tup ) if ( ( tup . count ( 1 ) == len ( tup ) ) and isinstance ( A , cupy . ndarray ) ) : return cupy . array ( A , copy = True , ndmin = d ) else : c = cupy . array ( A , copy = False , ndmin = d ) if ( d < c . ndim ) : tup = ( ( ( 1 , ) * ( c . ndim - d ) ) + tup ) shape_out = tuple ( ( ( s * t ) for ( s , t ) in zip ( c . shape , tup ) ) ) if ( c . size == 0 ) : return cupy . empty ( shape_out , dtype = c . dtype ) c_shape = [ ] ret_shape = [ ] for ( dim_in , nrep ) in zip ( c . shape , tup ) : if ( nrep == 1 ) : c_shape . append ( dim_in ) ret_shape . append ( dim_in ) elif ( dim_in == 1 ) : c_shape . append ( dim_in ) ret_shape . append ( nrep ) else : c_shape . append ( 1 ) c_shape . append ( dim_in ) ret_shape . append ( nrep ) ret_shape . append ( dim_in ) ret = cupy . empty ( ret_shape , dtype = c . dtype ) if ret . size : ret [ ... ] = c . reshape ( c_shape ) return ret . reshape ( shape_out )
construct an array by tiling a given array .