Repository navigation
Conversation
Collaborator
|
有一个 bug。 import numpy as np
from cqlib.compile.transform.decompose.block_zxz import decompose_block_zxz
np.set_printoptions(precision=6, suppress=True, linewidth=160)
unitary = np.roll(np.eye(8, dtype=np.complex128), 1, axis=0)
actual = decompose_block_zxz(unitary).to_matrix()
print("初始矩阵:")
print(unitary)
print("\n分解后重建的矩阵:")
print(actual)
print("\n最大矩阵误差:", np.max(np.abs(actual - unitary)))
print("额外全局相位(弧度):", np.angle(np.vdot(unitary, actual)))
np.testing.assert_allclose(actual, unitary, atol=1e-10, rtol=0)问题可能是计算了两次相位。 再确认一下吧。 |
Collaborator
|
控制功能也有一个bug。 UnitaryGate.control() 在创建受控门后,直接复用了原始线路定义: g.with_circuit(c.clone())但新门的比特数已从 n 增加为 n + num_controls,原线路仍为 n 比特,因此触发 QubitCountMismatch。该错误随后被丢弃,并在 Python 层误报为 NoMatrixRepresentation。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.