Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Circuits::CircuitFactory< Time > Class Template Reference

Factory for quantum gates and other operations. More...

#include <Factory.h>

Static Public Member Functions

static std::shared_ptr< Circuit< Time > > CreateCircuit (const std::vector< std::shared_ptr< IOperation< Time > > > &ops={})
 Construct a circuit.
 
static std::shared_ptr< IOperation< Time > > CreateReset (const Types::qubits_vector &qubits={}, const std::vector< bool > &resetTgts={})
 Construct a reset operation.
 
static std::shared_ptr< IOperation< Time > > CreateRandom (const std::vector< size_t > &bits={}, size_t seed=0)
 Construct a random operation.
 
static const std::shared_ptr< IOperation< Time > > CreateMeasurement (const std::vector< std::pair< Types::qubit_t, size_t > > &qs={})
 Construct a measurement operation.
 
static const std::shared_ptr< IQuantumGate< Time > > CreateGate (QuantumGateType type, size_t q1, size_t q2=0, size_t q3=0, double param1=0, double param2=0, double param3=0, double param4=0)
 Construct a quantum gate.
 
static const std::shared_ptr< IOperation< Time > > CreateGateWithVectors (QuantumGateType type, const Types::qubits_vector &qubits, const std::vector< double > &params={})
 Construct a quantum gate.
 
static std::shared_ptr< IConditionCreateEqualCondition (const std::vector< size_t > &ind, const std::vector< bool > &b)
 Construct an equality condition.
 
static std::shared_ptr< IOperation< Time > > CreateConditionalGate (const std::shared_ptr< IGateOperation< Time > > &operation, const std::shared_ptr< ICondition > &condition)
 Construct a conditional gate.
 
static std::shared_ptr< IOperation< Time > > CreateSimpleConditionalGate (const std::shared_ptr< IGateOperation< Time > > &operation, const size_t cbit)
 Construct a simple conditional gate.
 
static std::shared_ptr< IOperation< Time > > CreateConditionalMeasurement (const std::shared_ptr< MeasurementOperation< Time > > &measurement, const std::shared_ptr< ICondition > &condition)
 Constructs a conditional measurement.
 
static std::shared_ptr< IOperation< Time > > CreateConditionalRandomGen (const std::shared_ptr< Random< Time > > &randomGen, const std::shared_ptr< ICondition > &condition)
 Constructs a conditional random number generator.
 
static std::shared_ptr< IOperation< Time > > CreateNoOp ()
 Creates a no op.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateBellStateCircuit (size_t qbit1, size_t qbit2, bool qbit1X=false, bool qbit2X=false)
 Creates a circuit that prepares a qubit pair in a Bell state.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateBellStateDecoderCircuit (size_t qbit1, size_t qbit2)
 Creates a Bell state decoder circuit.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateGZHStateCircuit (size_t qbit1, size_t qbit2, size_t qbit3)
 Creates a circuit that prepares three qubits in a GHZ state.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateTeleportationCircuit (size_t entqbit1, size_t entqbit2, size_t srcqbit, size_t cbit1, size_t cbit2)
 Creates a teleportation circuit.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateStartDistributionCircuit (size_t ctrlQubit, size_t ctrlEntangledQubit, size_t tgtEntangledQubit, size_t ctrlEntangledMeasureBit)
 Creates the circuit for distribution start.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateEndDistributionCircuit (size_t ctrlQubit, size_t tgtEntangledQubit, size_t tgtEntangledMeasureBit)
 Creates the circuit for distribution end.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateMeasureX (size_t qubit, size_t cbit)
 Creates the circuit for measuring a qubit in the X basis.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateMeasureY (size_t qubit, size_t cbit)
 Creates the circuit for measuring a qubit in the Y basis.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateMeasureZ (size_t qubit, size_t cbit)
 Creates the circuit for measuring a qubit in the Z basis.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateInitZero (size_t qubit)
 Creates the circuit for initializing a qubit in the |0> state.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateInitOne (size_t qubit)
 Creates the circuit for initializing a qubit in the |1> state.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateInitPlus (size_t qubit)
 Creates the circuit for initializing a qubit in the |+> state.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateInitMinus (size_t qubit)
 Creates the circuit for initializing a qubit in the |-> state.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateInitPlusI (size_t qubit)
 Creates the circuit for initializing a qubit in the |i> state.
 
static std::vector< std::shared_ptr< IOperation< Time > > > CreateInitMinusI (size_t qubit)
 Creates the circuit for initializing a qubit in the |-i> state.
 

Detailed Description

template<typename Time = Types::time_type>
class Circuits::CircuitFactory< Time >

Factory for quantum gates and other operations.

