示例#1
0
 def test_dot_mpo(self, cyclic):
     A = MPO_rand(8, 5, cyclic=cyclic)
     B = MPO_rand(8,
                  5,
                  upper_ind_id='q{}',
                  lower_ind_id='w{}',
                  cyclic=cyclic)
     C = A.apply(B)
     assert C.max_bond() == 25
     assert C.upper_ind_id == 'q{}'
     assert C.lower_ind_id == 'w{}'
     Ad, Bd, Cd = A.to_dense(), B.to_dense(), C.to_dense()
     assert_allclose(Ad @ Bd, Cd)
示例#2
0
 def test_apply_mps(self, cyclic, site_ind_id):
     A = MPO_rand(8, 5, cyclic=cyclic)
     x = MPS_rand_state(8, 4, site_ind_id=site_ind_id, cyclic=cyclic)
     y = A.apply(x)
     assert y.max_bond() == 20
     assert isinstance(y, MatrixProductState)
     assert len(y.tensors) == 8
     assert y.site_ind_id == site_ind_id
     Ad, xd, yd = A.to_dense(), x.to_dense(), y.to_dense()
     assert_allclose(Ad @ xd, yd)