未验证 提交 70a3e5ae 编写于 作者: Y yangguohao 提交者: GitHub

Update utils.py

上级 907e455d
......@@ -914,14 +914,14 @@ class Hamiltonian:
pass
return self.coefficients, self.__pauli_words
def construct_h_matrix(self):
def construct_h_matrix(selfn_qubit):
r"""构建 Hamiltonian 在 Z 基底下的矩阵。
Returns:
np.ndarray: Z 基底下的哈密顿量矩阵形式
"""
coefs, pauli_words, sites = self.decompose_with_sites()
n_qubit = 1
assert n_qubit>=self.num_qubit,"输入的量子数不小于哈密顿量表达式中所对应的量子比特数"
for site in sites:
if type(site[0]) is int:
n_qubit = max(n_qubit, max(site) + 1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册