Contains factory methods for quantum gates, resets, measurements, conditional gates, etc. There are even for factory methods for some circuits that are important (for example for distribution).

Template Parameters
TimeThe time type used for operations timing.

Definition at line 37 of file Circuit/Factory.h.

Member Function Documentation

◆ CreateBellStateCircuit()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateBellStateCircuit ( size_t  qbit1,
size_t  qbit2,
bool  qbit1X = false,
bool  qbit2X = false 
)
inlinestatic

Creates a circuit that prepares a qubit pair in a Bell state.

Creates a circuit that prepares a qubit pair in a Bell state.

Parameters
qbit1The first qubit.
qbit2The second qubit.
qbit1XWhether to apply an X gate to the first qubit.
qbit2XWhether to apply an X gate to the second qubit.
Returns
The circuit that prepares the qubit pair in a Bell state.
See also
IOperation

Definition at line 384 of file Circuit/Factory.h.

◆ CreateBellStateDecoderCircuit()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateBellStateDecoderCircuit ( size_t  qbit1,
size_t  qbit2 
)
inlinestatic

Creates a Bell state decoder circuit.

Creates a Bell state decoder circuit.

Parameters
qbit1The first qubit.
qbit2The second qubit.
Returns
The decoder circuit.
See also
IOperation

Definition at line 412 of file Circuit/Factory.h.

◆ CreateCircuit()

template<typename Time = Types::time_type>
static std::shared_ptr< Circuit< Time > > Circuits::CircuitFactory< Time >::CreateCircuit ( const std::vector< std::shared_ptr< IOperation< Time > > > &  ops = {})
inlinestatic

Construct a circuit.

Constructs a circuit with the given operations.

Parameters
opsThe operations to add to the circuit.
Returns
The created circuit.
See also
Circuit

Definition at line 47 of file Circuit/Factory.h.

◆ CreateConditionalGate()

template<typename Time = Types::time_type>
static std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateConditionalGate ( const std::shared_ptr< IGateOperation< Time > > &  operation,
const std::shared_ptr< ICondition > &  condition 
)
inlinestatic

Construct a conditional gate.

Constructs a conditional gate with the given operation and condition.

Parameters
operationThe operation to perform if the condition is met.
conditionThe condition to check.
Returns
The conditional gate.
See also
ConditionalGate
IGateOperation
ICondition

Definition at line 294 of file Circuit/Factory.h.

◆ CreateConditionalMeasurement()

template<typename Time = Types::time_type>
static std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateConditionalMeasurement ( const std::shared_ptr< MeasurementOperation< Time > > &  measurement,
const std::shared_ptr< ICondition > &  condition 
)
inlinestatic

Constructs a conditional measurement.

Constructs a conditional measurement with the given measurement and condition.

Parameters
measurementThe measurement to perform if the condition is met.
conditionThe condition to check.
Returns
The conditional measurement.
See also
ConditionalMeasurement
MeasurementOperation
ICondition

Definition at line 333 of file Circuit/Factory.h.

◆ CreateConditionalRandomGen()

template<typename Time = Types::time_type>
static std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateConditionalRandomGen ( const std::shared_ptr< Random< Time > > &  randomGen,
const std::shared_ptr< ICondition > &  condition 
)
inlinestatic

Constructs a conditional random number generator.

Constructs a conditional random number generator with the given random number generator and condition.

Parameters
randomGenThe random number generator to perform if the condition is met.
conditionThe condition to check.
Returns
The conditional random number generator.
See also
ConditionalRandomGen
Random
ICondition

Definition at line 354 of file Circuit/Factory.h.

◆ CreateEndDistributionCircuit()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateEndDistributionCircuit ( size_t  ctrlQubit,
size_t  tgtEntangledQubit,
size_t  tgtEntangledMeasureBit 
)
inlinestatic

Creates the circuit for distribution end.

Creates the circuit operations for the end of the distribution.

Parameters
ctrlQubitThe control qubit for the operation to distribute.
tgtEntangledQubitThe entangled qubit on the target host.
tgtEntangledMeasureBitThe classical bit to store the measurement of the entangled qubit on the target host.
Returns
The distribution end circuit operations.

Definition at line 547 of file Circuit/Factory.h.

◆ CreateEqualCondition()

template<typename Time = Types::time_type>
static std::shared_ptr< ICondition > Circuits::CircuitFactory< Time >::CreateEqualCondition ( const std::vector< size_t > &  ind,
const std::vector< bool > &  b 
)
inlinestatic

Construct an equality condition.

Constructs an equality condition for the given classical bits and the given values.

Parameters
indThe classical bits to check.
bThe values to check for equality.
Returns
The equality condition.
See also
ICondition

Definition at line 274 of file Circuit/Factory.h.

