def gen_cre_linkstr(strs, norb, nelec): '''Given intermediates, the link table to generate input strs ''' if nelec == norb: return None inter = [] for str0 in strs: vir = [i for i in range(norb) if not str0 & (1 << i)] for i in vir: inter.append(str0 | (1 << i)) inter = sorted(set(inter)) addrs = dict(zip(strs, range(len(strs)))) link_index = numpy.zeros((len(inter), nelec + 1, 4), dtype=numpy.int32) for i1, str1 in enumerate(inter): occ = [i for i in range(norb) if str1 & (1 << i)] k = 0 for i in occ: str0 = str1 ^ (1 << i) if str0 in addrs: sign = cistring.des_sign(i, str1) link_index[i1, k] = (i, 0, addrs[str0], sign) k += 1 return link_index
def gen_cre_linkstr(strs, norb, nelec): '''Given intermediates, the link table to generate input strs ''' if nelec == norb: return None inter = [] for str0 in strs: vir = [i for i in range(norb) if not str0 & (1<<i)] for i in vir: inter.append(str0 | (1<<i)) inter = sorted(set(inter)) addrs = dict(zip(strs, range(len(strs)))) link_index = numpy.zeros((len(inter),nelec+1,4), dtype=numpy.int32) for i1, str1 in enumerate(inter): occ = [i for i in range(norb) if str1 & (1<<i)] k = 0 for i in occ: str0 = str1 ^ (1<<i) if str0 in addrs: sign = cistring.des_sign(i, str1) link_index[i1,k] = (i, 0, addrs[str0], sign) k += 1 return link_index