def test_opt(wavelet_tensors): h, iso, dis = wavelet_tensors s = np.reshape(np.eye(2**3) / 2**3, [2] * 6) for _ in range(20): s = simple_mera.descend(h, s, iso, dis) s, iso, dis = simple_mera.optimize_linear(h, s, iso, dis, 100) en = np.trace(np.reshape(s, [2**3, -1]) @ np.reshape(h, [2**3, -1])) assert en < -1.25
def test_energy(wavelet_tensors): h, iso, dis = wavelet_tensors s = np.reshape(np.eye(2**3) / 2**3, [2] * 6) for _ in range(20): s = simple_mera.descend(h, s, iso, dis) en = np.trace(np.reshape(s, [2**3, -1]) @ np.reshape(h, [2**3, -1])) assert np.isclose(en, -1.242, rtol=1e-3, atol=1e-3) en = simple_mera.binary_mera_energy(h, s, iso, dis) assert np.isclose(en, -1.242, rtol=1e-3, atol=1e-3)
def test_descend(random_tensors): h, s, iso, dis = random_tensors s = simple_mera.descend(h, s, iso, dis) assert len(s.shape) == 6 D = s.shape[0] smat = np.reshape(s, [D**3] * 2) assert np.isclose(np.trace(smat), 1.0) assert np.isclose(np.linalg.norm(smat - np.conj(np.transpose(smat))), 0.0) spec, _ = np.linalg.eigh(smat) assert np.alltrue(spec >= 0.0)