Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
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))
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
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()))
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 def str_to_irrep_th(self, cube_str):
     otup, gtup = get_wreath(cube_str)
     return self.tup_to_irrep_th(otup, gtup)
Ejemplo n.º 7
0
 def _str_irrep_test(self, cube_str):
     otup, ptup = get_wreath(cube_str)
     return self._irrep_test(otup, ptup)
Ejemplo n.º 8
0
 def str_irrep(self, cube_str):
     otup, ptup = get_wreath(cube_str)
     return self.irrep(otup, ptup)