Ejemplo n.º 1
0
 def test_contract_vector(self, backend):
     qstate = peps.random(3, 3, 2, backend=backend)
     statevector = qstate.statevector(contract_option=Snake())
     for contract_option in [BMPS(None), BMPS(ReducedSVD(16)), BMPS(RandomizedSVD(16)), BMPS(ImplicitRandomizedSVD(16))]:
         with self.subTest(contract_option=contract_option):
             contract_result = qstate.statevector(contract_option=contract_option)
             self.assertTrue(backend.allclose(statevector.tensor, contract_result.tensor))
Ejemplo n.º 2
0
 def test_truncate(self, backend):
     for phys, dual in [(1, 1), (2, 1), (2, 2)]:
         with self.subTest(phyiscal_dim=phys, dual_dim=dual):
             qstate = peps.random(2, 3, 4, phys, dual, backend=backend)
             self.assertEqual(qstate.get_average_bond_dim(), 4)
             qstate.truncate(peps.DefaultUpdate(rank=2))
             self.assertEqual(qstate.get_average_bond_dim(), 2)
Ejemplo n.º 3
0
 def test_contract_scalar(self, backend):
     qstate = peps.random(3, 4, 2, backend=backend)
     norm = qstate.norm(contract_option=Snake())
     for contract_option in contract_options:
         if contract_option is not Snake:
             for svd_option in (None, ReducedSVD(16), RandomizedSVD(16), ImplicitRandomizedSVD(16), ImplicitRandomizedSVD(16, orth_method='local_gram')):
                 with self.subTest(contract_option=contract_option.__name__, svd_option=svd_option):
                     self.assertTrue(backend.isclose(norm, qstate.norm(contract_option=contract_option(svd_option))))