◆ CreateGate()

template<typename Time = Types::time_type>
static const std::shared_ptr< IQuantumGate< Time > > Circuits::CircuitFactory< Time >::CreateGate ( QuantumGateType  type,
size_t  q1,
size_t  q2 = 0,
size_t  q3 = 0,
double  param1 = 0,
double  param2 = 0,
double  param3 = 0,
double  param4 = 0 
)
inlinestatic

Construct a quantum gate.

Constructs a quantum gate operation.

Parameters
typeThe type of gate to construct.
q1The first qubit.
q2The second qubit (if it's two or three qubit gate, otherwise ignored).
q3The third qubit (if it's a three qubit gate, otherwise ignored).
param1The first parameter (if it has parameters, otherwise ignored).
param2The second parameter (if it has more than one parameter, otherwise ignored).
param3The third parameter (if it has more than two parameters, otherwise ignored).
param4The fourth parameter (if it has more than three parameters, otherwise ignored).
Returns
The quantum gate.
See also
IQuantumGate
QuantumGateType

Definition at line 122 of file Circuit/Factory.h.

◆ CreateGateWithVectors()

template<typename Time = Types::time_type>
static const std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateGateWithVectors ( QuantumGateType  type,
const Types::qubits_vector &  qubits,
const std::vector< double > &  params = {} 
)
inlinestatic

Construct a quantum gate.

Constructs a quantum gate operation.

Parameters
typeThe type of gate to construct.
qubitsThe qubits to apply the gate to.
paramsThe parameters of the gate.
Returns
A smart pointer to the created quantum gate.
See also
IQuantumGate
QuantumGateType

Definition at line 248 of file Circuit/Factory.h.

◆ CreateGZHStateCircuit()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateGZHStateCircuit ( size_t  qbit1,
size_t  qbit2,
size_t  qbit3 
)
inlinestatic

Creates a circuit that prepares three qubits in a GHZ state.

Creates a circuit that prepares a three qubits in a GHZ state.

Parameters
qbit1The first qubit.
qbit2The second qubit.
qbit3The third qubit.
Returns
The circuit that prepares the qubits in a GHZ state.
See also
IOperation

Definition at line 432 of file Circuit/Factory.h.

◆ CreateInitMinus()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateInitMinus ( size_t  qubit)
inlinestatic

Creates the circuit for initializing a qubit in the |-> state.

Creates the circuit operations for initializing a qubit in the |-> state.

Parameters
qubitThe qubit to initialize.

Definition at line 669 of file Circuit/Factory.h.

◆ CreateInitMinusI()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateInitMinusI ( size_t  qubit)
inlinestatic

Creates the circuit for initializing a qubit in the |-i> state.

Creates the circuit operations for initializing a qubit in the |-i> state.

Parameters
qubitThe qubit to initialize.

Definition at line 703 of file Circuit/Factory.h.

◆ CreateInitOne()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateInitOne ( size_t  qubit)
inlinestatic

Creates the circuit for initializing a qubit in the |1> state.

Creates the circuit operations for initializing a qubit in the |1> state.

Parameters
qubitThe qubit to initialize.

Definition at line 637 of file Circuit/Factory.h.

◆ CreateInitPlus()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateInitPlus ( size_t  qubit)
inlinestatic

Creates the circuit for initializing a qubit in the |+> state.

Creates the circuit operations for initializing a qubit in the |+> state.

Parameters
qubitThe qubit to initialize.

Definition at line 653 of file Circuit/Factory.h.

◆ CreateInitPlusI()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateInitPlusI ( size_t  qubit)
inlinestatic

Creates the circuit for initializing a qubit in the |i> state.

Creates the circuit operations for initializing a qubit in the |i> state.

Parameters
qubitThe qubit to initialize.

Definition at line 686 of file Circuit/Factory.h.

◆ CreateInitZero()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateInitZero ( size_t  qubit)
inlinestatic

Creates the circuit for initializing a qubit in the |0> state.

Creates the circuit operations for initializing a qubit in the |0> state.

Parameters
qubitThe qubit to initialize.

Definition at line 622 of file Circuit/Factory.h.

◆ CreateMeasurement()

template<typename Time = Types::time_type>
static const std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateMeasurement ( const std::vector< std::pair< Types::qubit_t, size_t > > &  qs = {})
inlinestatic

Construct a measurement operation.

Measures the qubits and stores the result in the classical bits.

Parameters
qsThe qubits to measure and the corresponding classical bit where to put results, specified as pairs.
Returns
The measurement operation.
See also
MeasurementOperation

Definition at line 95 of file Circuit/Factory.h.

◆ CreateMeasureX()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateMeasureX ( size_t  qubit,
size_t  cbit 
)
inlinestatic

Creates the circuit for measuring a qubit in the X basis.

Creates the circuit operations for measuring a qubit in the X basis.

Parameters
qubitThe qubit to measure.
cbitThe classical bit to store the measurement result.

Definition at line 572 of file Circuit/Factory.h.

◆ CreateMeasureY()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateMeasureY ( size_t  qubit,
size_t  cbit 
)
inlinestatic

Creates the circuit for measuring a qubit in the Y basis.

Creates the circuit operations for measuring a qubit in the Y basis.

Parameters
qubitThe qubit to measure.
cbitThe classical bit to store the measurement result.

Definition at line 589 of file Circuit/Factory.h.

◆ CreateMeasureZ()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateMeasureZ ( size_t  qubit,
size_t  cbit 
)
inlinestatic

Creates the circuit for measuring a qubit in the Z basis.

Creates the circuit operations for measuring a qubit in the Z basis.

Parameters
qubitThe qubit to measure.
cbitThe classical bit to store the measurement result.

Definition at line 607 of file Circuit/Factory.h.

◆ CreateNoOp()

template<typename Time = Types::time_type>
static std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateNoOp ( )
inlinestatic

Creates a no op.

Creates a no op, an operation that does nothing.

Returns
The no op.
See also
NoOperation

Definition at line 368 of file Circuit/Factory.h.

◆ CreateRandom()

template<typename Time = Types::time_type>
static std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateRandom ( const std::vector< size_t > &  bits = {},
size_t  seed = 0 
)
inlinestatic

Construct a random operation.

Generates a random 0 or 1 for each specified classical bit.

Parameters
bitsThe bits to generate random numbers for.
seedThe seed to use for the random number generator.
Returns
The random operation.
See also
Random

Definition at line 80 of file Circuit/Factory.h.

◆ CreateReset()

template<typename Time = Types::time_type>
static std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateReset ( const Types::qubits_vector &  qubits = {},
const std::vector< bool > &  resetTgts = {} 
)
inlinestatic

Construct a reset operation.

Resets the qubits to the given state. If not specified, the qubits are reset to |0>.

Parameters
qubitsThe qubits to reset.
resetTgtsThe reset values, true to reset to |1>, false to reset to |0>.
Returns
The reset operation.
See also
Reset

Definition at line 64 of file Circuit/Factory.h.

◆ CreateSimpleConditionalGate()

template<typename Time = Types::time_type>
static std::shared_ptr< IOperation< Time > > Circuits::CircuitFactory< Time >::CreateSimpleConditionalGate ( const std::shared_ptr< IGateOperation< Time > > &  operation,
const size_t  cbit 
)
inlinestatic

Construct a simple conditional gate.

Constructs a simple conditional gate with the given operation and a single cbit value. The gate is applied only if the cbit is true.

Parameters
operationThe operation to perform if the condition is met.
cbitThe cbit to be checked.
Returns
The conditional gate.
See also
ConditionalGate
IGateOperation
ICondition

Definition at line 313 of file Circuit/Factory.h.

◆ CreateStartDistributionCircuit()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateStartDistributionCircuit ( size_t  ctrlQubit,
size_t  ctrlEntangledQubit,
size_t  tgtEntangledQubit,
size_t  ctrlEntangledMeasureBit 
)
inlinestatic

Creates the circuit for distribution start.

Creates the circuit operations for the start of the distribution.

Parameters
ctrlQubitThe control qubit for the operation to distribute.
ctrlEntangledQubitThe entangled qubit on the control host.
tgtEntangledQubitThe entangled qubit on the target host.
ctrlEntangledMeasureBitThe classical bit to store the measurement of the entangled qubit on the control host.
Returns
The distribution start circuit operations.

Definition at line 499 of file Circuit/Factory.h.

◆ CreateTeleportationCircuit()

template<typename Time = Types::time_type>
static std::vector< std::shared_ptr< IOperation< Time > > > Circuits::CircuitFactory< Time >::CreateTeleportationCircuit ( size_t  entqbit1,
size_t  entqbit2,
size_t  srcqbit,
size_t  cbit1,
size_t  cbit2 
)
inlinestatic

Creates a teleportation circuit.

Creates a teleportation. The source qubit is teleported to the second entanglement qubit.

Parameters
entqbit1The first entanglment qubit.
entqbit2The second entanglement qubit.
srcqbitThe qubit to be teleported.
cbit1The classical bit to store the measurement of the qubit to be teleported.
cbit2The classical bit to store the measurement of the first entanglement qubit.
Returns
The teleportation circuit.
See also
IOperation

Definition at line 460 of file Circuit/Factory.h.


The documentation for this class was generated from the following file: