Exemple #1
0
 def expectation1(self, operator, site=None):
     """Return the expectated value of `operator` acting on the given `site`."""
     if site is None or site == self.center:
         A = self._data[self.center]
         return np.vdot(A, np.einsum('ij,ajb->aib', operator, A))
     else:
         return expectation.expectation1(self, operator, site)
Exemple #2
0
 def tensor1siteok(self, aϕ, O):
     for center in range(aϕ.size):
         ϕ = CanonicalMPS(aϕ, center=center, normalize=True)
         for n in range(ϕ.size):
             #
             # Take an MPS Φ, construct a new state ψ = O1*ϕ with a local
             # operator on the 'n-th' site
             #
             ψ = mps.state.MPS(ϕ)
             ψ[n] = np.einsum('ij,ajb->aib', O, ψ[n])
             #
             # and make sure that the AntilinearForm provides the right tensor to
             # compute <ϕ|ψ> = <ϕ|O1|ϕ>
             #
             Odesired = expectation1(ϕ, O, n)
             LF = AntilinearForm(ϕ, ψ, center)
             Oestimate = np.einsum('aib,aib', ϕ[center].conj(),
                                   LF.tensor1site())
             self.assertAlmostEqual(Oestimate, Odesired)
             if n >= center:
                 self.assertTrue(almostIdentity(LF.L[center], +1))
             if n <= center:
                 self.assertTrue(almostIdentity(LF.R[center], +1))
Exemple #3
0
 def expectation1(self, operator, n):
     """Return the expectation value of `operator` acting on the `n`-th
     site of the MPS. See `mps.expectation.expectation1()`."""
     return expectation.expectation1(self, operator, n)