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

Circuit class for holding the sequence of operations. More...

#include <Circuit.h>

+ Inheritance diagram for Circuits::Circuit< Time >:
+ Collaboration diagram for Circuits::Circuit< Time >:

Public Types

using ExecuteResults = std::unordered_map< std::vector< bool >, size_t >
 The results of the execution of the circuit.
 
using BitMapping = std::unordered_map< Types::qubit_t, Types::qubit_t >
 The (qu)bit mapping for remapping.
 
using Operation = IOperation< Time >
 The operation type.
 
using OperationPtr = std::shared_ptr< Operation >
 The shared pointer to the operation type.
 
using OperationsVector = std::vector< OperationPtr >
 The vector of operations.
 
using value_type = typename OperationsVector::value_type
 
using allocator_type = typename OperationsVector::allocator_type
 
using pointer = typename OperationsVector::pointer
 
using const_pointer = typename OperationsVector::const_pointer
 
using reference = typename OperationsVector::reference
 
using const_reference = typename OperationsVector::const_reference
 
using size_type = typename OperationsVector::size_type
 
using difference_type = typename OperationsVector::difference_type
 
using iterator = typename OperationsVector::iterator
 
using const_iterator = typename OperationsVector::const_iterator
 
using reverse_iterator = typename OperationsVector::reverse_iterator
 
using const_reverse_iterator = typename OperationsVector::const_reverse_iterator
 

Public Member Functions

 Circuit (const OperationsVector &ops={})
 Construct a new Circuit object.
 
