def test_mps_to_mpo(nr_sites, local_dim, rank, rgen):
mps = factory.random_mps(nr_sites, local_dim, rank, randstate=rgen)
# Instead of calling the two functions, we call mps_to_mpo(),
# which does exactly that:
# mps_as_puri = mp.mps_as_local_purification_mps(mps)
# mpo = mp.pmps_to_mpo(mps_as_puri)
mpo = mm.mps_to_mpo(mps)
# This is also a test of mp.mps_as_local_purification_mps() in the
# following sense: Local purifications are representations of
# mixed states. Therefore, compare mps and mps_as_puri by
# converting them to mixed states.
state = mps.to_array()
state = np.outer(state, state.conj())
state.shape = (local_dim,) * (2 * nr_sites)
state2 = mpo.to_array_global()
assert_array_almost_equal(state, state2)
评论列表
文章目录