盖茨#
对量子比特起作用的门的一种实现。
门是作用于量子位空间的幺正算符。
中期任务:
优化门。应用运算符Qubit来删除许多中间量子位对象的创建。
向所有运算符添加交换关系,并在gate_sort中使用此关系。
固定gate_sort和gate_simp。
正确绘制多目标UGates。
让UGate处理sympy/numpy矩阵并输出任意一种格式。这也应该使用矩阵槽。
- class sympy.physics.quantum.gate.CGate(*args, **kwargs)[源代码]#
一种具有控制量子位的一般酉门。
如果所有的控制量子位都有一个特定的值(由
CGate.control_value
)- 参数:
标签 :元组
在本例中,标签的形式是(controls,gate),其中controls是一个tuple/list of control qubit(as ints),gate是一个
Gate
作为目标运算符的实例。
- property controls#
控制量子位的元组。
- property gate#
将应用于目标的非受控门。
- property min_qubits#
这个门需要作用的最小量子比特数。
- property nqubits#
这个门作用于的量子位总数。
对于受控门子类,这包括目标和控制量子位,因此,例如CNOT门作用于2个量子位。
- property targets#
目标量子位的元组。
- class sympy.physics.quantum.gate.CGateS(*args, **kwargs)[源代码]#
允许门简化的CGate版本。一、 cnot看起来像是一个oplus,cphase有点等。
- class sympy.physics.quantum.gate.CNotGate(*args, **kwargs)[源代码]#
两个量子位不受控制。
如果控制量子位的值都为1,则此门对目标量子位执行非门或X门。
- 参数:
标签 :元组
形式(控件、目标)的元组。
实例
>>> from sympy.physics.quantum.gate import CNOT >>> from sympy.physics.quantum.qapply import qapply >>> from sympy.physics.quantum.qubit import Qubit >>> c = CNOT(1,0) >>> qapply(c*Qubit('10')) # note that qubits are indexed from right to left |11>
- property controls#
控制量子位的元组。
- property gate#
将应用于目标的非受控门。
- property min_qubits#
这个门需要作用的最小量子比特数。
- property targets#
目标量子位的元组。
- class sympy.physics.quantum.gate.Gate(*args, **kwargs)[源代码]#
作用于量子位的非受控幺正门运算符。
这是一个通用的抽象门,需要子类化才能做任何有用的事情。
- 参数:
标签 :元组,int
门将应用到的目标量子位(如int)的列表。
- get_target_matrix(format='sympy')[源代码]#
The matrix representation of the target part of the gate.
- 参数:
格式 :结构
格式字符串('sypy','numpy'等)
- property min_qubits#
这个门需要作用的最小量子比特数。
- property nqubits#
这个门作用于的量子位总数。
对于受控门子类,这包括目标和控制量子位,因此,例如CNOT门作用于2个量子位。
- property targets#
目标量子位的元组。
- sympy.physics.quantum.gate.H[源代码]#
HadamardGate
的别名
- class sympy.physics.quantum.gate.HadamardGate(*args, **kwargs)[源代码]#
单量子比特哈达玛门。
- 参数:
目标 :内景
此门将应用于的目标量子比特。
实例
>>> from sympy import sqrt >>> from sympy.physics.quantum.qubit import Qubit >>> from sympy.physics.quantum.gate import HadamardGate >>> from sympy.physics.quantum.qapply import qapply >>> qapply(HadamardGate(0)*Qubit('1')) sqrt(2)*|0>/2 - sqrt(2)*|1>/2 >>> # Hadamard on bell state, applied on 2 qubits. >>> psi = 1/sqrt(2)*(Qubit('00')+Qubit('11')) >>> qapply(HadamardGate(0)*HadamardGate(1)*psi) sqrt(2)*|00>/2 + sqrt(2)*|11>/2
- class sympy.physics.quantum.gate.IdentityGate(*args, **kwargs)[源代码]#
单量子比特身份门。
- 参数:
目标 :内景
此门将应用于的目标量子比特。
- class sympy.physics.quantum.gate.PhaseGate(*args, **kwargs)[源代码]#
单量子位相或称S门。
如果状态为
|1>
如果州政府|0>
.- 参数:
目标 :内景
此门将应用于的目标量子比特。
- class sympy.physics.quantum.gate.SwapGate(*args, **kwargs)[源代码]#
双量子比特交换门。
这个门交换两个量子比特的值。
- 参数:
标签 :元组
形式的元组(target1,target2)。
- class sympy.physics.quantum.gate.TGate(*args, **kwargs)[源代码]#
单量子比特pi/8门。
如果状态为
|1>
如果州政府|0>
.- 参数:
目标 :内景
此门将应用于的目标量子比特。
- class sympy.physics.quantum.gate.UGate(*args, **kwargs)[源代码]#
由一组目标和一个目标矩阵指定的一般门。
- 参数:
标签 :元组
一种形式的元组(targets,U),其中targets是目标量子位的元组,U是维数为len(targets)的酉矩阵。
- property targets#
目标量子位的元组。
- class sympy.physics.quantum.gate.XGate(*args, **kwargs)[源代码]#
单量子比特X,或者不是,门。
- 参数:
目标 :内景
此门将应用于的目标量子比特。
- sympy.physics.quantum.gate.gate_simp(circuit)[源代码]#
象征性地简化大门
它首先使用gate_sort对门进行排序。然后它将基本的简化规则应用于电路,例如XGate**2=Identity
- sympy.physics.quantum.gate.gate_sort(circuit)[源代码]#
在跟踪交换关系的同时对闸进行排序
此函数使用气泡排序来重新排列浇口应用程序的顺序。跟踪量子计算特殊的交换关系(例如,应用于同一量子比特的事物不会相互交换)
电路是要排序的门的Mul。
- sympy.physics.quantum.gate.normalized(normalize)[源代码]#
Set flag controlling normalization of Hadamard gates by \(1/\sqrt{2}\).
This is a global setting that can be used to simplify the look of various expressions, by leaving off the leading \(1/\sqrt{2}\) of the Hadamard gate.
- 参数:
归一化 布尔
Should the Hadamard gate include the \(1/\sqrt{2}\) normalization factor? When True, the Hadamard gate will have the \(1/\sqrt{2}\). When False, the Hadamard gate will not have this factor.
- sympy.physics.quantum.gate.random_circuit(ngates, nqubits, gate_space=(<class 'sympy.physics.quantum.gate.XGate'>, <class 'sympy.physics.quantum.gate.YGate'>, <class 'sympy.physics.quantum.gate.ZGate'>, <class 'sympy.physics.quantum.gate.PhaseGate'>, <class 'sympy.physics.quantum.gate.TGate'>, <class 'sympy.physics.quantum.gate.HadamardGate'>, <class 'sympy.physics.quantum.gate.CNotGate'>, <class 'sympy.physics.quantum.gate.SwapGate'>))[源代码]#
返回ngates和nqbit的随机循环。
这使用了(X,Y,Z,S,T,H,CNOT,SWAP)门的等权重样本。
- 参数:
恩盖特 :内景
电路中的门数。
纳比特 :内景
电路中的量子位数。
gate_space :元组
电路中使用的门类的元组。在这个元组中多次重复门类将增加它们在随机电路中出现的频率。