QCircuit class
Class representing a Quantum circuit
Constructors
- QCircuit.new({required int size})
Properties
-
gates
→ Iterable<
QCircuitGate> -
Returns the QCircuitGate gates making up the circuit
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
Returns the circuit's size (i.e. the number of qubits it works with)
final
Methods
-
addListener(
void listener(int step, QCircuitGate? gate, QRegister qreg)) → QCircuit -
Registers a listener which will be notified during execution after each gate
for step == 0,
gate
isnull
andqreg
is in the initial state for step > 0,gate
is the stepth gate of the circuit and the state ofqreg
has already been transformed by thegate
-
compile(
) → void - Compile this QCircuit by multiplying the matrices of consecutive, non-measurement gates together Eventually, the original circuit will hold a sequence of custom Quantum gates + measurement gates If the circuit does not contain any measurement gates, it will be represented by a single custom gate
-
custom(
dynamic qubits, ComplexMatrix gate, {dynamic controls, QGateType type = QGateType.custom, Map< String, dynamic> ? params, String? label}) → QCircuit -
Adds a custom
gate
to the circuit operating onqubits
and optionally controlled bycontrols
qubits.qubits
andcontrols
may be single ints or Iterables of ints. The gate may be represented by a 2x2 ComplexMatrix in which casequbits
must contain a single qubit andcontrols
must benull
or empty. Alternatively, the gate may be represented by a square ComplexMatrix of size 2^size operating on the circuit's full state. -
execute(
QRegister qreg) → void -
Executes the circuit with Quantum register
qreg
If the circuit has already been partially executed with step, the execution resumes from there. If the circuit has already been totally executed, execution restarts from scratch Listeners registered with addListener will be notified at each step -
fredkin(
Set< int> qubits, {required int control, String? label}) → QCircuit -
Adds a Fredkin (C-SWAP) gate exchanging the supplied
qubits
and controlled by thecontrol
qubitqubits
must be a Set containing 2 ints -
hadamard(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a Hadamard gate operating on
qubits
and controlled bycontrols
if provided -
invQft(
List< int> qubits, {bool swap = false, String? label}) → QCircuit -
Adds an inverse Quantum Fourrier Transform (QFT) gate operating on supplied
qubits
-
measure(
[Set< int> ? qubits, String? label]) → QCircuit -
Adds a measurement gate to the circuit
Qubits
qubits
will be measured Ifqubits
is null or empty, all qubits will be measured -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
not(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a Pauli X (NOT) gate operating on
qubits
-
pauliX(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a Pauli X (NOT) gate operating on
qubits
and controlled bycontrols
if provided -
pauliY(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a Pauli Y gate operating on
qubits
-
pauliZ(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a Pauli Z gate operating on
qubits
-
phase(
double radians, dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a phase gate operating on
qubits
with angleradians
-
phaseS(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a phase S gate operating on
qubits
-
phaseT(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a phase T gate operating on
qubits
-
qft(
List< int> qubits, {bool swap = false, String? label}) → QCircuit -
Adds a Quantum Fourrier Transform (QFT) gate operating on supplied
qubits
-
removeListener(
void listener(int step, QCircuitGate? gate, QRegister qreg)) → QCircuit - Removes a listener
-
sqrtOfNot(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a 'square root of not' (SQRT-NOT) gate operating on
qubits
-
squareRootOfX(
dynamic qubits, {dynamic controls, String? label}) → QCircuit -
Adds a 'square root of not' (SQRT-NOT) gate operating on
qubits
-
step(
QRegister qreg) → bool -
Executes a single gate of the circuit with Quantum register
qreg
Listeners registered with addListener will be notified Returnsfalse
after the last gate has been executed,true
otherwise. -
swap(
Set< int> qubits, {String? label}) → QCircuit -
Adds a swap gate exchanging the supplied
qubits
qubits
must be a Set containing 2 ints -
toffoli(
int qubit, {required Set< int> controls, String? label}) → QCircuit -
Adds a Toffoli (CC-NOT) gate operating on
qubit
and controlled by qubits supplied incontrols
controls
must be a Set containing 2 ints -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited