量子计算 — 练习
运行方式
bash
cd docs/quantum/computing/code
python exercise.py任务
apply_gate(gate, state):返回gate @ state。bell_state():CNOT @ kron(H, I) @ |00⟩。
参考实现:
python
def apply_gate(gate, state):
return gate @ state
def bell_state():
zero = np.array([1, 0, 0, 0], dtype=complex)
return CNOT @ np.kron(H, I2) @ zero源码位置
clone 后打开(相对仓库根目录):
docs/quantum/computing/code/exercise.py