def test_compress_form(self): p = MPS_rand_state(20, 20) p.compress('left') assert p.count_canonized() == (19, 0) p.compress('right') assert p.count_canonized() == (0, 19) p.compress(7) assert p.count_canonized() == (7, 12) p = MPS_rand_state(20, 20) p.compress('flat', absorb='left') assert p.count_canonized() == (0, 0)
def test_rand_mps_mixed_canonize(self): n = 10 rmps = MPS_rand_state(n, 10, site_tag_id="foo{}", tags='bar', normalize=True) # move to the center rmps.canonize(orthogonality_center=4) assert rmps.count_canonized() == (4, 5) assert_allclose(rmps.H @ rmps, 1) p_tn = (rmps.H & rmps) ^ slice(0, 4) ^ slice(..., 4, -1) assert_allclose(p_tn['foo3'].data, np.eye(10), atol=1e-13) assert_allclose(p_tn['foo5'].data, np.eye(10), atol=1e-13) # try shifting to the right rmps.shift_orthogonality_center(current=4, new=8) assert_allclose(rmps.H @ rmps, 1) p_tn = (rmps.H & rmps) ^ slice(0, 8) ^ slice(..., 8, -1) assert_allclose(p_tn['foo7'].data, np.eye(4), atol=1e-13) assert_allclose(p_tn['foo9'].data, np.eye(2), atol=1e-13) # try shifting to the left rmps.shift_orthogonality_center(current=8, new=6) assert_allclose(rmps.H @ rmps, 1) p_tn = (rmps.H & rmps) ^ slice(0, 6) ^ slice(..., 6, -1) assert_allclose(p_tn['foo5'].data, np.eye(10), atol=1e-13) assert_allclose(p_tn['foo7'].data, np.eye(8), atol=1e-13)
def test_rand_mps_left_canonize(self): n = 10 k = MPS_rand_state(n, 10, site_tag_id="foo{}", tags='bar', normalize=False) k.left_canonize(normalize=True) assert k.count_canonized() == (9, 0) assert_allclose(k.H @ k, 1) p_tn = (k.H & k) ^ slice(0, 9) assert_allclose(p_tn['foo8'].data, np.eye(10), atol=1e-13)