CompositeGate
QuICT.core.gate.CompositeGate ¶
CompositeGate(name: str = None, gates: List[BasicGate, CompositeGate] = None, precision: str = 'double')
Bases: CircuitBased
Implement a group of gate
Parameters:
-
name(str, default:None) –the name of the composite gate. Defaults to None.
-
gates(List[BasicGate, CompositeGate], default:None) –gates within this composite gate. Defaults to None.
Source code in QuICT/core/gate/composite_gate.py
__and__ ¶
assign indexes for the composite gates
Parameters:
-
targets([int / list[int]]) –qubit describe
Source code in QuICT/core/gate/composite_gate.py
__getitem__ ¶
get gates from this composite gate
Parameters:
-
item(int / slice) –slice passed in.
Return
[BasicGates]: the gates
__or__ ¶
deal the operator '|'
Use the syntax "CompositeGate | circuit", "CompositeGate | CompositeGate" to add the gate of gateSet into the circuit
Note that the order of qubits is that control bits first and target bits followed.
Parameters:
-
targets–the targets the gate acts on, it can have the following form, 1) Circuit 2) CompositeGate
Raise: TypeError: the type of other is wrong
Source code in QuICT/core/gate/composite_gate.py
__xor__ ¶
deal the operator '^'
Use the syntax "gateSet ^ circuit", "gateSet ^ gateSet" to add the gate of gateSet's inverse into the circuit
Note that the order of qubits is that control bits first and target bits followed.
Parameters:
-
targets–the targets the gate acts on, it can have the following form, 1) Circuit 2) CompositeGate
Raise: TypeError: the type of other is wrong
Source code in QuICT/core/gate/composite_gate.py
append ¶
Add a quantum gate to current CompositeGate.
Parameters:
-
gate(BasicGate) –The quantum gate need to append
Source code in QuICT/core/gate/composite_gate.py
clean ¶
copy ¶
depth ¶
exp2 ¶
Get a Composite that applys current Composite gate 2^n times
Parameters:
-
n(int) –The exponent.
Returns:
-
CompositeGate(CompositeGate) –a gate that apply the original gate 2^n times.
Source code in QuICT/core/gate/composite_gate.py
extend ¶
Add a CompositeGate to current CompositeGate.
Parameters:
-
gates(CompositeGate) –The given CompositeGate
Source code in QuICT/core/gate/composite_gate.py
inverse ¶
the inverse of CompositeGate
Returns:
-
CompositeGate(CompositeGate) –the inverse of the gateSet
Source code in QuICT/core/gate/composite_gate.py
matrix ¶
matrix of these gates
Parameters:
-
device(str, default:'CPU') –The device type for generate circuit's matrix, one of [CPU, GPU]. Defaults to "CPU".
-
local(bool, default:False) –whether consider only about the occupied qubits or not
-
expand_gate(bool, default:True) –whether or not expand each gate to the full system size when calculating circuit's matrix. Default to
True.
Returns:
-
ndarray–np.ndarray: the matrix of the gates
Source code in QuICT/core/gate/composite_gate.py
peel ¶
Partially flatten the composite gates inside current composite.
Parameters:
-
level(int, default:-1) –maximum level to flatten the composite gates.
lelve = -1means the composite gates will be fully flattened.
Returns:
-
CompositeGate(CompositeGate) –a partially flattened composite gate.
Source code in QuICT/core/gate/composite_gate.py
set_ancilla ¶
Set ancilla qubits' indices.
Parameters:
-
ancilla_qubits(List[int]) –list of indices indicating the ancilla qubits.
Source code in QuICT/core/gate/composite_gate.py
split ¶
Split the CompositeGate by qubits or depth.
Parameters:
-
qubits(List, default:None) –The qubit indexes for one of split CompositeGate.
-
depth(Union[int, List], default:None) –The split depth for current CompositeGate, support split by different