def transNK(self, d, N, problem_arg=0):
# return np.arange(0, N), np.arange(0, N)
# Each ind has 2*|ind|_0 samples
indSet = setutil.GenTDSet(d, N, base=0)
N_per_ind = 2**np.sum(indSet!=0, axis=1)
if problem_arg == 1:
N_per_ind[1:] /= 2
_, k_ind = np.unique(np.sum(indSet, axis=1), return_inverse=True)
k_of_N = np.repeat(k_ind, N_per_ind.astype(np.int))[:N]
# N_of_k = [j+np.arange(0, i, dtype=np.uint) for i, j in
# zip(N_per_ind, np.hstack((np.array([0],
# dtype=np.uint),
# np.cumsum(N_per_ind)[:np.max(k_of_N)])))]
return k_of_N
评论列表
文章目录