def calculate_hashed_fps_binary_quick(self, nBits): # bit format self.fps_hashed_binary_quick = _asarray([ _GetMorganFingerprintAsBitVect(x, radius=self.max_radius, nBits=nBits) for x in self.mols ])
def obc_contract_all_average_double_density(L,mps,qmpo,idx_all_operator): # -- -- -- # | | | # rho^T: -a--o----o----o---- # | |s- | # MPOA : -c--o----o----o---- # | |w | # MPOB : -b--o----o----o---- # | |s+ | # rho : -a--o----o----o---- # | | | # -- -- -- for l in xrange(L): # qmps = _QTensor(qbasis.next(), [('a',l),('W',(l+1)),('s',-(l+1)),('a',(l+1)%L)]) # mpoA = _QTensor(opAbas.next(), [('b',l),('s',-(l+1)),('s',+(l+1)),('b',(l+1)%L)]) mps[l]._labels = [('a',l),('W',(l+1)),('s',-(l+1)),('a',(l+1)%L)] if (l in idx_all_operator): if (l==idx_all_operator[0]): mpo = qmpo[0] mpo._labels = [('s',-(l+1)),('s',+(l+1))] elif (l==idx_all_operator[-1]): mpo = qmpo[-1] mpo._labels = [('s',-(l+1)),('s',+(l+1))] if l==0: tmp = (mps[l]*mpo)*mps[l].rev_label(revA=True,revS=True,revW=False) elif l==L-1: tmp *= (mps[l]*mpo)*mps[l].rev_label(revA=True,revS=True,revW=False) val = tmp._blocks[()] # print(tmp,val) elif l % 2 == 0: # up tmp *= mps[l] tmp *= mpo tmp *= mps[l].rev_label(revA=True,revS=True,revW=False) elif l % 2 == 1: # down tmp *= mps[l].rev_label(revA=True,revS=True,revW=False) tmp *= mpo tmp *= mps[l] else: if l == 0: tmp = mps[l]*mps[l].rev_label(revA=True,revS=False,revW=False) elif l==L-1: tmp *= mps[l]*mps[l].rev_label(revA=True,revS=False,revW=False) val = tmp._blocks[()] # print(tmp,val) elif l % 2 == 0: # up tmp *= mps[l] tmp *= mps[l].rev_label(revA=True,revS=False,revW=False) elif l % 2 == 1: # down tmp *= mps[l].rev_label(revA=True,revS=False,revW=False) tmp *= mps[l] return _asscalar(_asarray(val))
def fmap(segments, algorithms, alt_signal=None): # TODO : rename extract_indicators """ Generates a list composed of a list of results for each segment. [[result for each algorithm] for each segment] :param segments: An iterable of segments (e.g. an initialized SegmentGenerator) :param algorithms: A list of algorithms :param alt_signal: The signal that will be used instead of the one referenced in the segments :return: values, col_names A tuple: matrix (segment x algorithms) containing a value for each algorithm, the list of the algorithm names. """ from numpy import asarray as _asarray values = _asarray([[seg.get_begin_time(), seg.get_end_time(), seg.get_label()] + [alg(seg(alt_signal)) for alg in algorithms] for seg in ( segments(alt_signal) if isinstance(segments, SegmentsGenerator) else segments )]) col_names = ["begin", "end", "label"] + map(lambda x: x.__repr__(), algorithms) return values, _array(col_names)
def fmap(segments, algorithms, alt_signal=None): # TODO : rename extract_indicators """ Generates a list composed of a list of results for each segment. [[result for each algorithm] for each segment] :param segments: An iterable of segments (e.g. an initialized SegmentGenerator) :param algorithms: A list of algorithms :param alt_signal: The signal that will be used instead of the one referenced in the segments :return: values, col_names A tuple: matrix (segment x algorithms) containing a value for each algorithm, the list of the algorithm names. """ from numpy import asarray as _asarray values = _asarray([[seg.get_begin_time(), seg.get_end_time(), seg.get_label()] + [alg(seg(alt_signal)) for alg in algorithms] for seg in ( segments(alt_signal) if isinstance(segments, SegmentsGenerator) else segments )]) col_names = ["begin", "end", "label"] + [x.__repr__() for x in algorithms] return values, _array(col_names)
def calculate_hashed_fps_binary_quick(self,nBits): # bit format self.fps_hashed_binary_quick = _asarray([_GetMorganFingerprintAsBitVect(x,radius=self.max_radius,nBits=nBits) for x in self.mols])
def obc_contract_all_average_density(L,mps,qmpo,idx_all_operator): # if len(idx_all_operator)==1: for l in xrange(L): mps[l]._labels = [('a',l),('s',(l+1)),('s',-(l+1)),('a',(l+1)%L)] # if (l==idx_all_operator[0]): # mpo = qmpo # mpo._labels = [('s',-(l+1)),('s',+(l+1))] if (l in idx_all_operator): # both single or two taken into account if (l==idx_all_operator[0]): mpo = qmpo[0] mpo._labels = [('s',-(l+1)),('s',+(l+1))] elif (l==idx_all_operator[-1]): mpo = qmpo[-1] mpo._labels = [('s',-(l+1)),('s',+(l+1))] if l==0: tmp = mps[l]*mpo tmp = tmp.remove_label(('a',0)) elif l==L-1: tmp *= mps[l]*mpo tmp = tmp.remove_label(('a',0)) val = tmp._blocks[()] # print(tmp,val) else: tmp *= mps[l]*mpo else: if l == 0: tmp = mps[l].contract([('s',(l+1)),('s',-(l+1))]) tmp = tmp.remove_label(('a',0)) elif l==L-1: tmp *= mps[l].contract([('s',(l+1)),('s',-(l+1))]) tmp = tmp.remove_label(('a',0)) val = tmp._blocks[()] # print(tmp,val) else: tmp *= mps[l].contract([('s',(l+1)),('s',-(l+1))]) # elif len(idx_all_operator)==2: # for l in xrange(L): # mps[l]._labels = [('a',l),('s',(l+1)),('s',-(l+1)),('a',(l+1)%L)] # if (l==idx_all_operator[0]): # mpo = qmpo[0] # mpo._labels = [('s',-(l+1)),('s',+(l+1))] # elif (l==idx_all_operator[1]): # mpo = qmpo[1] # mpo._labels = [('s',-(l+1)),('s',+(l+1))] # if (l in idx_all_operator): # if l==0: # tmp = mps[l]*mpo # elif l==L-1: # tmp *= mps[l]*mpo # tmp = tmp.remove_label(('a',0)) # # print(tmp) # val = tmp._blocks[()] # else: # tmp *= mps[l]*mpo # else: # if l == 0: # tmp = mps[l].contract([('s',(l+1)),('s',-(l+1))]) # tmp = tmp.remove_label(('a',0)) # elif l==L-1: # tmp *= mps[l].contract([('s',(l+1)),('s',-(l+1))]) # tmp = tmp.remove_label(('a',0)) # # print(tmp) # val = tmp._blocks[()] # else: # tmp *= mps[l].contract([('s',(l+1)),('s',-(l+1))]) # return alpha*complex(val)/norm return _asscalar(_asarray(val))
def obc_contract_correlation_with_all_double_density(L,contrmpsmpo,qmpo,idx_all_operator,mps): # -- -- -- # | | | # rho^T: -a--o----o----o---- # | |s- | # MPOA : -c--o----o----o---- # | |w | # MPOB : -b--o----o----o---- # | |s+ | # rho : -a--o----o----o---- # | | | # -- -- -- # similar to : # -- -- -- # | |w | # rho : -a--o----o----o---- ### A l'AVENIR IL VAUDRA PEUT-ETRE MIEUX TRANSPOSE CA => je crois pas # | | | # | |s+ | # MPOB : -b--o----o----o---- # | |-s | # | | | # MPOA : -c--o----o----o---- # rho : -a--o----o----o---- # | |w | # | | | # -- -- -- for l in xrange(L): contrmpsmpo[l]._labels = [('a',-l),('W',(l+1)),('s',-(l+1)),('a',-((l+1)%L))] if (l in idx_all_operator): mps[l]._labels = [('a',l),('s',+(l+1)),('W',(l+1)),('a',(l+1)%L)] if (l==idx_all_operator[0]): mpo = qmpo[0] mpo._labels = [('s',-(l+1)),('s',+(l+1))] elif (l==idx_all_operator[-1]): mpo = qmpo[-1] mpo._labels = [('s',-(l+1)),('s',+(l+1))] if l==0: tmp = contrmpsmpo[l]*(mpo*mps[l]) elif l==L-1: tmp *= contrmpsmpo[l]*(mpo*mps[l]) val = tmp._blocks[()] # print(tmp,val) elif l % 2 == 0: # up tmp *= contrmpsmpo[l] tmp *= mpo tmp *= mps[l] elif l % 2 == 1: # down tmp *= mps[l] tmp *= mpo tmp *= contrmpsmpo[l] else: mps[l]._labels = [('a',l),('s',-(l+1)),('W',(l+1)),('a',(l+1)%L)] if l == 0: tmp = contrmpsmpo[l]*mps[l] elif l==L-1: tmp *= contrmpsmpo[l]*mps[l] val = tmp._blocks[()] # print(tmp,val) elif l % 2 == 0: # up tmp *= contrmpsmpo[l] tmp *= mps[l] elif l % 2 == 1: # down tmp *= mps[l] tmp *= contrmpsmpo[l] return _asscalar(_asarray(val))