void Execute (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
 Execute the circuit on the given simulator.
 
OperationType GetType () const override
 Get the type of the circuit.
 
void AddOperation (const OperationPtr &op)
 Adds an operation to the circuit.
 
void ReplaceOperation (size_t index, const OperationPtr &op)
 Replaces an operation in the circuit.
 
void SetOperations (const OperationsVector &ops)
 Set the operations in the circuit.
 
void AddOperations (const OperationsVector &ops)
 Adds operations to the circuit.
 
void AddCircuit (const std::shared_ptr< Circuit< Time > > &circuit)
 Adds operations from another circuit to the circuit.
 
const OperationsVectorGetOperations () const
 Get the operations in the circuit.
 
void Clear ()
 Clears the operations from the circuit.
 
OperationPtr Clone () const override
 Get a shared pointer to a clone of this object.
 
OperationPtr CloneFlyweight () const
 Get a shared pointer to a clone of this object, but without cloning the operations.
 
OperationPtr Remap (const BitMapping &qubitsMap, const BitMapping &bitsMap={}) const override
 Get a shared pointer to a circuit remapped.
 
std::shared_ptr< Circuit< Time > > RemapToContinuous (BitMapping &newQubitsMap, BitMapping &reverseBitsMap, size_t &nrQubits, size_t &nrCbits) const
 Get a shared pointer to a circuit remapped to a continuous interval starting from zero.
 
void ConvertForDistribution ()
 Converts the circuit for distributed computing.
 
void ConvertForCutting ()
 Converts the circuit for distributed computing.
 
void EnsureProperOrderForMeasurements ()
 
size_t GetMaxQubitIndex () const
 Returns the max qubit id for all operations.
 
size_t GetMinQubitIndex () const
 Returns the min qubit id for all operations.
 
size_t GetMaxCbitIndex () const
 Returns the max classical bit id for all operations.
 
size_t GetMinCbitIndex () const
 Returns the min classical bit id for all operations.
 
std::set< size_t > GetQubits () const
 Returns the qubits affected by the operations.
 
std::set< size_t > GetBits () const
 Returns the classical bits affected by the operations.
 
Types::qubits_vector AffectedQubits () const override
 Returns the affected qubits.
 
std::vector< size_t > AffectedBits () const override
 Returns the affected bits.
 
bool NeedsEntanglementForDistribution () const override
 Find if the circuit needs entanglement for distribution.
 
bool CanAffectQuantumState () const override
 Find if the circuit can affect the quantum state.
 
std::unordered_map< size_t, OperationPtrGetLastOperationsOnQubits () const
 Returns the last operations on circuit's qubits.
 
std::unordered_map< size_t, OperationPtrGetFirstOperationsOnQubits () const
 Returns the first operations on circuit's qubits.
 
void AddResetsIfNeeded (Time delay=0)
 Add resets at the end of the circuit.
 
void AddResetsAtBeginningIfNeeded (Time delay=0)
 Add resets at the beginning of the circuit.
 
void Optimize (bool optimizeRotationGates=true)
 Circuit optimization.
 
void MoveMeasurementsAndResets ()
 Move the measurements and resets closer to the beginning of the circuit.
 
std::pair< std::vector< size_t >, std::vector< Time > > GetDepth () const
 Get circuit depth.
 
std::pair< size_t, Time > GetMaxDepth () const
 Get max circuit depth.
 
size_t GetNumberOfOperations () const
 Get the number of operations in the circuit.
 
OperationPtr GetOperation (size_t pos) const
 Get an operation at a given position.
 
std::shared_ptr< Circuit< Time > > GetCircuitCut (Types::qubit_t startQubit, Types::qubit_t endQubit) const
 Get the circuit cut.
 
bool HasOpsAfterMeasurements () const
 Checks if the circuit has measurements that are followed by operations that affect the measured qubits.
 
std::vector< bool > ExecuteNonMeasurements (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const
 Execute the non-measurements operations from the circuit on the given simulator.
 
void ExecuteMeasurements (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state, const std::vector< bool > &executedOps) const
 Execute the measurement operations from the circuit on the given simulator.
 
std::shared_ptr< MeasurementOperation< Time > > GetLastMeasurements (const std::vector< bool > &executedOps, bool sort=true) const
 
bool HasConditionalOperations () const
 Checks if the circuit has clasically conditional operations.
 
bool ActsOnlyOnAdjacentQubits () const
 Checks if the circuit has only operations that act on adjacent qubits.
 
bool IsForest () const
 Checks if the circuit is a forest circuit.
 
bool IsClifford () const override
 Checks if the circuit is a Clifford circuit.
 
double CliffordPercentage () const
 Get the percentage of Clifford operations in the circuit.
 
std::unordered_set< Types::qubit_t > GetCliffordQubits () const
 Get the qubits that are acted on by Clifford operations.
 
std::vector< std::shared_ptr< Circuit< Time > > > SplitCircuit () const
 Splits a circuit that has disjoint subcircuits in it into separate circuits.
 
iterator begin () noexcept
 Get the begin iterator for the operations.
 
iterator end () noexcept
 Get the end iterator for the operations.
 
const_iterator cbegin () const noexcept
 Get the const begin iterator for the operations.
 
const_iterator cend () const noexcept
 Get the const end iterator for the operations.
 
reverse_iterator rbegin () noexcept
 Get the reverse begin iterator for the operations.
 
reverse_iterator rend () noexcept
 Get the reverse end iterator for the operations.
 
const_reverse_iterator crbegin () const noexcept
 Get the const reverse begin iterator for the operations.
 
const_reverse_iterator crend () const noexcept
 Get the const reverse end iterator for the operations.
 
auto size () const
 Get the number of operations in the circuit.
 
auto empty () const
 Check if the circuit is empty.
 
auto & operator[] (size_t pos)
 Get the operation at a given position.
 
const auto & operator[] (size_t pos) const
 Get the operation at a given position.
 
void resize (size_t size)
 Resizes the circuit.
 
- Public Member Functions inherited from Circuits::IOperation< Time >
 IOperation (Time delay=0)
 Construct a new IOperation object.
 
virtual ~IOperation ()=default
 Destroy the IOperation object.
 
virtual bool IsConditional () const
 Find if the operation is a conditional operation.
 
std::shared_ptr< IOperation< Time > > getptr ()
 Get a shared pointer to this object.
 
Time GetDelay () const
 Get the delay of the operation.
 
void SetDelay (Time d)
 Set the delay of the operation.
 

Static Public Member Functions

static ExecuteResults RemapResultsBack (const ExecuteResults &results, const BitMapping &bitsMap={}, bool ignoreNotMapped=false, size_t sz=0)
 Map back the results for a remapped circuit.
 
static void AccumulateResults (ExecuteResults &results, const ExecuteResults &newResults)
 Accumulate the results of a circuit execution to already existing results.
 
static void AccumulateResultsWithRemapBack (ExecuteResults &results, const ExecuteResults &newResults, const BitMapping &bitsMap={}, bool ignoreNotMapped=true, size_t sz=0)
 Accumulate the results of a circuit execution to already existing results with remapping.
 

Detailed Description

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

Circuit class for holding the sequence of operations.

Contains a sequence of operations that can be executed, supplying a function that allows executing them in a simulator. Allows adding operations and converting them to prepare the circuit for distributed computing.

Template Parameters
TimeThe time type used for operation timing.
See also
IOperation
ISimulator

Definition at line 45 of file Circuit.h.

Member Typedef Documentation

◆ allocator_type

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::allocator_type = typename OperationsVector::allocator_type

Definition at line 63 of file Circuit.h.

◆ BitMapping

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::BitMapping = std::unordered_map<Types::qubit_t, Types::qubit_t>

The (qu)bit mapping for remapping.

Definition at line 51 of file Circuit.h.

◆ const_iterator

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::const_iterator = typename OperationsVector::const_iterator

Definition at line 72 of file Circuit.h.

◆ const_pointer

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::const_pointer = typename OperationsVector::const_pointer

Definition at line 65 of file Circuit.h.

◆ const_reference

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::const_reference = typename OperationsVector::const_reference

Definition at line 67 of file Circuit.h.

◆ const_reverse_iterator

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::const_reverse_iterator = typename OperationsVector::const_reverse_iterator

Definition at line 74 of file Circuit.h.

◆ difference_type

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::difference_type = typename OperationsVector::difference_type

Definition at line 69 of file Circuit.h.

◆ ExecuteResults

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::ExecuteResults = std::unordered_map<std::vector<bool>, size_t>

The results of the execution of the circuit.

Definition at line 47 of file Circuit.h.

◆ iterator

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::iterator = typename OperationsVector::iterator

Definition at line 71 of file Circuit.h.

◆ Operation

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::Operation = IOperation<Time>

The operation type.

Definition at line 56 of file Circuit.h.

◆ OperationPtr

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::OperationPtr = std::shared_ptr<Operation>

The shared pointer to the operation type.

Definition at line 57 of file Circuit.h.

◆ OperationsVector

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::OperationsVector = std::vector<OperationPtr>

The vector of operations.

Definition at line 59 of file Circuit.h.

◆ pointer

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::pointer = typename OperationsVector::pointer

Definition at line 64 of file Circuit.h.

◆ reference

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::reference = typename OperationsVector::reference

Definition at line 66 of file Circuit.h.

◆ reverse_iterator

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::reverse_iterator = typename OperationsVector::reverse_iterator

Definition at line 73 of file Circuit.h.

◆ size_type

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::size_type = typename OperationsVector::size_type

Definition at line 68 of file Circuit.h.

◆ value_type

template<typename Time = Types::time_type>
using Circuits::Circuit< Time >::value_type = typename OperationsVector::value_type

Definition at line 62 of file Circuit.h.

Constructor & Destructor Documentation

◆ Circuit()

template<typename Time = Types::time_type>
Circuits::Circuit< Time >::Circuit ( const OperationsVector ops = {})
inline

Construct a new Circuit object.

Constructs a new Circuit object with the given operations.

Parameters
opsThe operations to add to the circuit.
See also
IOperation

Definition at line 84 of file Circuit.h.

Member Function Documentation

◆ AccumulateResults()

template<typename Time = Types::time_type>
static void Circuits::Circuit< Time >::AccumulateResults ( ExecuteResults results,
const ExecuteResults newResults 
)
inlinestatic

Accumulate the results of a circuit execution to already existing results.

Accumulates the results of a circuit execution to already existing results.

Parameters
resultsThe existing results to accumulate to.
newResultsThe new results to add to the existing results.

Definition at line 325 of file Circuit.h.

◆ AccumulateResultsWithRemapBack()

template<typename Time = Types::time_type>
static void Circuits::Circuit< Time >::AccumulateResultsWithRemapBack ( ExecuteResults results,
const ExecuteResults newResults,
const BitMapping bitsMap = {},
bool  ignoreNotMapped = true,
size_t  sz = 0 
)
inlinestatic

Accumulate the results of a circuit execution to already existing results with remapping.

Accumulates the results of a circuit execution to already existing results with remapping back.

Parameters
resultsThe existing results to accumulate to.
newResultsThe new results to add to the existing results.
bitsMapThe map of classical bits to remap.
ignoreNotMappedIf true, the results that are not in the map will be ignored.
szThe size of the results vector.

Definition at line 344 of file Circuit.h.

◆ ActsOnlyOnAdjacentQubits()

template<typename Time = Types::time_type>
bool Circuits::Circuit< Time >::ActsOnlyOnAdjacentQubits ( ) const
inline

Checks if the circuit has only operations that act on adjacent qubits.

Checks if the circuit has only operations that act on adjacent qubits. Can be useful in picking up a tensor network contractor, for example. Also such a circuit is easier to simulate in a MPS simulator, since swap gates are not needed to be added to bring up the qubits next to each other before applying a two qubits gate.

Returns
True if the circuit has operations that are not gates, false otherwise.

Definition at line 1849 of file Circuit.h.

◆ AddCircuit()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::AddCircuit ( const std::shared_ptr< Circuit< Time > > &  circuit)
inline

Adds operations from another circuit to the circuit.

Adds operations from another circuit to the circuit.

Parameters
circuitThe circuit to add operations from.

Definition at line 161 of file Circuit.h.

◆ AddOperation()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::AddOperation ( const OperationPtr op)
inline

Adds an operation to the circuit.

Adds an operation to the circuit.

Parameters
opThe operation to add.
See also
IOperation

Definition at line 120 of file Circuit.h.

◆ AddOperations()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::AddOperations ( const OperationsVector ops)
inline

Adds operations to the circuit.

Adds operations to the circuit.

Parameters
opsThe operations to add.
See also
IOperation

Definition at line 151 of file Circuit.h.

◆ AddResetsAtBeginningIfNeeded()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::AddResetsAtBeginningIfNeeded ( Time  delay = 0)
inline

Add resets at the beginning of the circuit.

Adds resets at the beginning of the circuit, on the qubits that don't have a reset operation already.

Parameters
delayThe delay for the reset operation

Definition at line 736 of file Circuit.h.

◆ AddResetsIfNeeded()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::AddResetsIfNeeded ( Time  delay = 0)
inline

Add resets at the end of the circuit.

Adds resets at the end of the circuit, on the qubits that don't have a reset operation already.

Parameters
delayThe delay for the reset operation

Definition at line 717 of file Circuit.h.

◆ AffectedBits()

template<typename Time = Types::time_type>
std::vector< size_t > Circuits::Circuit< Time >::AffectedBits ( ) const
inlineoverridevirtual

Returns the affected bits.

Returns the affected classical bits.

Returns
The affected bits.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 630 of file Circuit.h.

◆ AffectedQubits()

template<typename Time = Types::time_type>
Types::qubits_vector Circuits::Circuit< Time >::AffectedQubits ( ) const
inlineoverridevirtual

Returns the affected qubits.

Returns the affected qubits by the operation.

Returns
A vector with the affected qubits.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 613 of file Circuit.h.

◆ begin()

template<typename Time = Types::time_type>
iterator Circuits::Circuit< Time >::begin ( )
inlinenoexcept

Get the begin iterator for the operations.

Returns the begin iterator for the operations.

Returns
The begin iterator for the operations.

Definition at line 2090 of file Circuit.h.

◆ CanAffectQuantumState()

template<typename Time = Types::time_type>
bool Circuits::Circuit< Time >::CanAffectQuantumState ( ) const
inlineoverridevirtual

Find if the circuit can affect the quantum state.

Returns true if the circuit can affect the quantum state, false otherwise.

Returns
True if the circuit can affect the quantum state, false otherwise.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 664 of file Circuit.h.

◆ cbegin()

template<typename Time = Types::time_type>
const_iterator Circuits::Circuit< Time >::cbegin ( ) const
inlinenoexcept

Get the const begin iterator for the operations.

Returns the const begin iterator for the operations.

Returns
The const begin iterator for the operations.

Definition at line 2106 of file Circuit.h.

◆ cend()

template<typename Time = Types::time_type>
const_iterator Circuits::Circuit< Time >::cend ( ) const
inlinenoexcept

Get the const end iterator for the operations.

Returns the const end iterator for the operations.

Returns
The const end iterator for the operations.

Definition at line 2114 of file Circuit.h.

◆ Clear()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::Clear ( )
inline

Clears the operations from the circuit.

Removes all operations from the circuit.

Definition at line 179 of file Circuit.h.

◆ CliffordPercentage()

template<typename Time = Types::time_type>
double Circuits::Circuit< Time >::CliffordPercentage ( ) const
inline

Get the percentage of Clifford operations in the circuit.

Returns the percentage of Clifford operations in the circuit. Considers gates as Clifford if they are supported by the Clifford simulator.

Returns
The percentage of Clifford operations in the circuit.

Definition at line 1950 of file Circuit.h.

◆ Clone()

template<typename Time = Types::time_type>
OperationPtr Circuits::Circuit< Time >::Clone ( ) const
inlineoverridevirtual

Get a shared pointer to a clone of this object.

Returns a shared pointer to a copy of this object.

Returns
A shared pointer to this object.

Implements Circuits::IOperation< Time >.

Definition at line 187 of file Circuit.h.

◆ CloneFlyweight()

template<typename Time = Types::time_type>
OperationPtr Circuits::Circuit< Time >::CloneFlyweight ( ) const
inline

Get a shared pointer to a clone of this object, but without cloning the operations.

Returns a shared pointer to a copy of this object, flyweight stype.

Returns
A shared pointer to this object.

Definition at line 202 of file Circuit.h.

◆ ConvertForCutting()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::ConvertForCutting ( )
inline

Converts the circuit for distributed computing.

Converts the circuit for distributed computing using circuit cutting. Converts the three qubit gates to prepare the circuit for distributed computing.

Definition at line 400 of file Circuit.h.

◆ ConvertForDistribution()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::ConvertForDistribution ( )
inline

Converts the circuit for distributed computing.

Converts the circuit for distributed computing using quantum entanglement between hosts. Converts the swap gates and three qubit gates to prepare the circuit for distributed computing.

Definition at line 385 of file Circuit.h.

◆ crbegin()

template<typename Time = Types::time_type>
const_reverse_iterator Circuits::Circuit< Time >::crbegin ( ) const
inlinenoexcept

Get the const reverse begin iterator for the operations.

Returns the const reverse begin iterator for the operations.

Returns
The const reverse begin iterator for the operations.

Definition at line 2138 of file Circuit.h.

◆ crend()

template<typename Time = Types::time_type>
const_reverse_iterator Circuits::Circuit< Time >::crend ( ) const
inlinenoexcept

Get the const reverse end iterator for the operations.

Returns the const reverse end iterator for the operations.

Returns
The const reverse end iterator for the operations.

Definition at line 2148 of file Circuit.h.

◆ empty()

template<typename Time = Types::time_type>
auto Circuits::Circuit< Time >::empty ( ) const
inline

Check if the circuit is empty.

Returns true if the circuit is empty, false otherwise.

Returns
True if the circuit is empty, false otherwise.

Definition at line 2164 of file Circuit.h.

◆ end()

template<typename Time = Types::time_type>
iterator Circuits::Circuit< Time >::end ( )
inlinenoexcept

Get the end iterator for the operations.

Returns the end iterator for the operations.

Returns
The end iterator for the operations.

Definition at line 2098 of file Circuit.h.

◆ EnsureProperOrderForMeasurements()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::EnsureProperOrderForMeasurements ( )
inline

Definition at line 419 of file Circuit.h.

◆ Execute()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::Execute ( const std::shared_ptr< Simulators::ISimulator > &  sim,
OperationState state 
) const
inlineoverridevirtual

Execute the circuit on the given simulator.

Executes the circuit on the given simulator.

Parameters
simThe simulator to execute the circuit on.
stateThe classical state containing the classical bits.
See also
ISimulator
OperationState

Implements Circuits::IOperation< Time >.

Definition at line 95 of file Circuit.h.

◆ ExecuteMeasurements()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::ExecuteMeasurements ( const std::shared_ptr< Simulators::ISimulator > &  sim,
OperationState state,
const std::vector< bool > &  executedOps 
) const
inline

Execute the measurement operations from the circuit on the given simulator.

Execute the measurements operations from the circuit on the given simulator.

Parameters
simThe simulator to execute the circuit on.
stateThe classical state containing the classical bits.
See also
ISimulator
OperationState

Definition at line 1772 of file Circuit.h.

◆ ExecuteNonMeasurements()

template<typename Time = Types::time_type>
std::vector< bool > Circuits::Circuit< Time >::ExecuteNonMeasurements ( const std::shared_ptr< Simulators::ISimulator > &  sim,
OperationState state 
) const
inline

Execute the non-measurements operations from the circuit on the given simulator.

Execute the non-measurements operations from the circuit on the given simulator.

Parameters
simThe simulator to execute the circuit on.
stateThe classical state containing the classical bits.
Returns
A bool vector with the executed operations marked.
See also
ISimulator
OperationState

Definition at line 1675 of file Circuit.h.

◆ GetBits()

template<typename Time = Types::time_type>
std::set< size_t > Circuits::Circuit< Time >::GetBits ( ) const
inline

Returns the classical bits affected by the operations.

Returns the classical bits affected by the operations.

Returns
The bits affected by the operations

Definition at line 597 of file Circuit.h.

◆ GetCircuitCut()

template<typename Time = Types::time_type>
std::shared_ptr< Circuit< Time > > Circuits::Circuit< Time >::GetCircuitCut ( Types::qubit_t  startQubit,
Types::qubit_t  endQubit 
) const
inline

Get the circuit cut.

Cuts out a circuit from the current circuit, starting from the startQubit and ending at the endQubit. Throws an exception if there is an operation that affects both qubits inside and outside of the specified interval. The returned circuit contains only operations that act on the qubits in the specified interval.

Parameters
startQubitThe start qubit of the interval.
endQubitThe end qubit of the interval.
Returns
The circuit cut.

Definition at line 1561 of file Circuit.h.

◆ GetCliffordQubits()

template<typename Time = Types::time_type>
std::unordered_set< Types::qubit_t > Circuits::Circuit< Time >::GetCliffordQubits ( ) const
inline

Get the qubits that are acted on by Clifford operations.

Returns the qubits that are acted on only by Clifford operations. Considers gates as Clifford if they are supported by the Clifford simulator.

Returns
The qubits that are acted on only by Clifford operations.

Definition at line 1967 of file Circuit.h.

◆ GetDepth()

template<typename Time = Types::time_type>
std::pair< std::vector< size_t >, std::vector< Time > > Circuits::Circuit< Time >::GetDepth ( ) const
inline

Get circuit depth.

Returns the depth of the circuit as a pair of the depth and an estimate of time cost for each qubit. Should be considered only as an estimate.

Returns
The depth of the circuit as a pair of the depth and an estimate of time cost for each qubit.

Definition at line 1413 of file Circuit.h.

◆ GetFirstOperationsOnQubits()

template<typename Time = Types::time_type>
std::unordered_map< size_t, OperationPtr > Circuits::Circuit< Time >::GetFirstOperationsOnQubits ( ) const
inline

Returns the first operations on circuit's qubits.

Returns the first operations on circuit's qubits.

Returns
The first operations on circuit's qubits

Definition at line 696 of file Circuit.h.

◆ GetLastMeasurements()

template<typename Time = Types::time_type>
std::shared_ptr< MeasurementOperation< Time > > Circuits::Circuit< Time >::GetLastMeasurements ( const std::vector< bool > &  executedOps,
bool  sort = true 
) const
inline

Definition at line 1791 of file Circuit.h.

◆ GetLastOperationsOnQubits()

template<typename Time = Types::time_type>
std::unordered_map< size_t, OperationPtr > Circuits::Circuit< Time >::GetLastOperationsOnQubits ( ) const
inline

Returns the last operations on circuit's qubits.

Returns the last operations on circuit's qubits.

Returns
The last operations on circuit's qubits

Definition at line 678 of file Circuit.h.

◆ GetMaxCbitIndex()

template<typename Time = Types::time_type>
size_t Circuits::Circuit< Time >::GetMaxCbitIndex ( ) const
inline

Returns the max classical bit id for all operations.

Returns the max classical bit id for all operations.

Returns
The max classical bit id for all operations

Definition at line 542 of file Circuit.h.

◆ GetMaxDepth()

template<typename Time = Types::time_type>
std::pair< size_t, Time > Circuits::Circuit< Time >::GetMaxDepth ( ) const
inline

Get max circuit depth.

Returns the max depth of the circuit as a pair of the max depth and an estimate of max time cost. Should be considered only as an estimate.

Returns
The max depth of the circuit as a pair of the max depth and an estimate of time cost.

Definition at line 1513 of file Circuit.h.

◆ GetMaxQubitIndex()

template<typename Time = Types::time_type>
size_t Circuits::Circuit< Time >::GetMaxQubitIndex ( ) const
inline

Returns the max qubit id for all operations.

Returns the max qubit id for all operations.

Returns
The max qubit id for all operations

Definition at line 506 of file Circuit.h.

◆ GetMinCbitIndex()

template<typename Time = Types::time_type>
size_t Circuits::Circuit< Time >::GetMinCbitIndex ( ) const
inline

Returns the min classical bit id for all operations.

Returns the min classical bit id for all operations.

Returns
The min classical bit id for all operations

Definition at line 560 of file Circuit.h.

◆ GetMinQubitIndex()

template<typename Time = Types::time_type>
size_t Circuits::Circuit< Time >::GetMinQubitIndex ( ) const
inline

Returns the min qubit id for all operations.

Returns the min qubit id for all operations.

Returns
The min qubit id for all operations

Definition at line 524 of file Circuit.h.

◆ GetNumberOfOperations()

template<typename Time = Types::time_type>
size_t Circuits::Circuit< Time >::GetNumberOfOperations ( ) const
inline

Get the number of operations in the circuit.

Returns the number of operations in the circuit.

Returns
The number of operations in the circuit.

Definition at line 1532 of file Circuit.h.

◆ GetOperation()

template<typename Time = Types::time_type>
OperationPtr Circuits::Circuit< Time >::GetOperation ( size_t  pos) const
inline

Get an operation at a given position.

Returns the operation at the given position.

Parameters
posThe position of the operation to get.
Returns
The operation at the given position.

Definition at line 1542 of file Circuit.h.

◆ GetOperations()

template<typename Time = Types::time_type>
const OperationsVector & Circuits::Circuit< Time >::GetOperations ( ) const
inline

Get the operations in the circuit.

Returns the operations in the circuit.

Returns
The operations in the circuit.
See also
IOperation

Definition at line 172 of file Circuit.h.

◆ GetQubits()

template<typename Time = Types::time_type>
std::set< size_t > Circuits::Circuit< Time >::GetQubits ( ) const
inline

Returns the qubits affected by the operations.

Returns the qubits affected by the operations. They might not cover all qubits, there might be gaps. In such cases a remapping might be needed, for example in a scheduler.

Returns
The qubits affected by the operations

Definition at line 580 of file Circuit.h.

◆ GetType()

template<typename Time = Types::time_type>
OperationType Circuits::Circuit< Time >::GetType ( ) const
inlineoverridevirtual

Get the type of the circuit.

Returns the type of the circuit.

Returns
The type of the circuit.
See also
OperationType

Reimplemented from Circuits::IOperation< Time >.

Definition at line 111 of file Circuit.h.

◆ HasConditionalOperations()

template<typename Time = Types::time_type>
bool Circuits::Circuit< Time >::HasConditionalOperations ( ) const
inline

Checks if the circuit has clasically conditional operations.

Checks if the circuit has clasically conditional operations.

Returns
True if the circuit has clasically conditional operations, false otherwise.

Definition at line 1826 of file Circuit.h.

◆ HasOpsAfterMeasurements()

template<typename Time = Types::time_type>
bool Circuits::Circuit< Time >::HasOpsAfterMeasurements ( ) const
inline

Checks if the circuit has measurements that are followed by operations that affect the measured qubits.

Checks if the circuit has measurements that are followed by operations that affect the measured qubits.

Returns
True if the circuit has measurements that are followed by operations that affect the measured qubits, false otherwise.

Definition at line 1601 of file Circuit.h.

◆ IsClifford()

template<typename Time = Types::time_type>
bool Circuits::Circuit< Time >::IsClifford ( ) const
inlineoverridevirtual

Checks if the circuit is a Clifford circuit.

Checks if the circuit is a Clifford circuit. Considers gates as Clifford if they are supported by the Clifford simulator.

Returns
True if the circuit is a Clifford circuit, false otherwise.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 1934 of file Circuit.h.

◆ IsForest()

template<typename Time = Types::time_type>
bool Circuits::Circuit< Time >::IsForest ( ) const
inline

Checks if the circuit is a forest circuit.

Checks if the circuit is a forest circuit.

Returns
True if the circuit is a forest circuit, false otherwise.

Definition at line 1881 of file Circuit.h.

◆ MoveMeasurementsAndResets()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::MoveMeasurementsAndResets ( )
inline

Move the measurements and resets closer to the beginning of the circuit.

Moves the measurements and resets closer to the beginning of the circuit.

Definition at line 1277 of file Circuit.h.

◆ NeedsEntanglementForDistribution()

template<typename Time = Types::time_type>
bool Circuits::Circuit< Time >::NeedsEntanglementForDistribution ( ) const
inlineoverridevirtual

Find if the circuit needs entanglement for distribution.

Returns true if the circuit needs entanglement for distribution, false otherwise.

Returns
True if the circuit needs entanglement for distribution, false otherwise.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 650 of file Circuit.h.

◆ operator[]() [1/2]

template<typename Time = Types::time_type>
auto & Circuits::Circuit< Time >::operator[] ( size_t  pos)
inline

Get the operation at a given position.

Returns the operation at the given position.

Parameters
posThe position of the operation to get.
Returns
The operation at the given position.

Definition at line 2173 of file Circuit.h.

◆ operator[]() [2/2]

template<typename Time = Types::time_type>
const auto & Circuits::Circuit< Time >::operator[] ( size_t  pos) const
inline

Get the operation at a given position.

Returns the operation at the given position.

Parameters
posThe position of the operation to get.
Returns
The operation at the given position.

Definition at line 2182 of file Circuit.h.

◆ Optimize()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::Optimize ( bool  optimizeRotationGates = true)
inline

Circuit optimization.

Optimizes the circuit. See qisikit aer for 'transpilling' when the circuit is flushed for some ideas.

Definition at line 755 of file Circuit.h.

◆ rbegin()

template<typename Time = Types::time_type>
reverse_iterator Circuits::Circuit< Time >::rbegin ( )
inlinenoexcept

Get the reverse begin iterator for the operations.

Returns the reverse begin iterator for the operations.

Returns
The reverse begin iterator for the operations.

Definition at line 2122 of file Circuit.h.

◆ Remap()

template<typename Time = Types::time_type>
OperationPtr Circuits::Circuit< Time >::Remap ( const BitMapping qubitsMap,
const BitMapping bitsMap = {} 
) const
inlineoverridevirtual

Get a shared pointer to a circuit remapped.

Returns a shared pointer to a copy of the circuit with qubits and classical bits changed according to the provided maps.

Parameters
qubitsMapThe map of qubits to remap.
bitsMapThe map of classical bits to remap.
Returns
A shared pointer to the remapped circuit.

Implements Circuits::IOperation< Time >.

Definition at line 220 of file Circuit.h.

◆ RemapResultsBack()

template<typename Time = Types::time_type>
static ExecuteResults Circuits::Circuit< Time >::RemapResultsBack ( const ExecuteResults results,
const BitMapping bitsMap = {},
bool  ignoreNotMapped = false,
size_t  sz = 0 
)
inlinestatic

Map back the results for a remapped circuit.

Maps back the results for a remapped circuit, using the provided map. The results are the results of the execution of the circuit without remapping.

Parameters
resultsThe results to map back.
bitsMapThe map of classical bits to remap.
ignoreNotMappedIf true, the results that are not in the map will be ignored.
szThe size of the results vector.
Returns
The mapped back results.
See also
Circuit::Remap

Definition at line 293 of file Circuit.h.

◆ RemapToContinuous()

template<typename Time = Types::time_type>
std::shared_ptr< Circuit< Time > > Circuits::Circuit< Time >::RemapToContinuous ( BitMapping newQubitsMap,
BitMapping reverseBitsMap,
size_t &  nrQubits,
size_t &  nrCbits 
) const
inline

Get a shared pointer to a circuit remapped to a continuous interval starting from zero.

Returns a shared pointer to a copy of the circuit with qubits and classical bits changed according to the provided maps.

Parameters
bitsMapThe map of classical bits, to allow remapping the results back to the original circuit results.
Returns
A shared pointer to the remapped circuit.

Definition at line 241 of file Circuit.h.

◆ rend()

template<typename Time = Types::time_type>
reverse_iterator Circuits::Circuit< Time >::rend ( )
inlinenoexcept

Get the reverse end iterator for the operations.

Returns the reverse end iterator for the operations.

Returns
The reverse end iterator for the operations.

Definition at line 2130 of file Circuit.h.

◆ ReplaceOperation()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::ReplaceOperation ( size_t  index,
const OperationPtr op 
)
inline

Replaces an operation in the circuit.

Replaces an operation in the circuit.

Parameters
indexThe index of the operation to replace.
opThe operation to replace with.
See also
IOperation

Definition at line 130 of file Circuit.h.

◆ resize()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::resize ( size_t  size)
inline

Resizes the circuit.

Resizes the circuit, but it cannot make it larger, only smaller, by removing the last operations.

Parameters
sizeThe new size of the circuit.

Definition at line 2191 of file Circuit.h.

◆ SetOperations()

template<typename Time = Types::time_type>
void Circuits::Circuit< Time >::SetOperations ( const OperationsVector ops)
inline

Set the operations in the circuit.

Sets the operations in the circuit.

Parameters
opsThe operations to set.
See also
IOperation

Definition at line 142 of file Circuit.h.

◆ size()

template<typename Time = Types::time_type>
auto Circuits::Circuit< Time >::size ( ) const
inline

Get the number of operations in the circuit.

Returns the number of operations in the circuit.

Returns
The number of operations in the circuit.

Definition at line 2156 of file Circuit.h.

◆ SplitCircuit()

template<typename Time = Types::time_type>
std::vector< std::shared_ptr< Circuit< Time > > > Circuits::Circuit< Time >::SplitCircuit ( ) const
inline

Splits a circuit that has disjoint subcircuits in it into separate circuits.

Splits a circuit that has disjoint subcircuits in it into separate circuits.

Returns
A vector of shared pointers to the separate circuits.

Definition at line 1994 of file Circuit.h.


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