def str_to_irrep_np(self, cube_str): ''' cube_str: string representation of 2-cube state Returns: numpy matrix ''' otup, gtup = get_wreath(cube_str) return self.tup_to_irrep_np(otup, gtup)
def time_irreps(cube, n): c2 = init_2cube() cubes = [scramble(c2, 100) for c in range(n)] wreath_tups = [get_wreath(c) for c in cubes] npstart = time.time() for ot, pt in wreath_tups: cube.tup_to_irrep_np(ot, pt) npend = time.time() print('Elapsed: {:4.3f}'.format(npend - npstart))
def str_to_irrep_sp(self, cube_str): otup, gtup = get_wreath(cube_str) re = self.yor_dict[gtup] rem = re.mul( torch.sparse.FloatTensor(re.indices(), self.cyclic_irreps_re[otup], re.size())) imm = re.mul( torch.sparse.FloatTensor(re.indices(), self.cyclic_irreps_im[otup], re.size())) return rem, imm
def eval_cube(c, mat, model_np, model_sp, env_s, env_np, pkls): idx_to_nbrs, idx_to_cube, idx_to_dist, cube_to_idx = pkls otup, ptup = get_wreath(c) cidx = cube_to_idx[c] np_mat = env_np.tup_irrep_inv_np(otup, ptup) sp_r, sp_i = env_s.irrep_inv(c) # numpy model actually computes the transpose of the matrix npr, npi = model_np.forward(np_mat.T) spr, spi = model_sp.forward(sp_r, sp_i) true_val = mat[cidx] log.info('True: {:.4f} | NP: {:.4f} | SP: {:.4f}'.format(true_val, npr, spr.item()))
def str_to_irrep_sp_inv(self, cube_str): otup, gtup = get_wreath(cube_str) wreath_el = WreathCycSn.from_tup(otup, gtup, 3) oinv, ginv = wreath_el.inv_tup_rep() re = self.yor_dict[ginv] rem = re.mul( torch.sparse.FloatTensor(re.indices(), self.cyclic_irreps_re[oinv], re.size())) imm = re.mul( torch.sparse.FloatTensor(re.indices(), self.cyclic_irreps_im[oinv], re.size())) return rem, imm
def str_to_irrep_th(self, cube_str): otup, gtup = get_wreath(cube_str) return self.tup_to_irrep_th(otup, gtup)
def _str_irrep_test(self, cube_str): otup, ptup = get_wreath(cube_str) return self._irrep_test(otup, ptup)
def str_irrep(self, cube_str): otup, ptup = get_wreath(cube_str) return self.irrep(otup, ptup)