예제 #1
0
 def fuzz_state(self, f=1.0):
     norm = la.norm(self.A)
     fac = f*(norm / (self.q * self.D**2))        
     
     R = np.empty_like(self.A)
     m.randomize_cmplx(R, -fac/2.0, fac/2.0)
     
     self.A += R
예제 #2
0
 def randomize(self, do_update=True):
     """Randomizes the parameter tensors self.A.
     
     Parameters
     ----------
     do_update : bool (True)
         Whether to perform self.update() after randomizing.
     """
     m.randomize_cmplx(self.A)
     self.A /= la.norm(self.A)
     
     if do_update:
         self.update()
예제 #3
0
    def expand_D(self, newD, refac=100, imfac=0):
        """Expands the bond dimension in a simple way.
        
        New matrix entries are (mostly) randomized.
        
        Parameters
        ----------
        newD : int
            The new bond-dimension.
        refac : float
            Scaling factor for the real component of the added noise.
        imfac : float
            Scaling factor for the imaginary component of the added noise.
        """
        if newD < self.D:
            return False
        
        oldD = self.D
        oldA = self.A
        
        oldl = np.asarray(self.l)
        oldr = np.asarray(self.r)
        
        self._init_arrays(newD, self.q)
        
        realnorm = la.norm(oldA.real.ravel())
        imagnorm = la.norm(oldA.imag.ravel())
        realfac = (realnorm / oldA.size) * refac
        imagfac = (imagnorm / oldA.size) * imfac
#        m.randomize_cmplx(newA[:, self.D:, self.D:], a=-fac, b=fac)
        m.randomize_cmplx(self.A[:, :oldD, oldD:], a=0, b=realfac, aj=0, bj=imagfac)
        m.randomize_cmplx(self.A[:, oldD:, :oldD], a=0, b=realfac, aj=0, bj=imagfac)
        self.A[:, oldD:, oldD:] = 0 #for nearest-neighbour hamiltonian

#        self.A[:, :oldD, oldD:] = oldA[:, :, :(newD - oldD)]
#        self.A[:, oldD:, :oldD] = oldA[:, :(newD - oldD), :]
        self.A[:, :oldD, :oldD] = oldA

        self.l[:oldD, :oldD] = oldl
        self.l[:oldD, oldD:].fill(la.norm(oldl) / oldD**2)
        self.l[oldD:, :oldD].fill(la.norm(oldl) / oldD**2)
        self.l[oldD:, oldD:].fill(la.norm(oldl) / oldD**2)
        
        self.r[:oldD, :oldD] = oldr
        self.r[oldD:, :oldD].fill(la.norm(oldr) / oldD**2)
        self.r[:oldD, oldD:].fill(la.norm(oldr) / oldD**2)
        self.r[oldD:, oldD:].fill(la.norm(oldr) / oldD**2)
예제 #4
0
    def expand_D(self, newD):
        """Expands the bond dimension in a simple way.
        
        New matrix entries are (mostly) randomized.
        """
        if newD < self.D:
            return False
        
        oldD = self.D
        oldA = self.A
        oldK = self.K
        
        oldl = np.asarray(self.l)
        oldr = np.asarray(self.r)
        
        self._init_arrays(newD, self.q)
        
        realnorm = la.norm(oldA.real)
        imagnorm = la.norm(oldA.imag)
        realfac = (realnorm / (self.q * oldD**2))
        imagfac = (imagnorm / (self.q * oldD**2))
#        m.randomize_cmplx(newA[:, self.D:, self.D:], a=-fac, b=fac)
        m.randomize_cmplx(self.A[:, :oldD, oldD:], a=0, b=realfac, aj=0, bj=imagfac)
        m.randomize_cmplx(self.A[:, oldD:, :oldD], a=0, b=realfac, aj=0, bj=imagfac)
        self.A[:, oldD:, oldD:] = 0 #for nearest-neighbour hamiltonian

#        self.A[:, :oldD, oldD:] = oldA[:, :, :(newD - oldD)]
#        self.A[:, oldD:, :oldD] = oldA[:, :(newD - oldD), :]
        self.A[:, :oldD, :oldD] = oldA

        self.l[:oldD, :oldD] = oldl
        self.l[:oldD, oldD:].fill(la.norm(oldl) / oldD**2)
        self.l[oldD:, :oldD].fill(la.norm(oldl) / oldD**2)
        self.l[oldD:, oldD:].fill(la.norm(oldl) / oldD**2)
        
        self.r[:oldD, :oldD] = oldr
        self.r[oldD:, :oldD].fill(la.norm(oldr) / oldD**2)
        self.r[:oldD, oldD:].fill(la.norm(oldr) / oldD**2)
        self.r[oldD:, oldD:].fill(la.norm(oldr) / oldD**2)
        
        self.K[:oldD, :oldD] = oldK
        self.K[oldD:, :oldD].fill(la.norm(oldK) / oldD**2)
        self.K[:oldD, oldD:].fill(la.norm(oldK) / oldD**2)
        self.K[oldD:, oldD:].fill(la.norm(oldK) / oldD**2)
예제 #5
0
 def add_noise(self, fac=1.0, do_update=True):
     """Adds some random (white) noise of a given magnitude to the parameter 
     tensors A.
     
     Parameters
     ----------
     fac : number
         A factor determining the amplitude of the random noise.
     do_update : bool (True)
         Whether to perform self.update() after randomizing.
     """
     norm = la.norm(self.A)
     fac = fac * (norm / (self.q * self.D**2))        
     
     R = np.empty_like(self.A)
     m.randomize_cmplx(R, -fac / 2.0, fac / 2.0)
     
     self.A += R
     
     if do_update:
         self.update()
예제 #6
0
 def randomize(self, fac=0.5):
     m.randomize_cmplx(self.A, a=-fac, b=fac)