def __init__(self, bra, ket, center=0): assert bra.size == ket.size # # At the beginning, we create the right- and left- environments for # all sites to the left and to the right of 'center', which is the # focus point of 'LinearForm'. # size = bra.size ρ = begin_environment() R = [ρ] * size for i in range(size-1, center, -1): R[i-1] = ρ = update_right_environment(bra[i], ket[i], ρ) ρ = begin_environment() L = [ρ] * size for i in range(0, center): L[i+1] = ρ = update_left_environment(bra[i], ket[i], ρ) self.bra = bra self.ket = ket self.size = size self.R = R self.L = L self.center = center
def right_environment(self, site): start = max(site, self.center) ρ = expectation.begin_environment(self[start].shape[-1]) for A in self[start:site:-1]: ρ = expectation.update_right_environment(A, A, ρ) return ρ
def right_environment(self, site): ρ = expectation.begin_environment() for A in self[-1:site:-1]: ρ = expectation.update_right_environment(A, A, ρ) return ρ
def left_environment(self, site): start = min(site, self.center) ρ = expectation.begin_environment(self[start].shape[0]) for A in self[start:site]: ρ = expectation.update_left_environment(A, A, ρ) return ρ
def left_environment(self, site): ρ = expectation.begin_environment() for A in self[:site]: ρ = expectation.update_left_environment(A, A, ρ) return ρ