def EU2C(E,U,T=0): ''' Get the expectation matrix in k-space. Parameters: :E,U: ndarray, the eigenvalues and eigenvectors defined on real space. ndim(E)>=2 and ndim(U)=ndim(E)+1. Return: ndarray, the expectation matrix(the expectation mesh of <ck^\dag,ck>) ''' assert(ndim(E)>=1 and ndim(U)==ndim(E)+1) fm=fermi(E,T=T) C=bcast_dot((U.conj()*fm[...,newaxis,:]),swapaxes(U,-1,-2)) return C
def C2H(C,T=1.): ''' Get the entanglement hanmiltonian from expectation matrix. Parameters: :C: ndarray, the expectation matrix. :T: float, the temperature. Return: ndarray, the hamiltonian. ''' CE,CU=eigh(C) print 'Checking for the range fermionic occupation numbers, min -> %s, max -> %s.'%(CE.min(),CE.max()) assert(all(CE>0) and all(CE<1)) H=bcast_dot(CU.conj()*(log(1./CE-1)*T)[...,newaxis,:],swapaxes(CU,-1,-2)) return H