def rand_invar(cls, n, phys_dim=2, dtype=float, **mera_opts): """Generate a random translational and scale invariant MERA. """ d = phys_dim iso = qu.rand_iso(d**2, d, dtype=dtype) iso.shape = (d, d, d) uni = qu.rand_iso(d**2, d**2, dtype=dtype) uni.shape = (d, d, d, d) return cls(n, uni, iso, phys_dim=d, **mera_opts)
def test_multisubsystem(self): qu.seed_rand(42) dims = [2, 2, 2] IIX = qu.ikron(qu.rand_herm(2), dims, 2) dcmp = qu.pauli_decomp(IIX, mode='c') for p, x in dcmp.items(): if x == 0j: assert (p[0] != 'I') or (p[1] != 'I') else: assert p[0] == p[1] == 'I' K = qu.rand_iso(3 * 4, 4).reshape(3, 4, 4) KIIXK = qu.kraus_op(IIX, K, dims=dims, where=[0, 2]) dcmp = qu.pauli_decomp(KIIXK, mode='c') for p, x in dcmp.items(): if x == 0j: assert p[1] != 'I' else: assert p[1] == 'I'
def gen_isos(): while True: iso = qu.rand_iso(d**2, d, dtype=dtype) iso.shape = (d, d, d) yield iso
def gen_unis(): while True: uni = qu.rand_iso(d**2, d**2, dtype=dtype) uni.shape = (d, d, d, d) yield uni