def prox_l1(Y, alpha, n_orient):
 n_positions = (Y.shape[0] // n_orient)
 norms = np.sqrt((Y * Y.conj()).real.T.reshape((-1), n_orient).sum(axis=1))
 shrink = np.maximum((1.0 - (alpha / np.maximum(norms, alpha))), 0.0)
 shrink = shrink.reshape((-1), n_positions).T
 active_set = np.any((shrink > 0.0), axis=1)
 shrink = shrink[active_set]
 if (n_orient > 1):
  active_set = np.tile(active_set[:, None], [1, n_orient]).ravel()
 Y = Y[active_set]
 if (len(Y) > 0):
  for o in range(n_orient):
   Y[o::n_orient] *= shrink
 return (Y, active_set)

def prox_l1 ( Y , alpha , n_orient ) : n_positions = ( Y . shape [ 0 ] // n_orient ) norms = np . sqrt ( ( Y * Y . conj ( ) ) . real . T . reshape ( ( - 1 ) , n_orient ) . sum ( axis = 1 ) ) shrink = np . maximum ( ( 1.0 - ( alpha / np . maximum ( norms , alpha ) ) ) , 0.0 ) shrink = shrink . reshape ( ( - 1 ) , n_positions ) . T active_set = np . any ( ( shrink > 0.0 ) , axis = 1 ) shrink = shrink [ active_set ] if ( n_orient > 1 ) : active_set = np . tile ( active_set [ : , None ] , [ 1 , n_orient ] ) . ravel ( ) Y = Y [ active_set ] if ( len ( Y ) > 0 ) : for o in range ( n_orient ) : Y [ o : : n_orient ] *= shrink return ( Y , active_set )
proximity operator for l1 norm with multiple orientation support .