Circuits
Circuits are made up of instructions (operations to apply to the qubits – gates and noises) and result types (results). OpenQASM3 programs are parsed to circuits which are then run on the simulator.
BraketSimulator.Circuit
— TypeCircuit
A representation of a quantum circuit that contains the instructions to be performed on a quantum device and the requested result types.
See:
BraketSimulator.Operator
— TypeOperator
Abstract type representing operations that can be applied to a Circuit
. Subtypes include Gate
, Noise
, Observable
.
BraketSimulator.QuantumOperator
— TypeQuantumOperator < Operator
Abstract type representing quantum operations that can be applied to a Circuit
. Subtypes include Gate
and Noise
.
BraketSimulator.FreeParameter
— TypeFreeParameter
FreeParameter(name::Symbol) -> FreeParameter
Struct representing a free parameter, which may be used to initialize to a parametrized Gate
or Noise
and then given a fixed value later by supplying a mapping to a Circuit
.
BraketSimulator.Measure
— TypeMeasure(index) <: QuantumOperator
Represents a measurement operation on targeted qubit, stored in the classical register at index
.
BraketSimulator.Instruction
— TypeInstruction
Instruction(o::Operator, target)
Represents a single operation applied to a Circuit
. Contains an operator
, which may be any subtype of Operator
, and a target
set of qubits to which the operator
is applied.
Examples
julia> Instruction(H(), 1)
Instruction{H}(H(1.0), QubitSet(1))
julia> Instruction(CNot(), [1, Qubit(4)])
Instruction{CNot}(CNot(1.0), QubitSet(1, 4))
BraketSimulator.QubitSet
— TypeQubitSet
An OrderedSet
-like object which represents the qubits a Circuit
, Instruction
, or Result
acts on and their ordering. Elements may be Int
s or Qubit
s.
Examples
julia> QubitSet(1, Qubit(0))
QubitSet with 2 elements:
1
Qubit(0)
julia> QubitSet([2, 1])
QubitSet with 2 elements:
2
1
julia> QubitSet()
QubitSet()
julia> QubitSet(QubitSet(5, 1))
QubitSet with 2 elements:
5
1
BraketSimulator.Qubit
— TypeQubit <: Integer
Wrapper struct
representing a qubit.
Examples
julia> q = Qubit(0)
Qubit(0)
julia> q == 0
true
BraketSimulator.qubit_count
— Functionqubit_count(c::Circuit) -> Int
Returns the number of qubits that c
is defined on.
Examples
julia> c = Circuit();
julia> add_instruction!(c, Instruction(H(), 0));
julia> add_instruction!(c, Instruction(CNot(), [0, 1]));
julia> qubit_count(c)
2
BraketSimulator.qubits
— Functionqubits(c::Circuit) -> QubitSet
Returns a QubitSet
containing all qubits that c
is defined on.
Examples
julia> c = Circuit();
julia> add_instruction!(c, Instruction(H(), 0));
julia> add_instruction!(c, Instruction(CNot(), [0, 1]));
julia> qubits(c)
QubitSet with 2 elements:
0
1
BraketSimulator.basis_rotation_instructions!
— Functionbasis_rotation_instructions!(c::Circuit)
Gets a list of basis rotation instructions and stores them in the circuit c
. These basis rotation instructions are added if result types are requested for an observable other than Pauli-Z.
This only makes sense if all observables are simultaneously measurable; if not, this method will return an empty list.