Maestro 0.2.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Circuits::ComparableCircuit< Time > Class Template Referenceabstract

Circuit class for holding the sequence of operations that can be compared with another circuit. More...

#include <Circuit.h>

Inheritance diagram for Circuits::ComparableCircuit< Time >:
Collaboration diagram for Circuits::ComparableCircuit< Time >:

Public Types

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

Public Member Functions

 ComparableCircuit (const BaseClass &circ)
 Construct a new ComparableCircuit object.
 ComparableCircuit (const OperationsVector &ops={})
 Construct a new ComparableCircuit object.
bool ActsOnlyOnAdjacentQubits () const
 Checks if the circuit has only operations that act on adjacent qubits.
void AddCircuit (const std::shared_ptr< Circuit< Types::time_type > > &circuit)
 Adds operations from another circuit to the circuit.
void AddOperation (const OperationPtr &op)
 Adds an operation to the circuit.
void AddOperations (const OperationsVector &ops)
 Adds operations to the circuit.
void AddResetsAtBeginningIfNeeded (Types::time_type delay=0)
 Add resets at the beginning of the circuit.
void AddResetsIfNeeded (Types::time_type delay=0)
 Add resets at the end of the circuit.
std::vector< size_t > AffectedBits () const override
 Returns the affected bits.
Types::qubits_vector AffectedQubits () const override
 Returns the affected qubits.
iterator begin () noexcept
 Get the begin iterator for the operations.
bool CanAffectQuantumState () const override
 Find if the circuit can affect the quantum state.
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.
void Clear ()
 Clears the operations from the circuit.
double CliffordPercentage () const
 Get the percentage of Clifford operations in 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.
void ConvertForCutting ()
 Converts the circuit for distributed computing.
void ConvertForDistribution ()
 Converts the circuit for distributed computing.
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 empty () const
 Check if the circuit is empty.
iterator end () noexcept
 Get the end iterator for the operations.
void EnsureProperOrderForMeasurements ()
void Execute (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
 Execute 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::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.
bool GetApproximateParamsCheck () const
 Gets whether to check approximate equality of gate parameters.
std::set< size_t > GetBits () const
 Returns the classical bits affected by the operations.
std::shared_ptr< Circuit< Types::time_type > > GetCircuitCut (Types::qubit_t startQubit, Types::qubit_t endQubit) const
 Get the circuit cut.
std::unordered_set< Types::qubit_tGetCliffordQubits () const
 Get the qubits that are acted on by Clifford operations.
Types::time_type GetDelay () const
 Get the delay of the operation.
std::pair< std::vector< size_t >, std::vector< Types::time_type > > GetDepth () const
 Get circuit depth.
std::unordered_map< size_t, OperationPtrGetFirstOperationsOnQubits () const
 Returns the first operations on circuit's qubits.
std::shared_ptr< MeasurementOperation< Types::time_type > > GetLastMeasurements (const std::vector< bool > &executedOps, bool sort=true) const
std::unordered_map< size_t, OperationPtrGetLastOperationsOnQubits () const
 Returns the last operations on circuit's qubits.
size_t GetMaxCbitIndex () const
 Returns the max classical bit id for all operations.
std::pair< size_t, Types::time_typeGetMaxDepth () const
 Get max circuit depth.
size_t GetMaxQubitIndex () const
 Returns the max qubit id for all operations.
size_t GetMinCbitIndex () const
 Returns the min classical bit id for all operations.
size_t GetMinQubitIndex () const
 Returns the min qubit id for all operations.
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.
const OperationsVectorGetOperations () const
 Get the operations in the circuit.
double GetParamsEpsilon () const
 Gets the epsilon used for checking approximate equality of gate parameters.
std::shared_ptr< IOperation< Types::time_type > > getptr ()
 Get a shared pointer to this object.
std::set< size_t > GetQubits () const
 Returns the qubits affected by the operations.
OperationType GetType () const override
 Get the type of the circuit.
bool HasConditionalOperations () const
 Checks if the circuit has clasically conditional operations.
bool HasOpsAfterMeasurements () const
 Checks if the circuit has measurements that are followed by operations that affect the measured qubits.
bool IsBranching () const override
 Checks if any operation is a branching one.
bool IsClifford () const override
 Checks if the circuit is a Clifford circuit.
virtual bool IsConditional () const
 Find if the operation is a conditional operation.
bool IsForest () const
 Checks if the circuit is a forest circuit.
void MoveMeasurementsAndResets ()
 Move the measurements and resets closer to the beginning of the circuit.
bool NeedsEntanglementForDistribution () const override
 Find if the circuit needs entanglement for distribution.
bool operator!= (const BaseClass &rhs) const
 Comparison operator.
ComparableCircuitoperator= (const BaseClass &circ)
 Assignment operator.
bool operator== (const BaseClass &rhs) const
 Comparison operator.
auto & operator[] (size_t pos)
 Get the operation at a given position.
void Optimize (bool optimizeRotationGates=true)
 Circuit optimization.
reverse_iterator rbegin () noexcept
 Get the reverse begin iterator for the operations.
OperationPtr Remap (const BitMapping &qubitsMap, const BitMapping &bitsMap={}) const override
 Get a shared pointer to a circuit remapped.
virtual std::shared_ptr< IOperation< Types::time_type > > Remap (const std::unordered_map< Types::qubit_t, Types::qubit_t > &qubitsMap, const std::unordered_map< Types::qubit_t, Types::qubit_t > &bitsMap={}) const =0
 Get a shared pointer to a remapped operation.
std::shared_ptr< Circuit< Types::time_type > > 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.
std::shared_ptr< Circuits::Circuit< Types::time_type > > RemoveExecutedOperations (std::vector< bool > &executedOps) const
 Returns a new circuit with the operations that were not yet executed.
reverse_iterator rend () noexcept
 Get the reverse end iterator for the operations.
void ReplaceOperation (size_t index, const OperationPtr &op)
 Replaces an operation in the circuit.
void resize (size_t size)
 Resizes the circuit.
void SetApproximateParamsCheck (bool check)
 Sets whether to check approximate equality of gate parameters.
void SetDelay (Types::time_type d)
 Set the delay of the operation.
void SetOperations (const OperationsVector &ops)
 Set the operations in the circuit.
void SetParamsEpsilon (double eps)
 Sets the epsilon used for checking approximate equality of gate parameters.
auto size () const
 Get the number of operations in the circuit.
std::vector< std::shared_ptr< Circuit< Types::time_type > > > SplitCircuit () const
 Splits a circuit that has disjoint subcircuits in it into separate circuits.
std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > ToLayers () const
 Converts the circuit to layers.
std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > ToLayersNoClone () const
 Converts the circuit to layers.
std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > ToMultipleQubitsLayers () const
 Converts the circuit to layers oriented on multiple qubit gates.
std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > ToMultipleQubitsLayersNoClone () const
 Converts the circuit to layers oriented on multiple qubit gates.

Static Public Member Functions

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.
static std::shared_ptr< Circuits::Circuit< Types::time_type > > LayersToCircuit (const std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > &layers)
 Converts the layers back to a circuit.
static ExecuteResults RemapResultsBack (const ExecuteResults &results, const BitMapping &bitsMap={}, bool ignoreNotMapped=false, size_t sz=0)
 Map back the results for a remapped circuit.

Detailed Description

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

Circuit class for holding the sequence of operations that can be compared with another circuit.

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
Circuit
IOperation
ISimulator

Definition at line 2718 of file Circuit.h.

Member Typedef Documentation

◆ allocator_type

using Circuits::Circuit< Types::time_type >::allocator_type
inherited

Definition at line 64 of file Circuit.h.

◆ BaseClass

template<typename Time = Types::time_type>
using Circuits::ComparableCircuit< Time >::BaseClass = Circuit<Time>

The base class type.

Definition at line 2720 of file Circuit.h.

◆ BitMapping

using Circuits::Circuit< Types::time_type >::BitMapping
inherited

The (qu)bit mapping for remapping.

Definition at line 52 of file Circuit.h.

◆ const_iterator

using Circuits::Circuit< Types::time_type >::const_iterator
inherited

Definition at line 73 of file Circuit.h.

◆ const_pointer

using Circuits::Circuit< Types::time_type >::const_pointer
inherited

Definition at line 66 of file Circuit.h.

◆ const_reference

using Circuits::Circuit< Types::time_type >::const_reference
inherited

Definition at line 68 of file Circuit.h.

◆ const_reverse_iterator

using Circuits::Circuit< Types::time_type >::const_reverse_iterator
inherited

Definition at line 75 of file Circuit.h.

◆ difference_type

using Circuits::Circuit< Types::time_type >::difference_type
inherited

Definition at line 70 of file Circuit.h.

◆ ExecuteResults

using Circuits::Circuit< Types::time_type >::ExecuteResults
inherited

The results of the execution of the circuit.

Definition at line 48 of file Circuit.h.

◆ iterator

using Circuits::Circuit< Types::time_type >::iterator
inherited

Definition at line 72 of file Circuit.h.

◆ Operation

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

The operation type.

Definition at line 2721 of file Circuit.h.

◆ OperationPtr

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

The shared pointer to the operation type.

Definition at line 2722 of file Circuit.h.

◆ OperationsVector

template<typename Time = Types::time_type>
using Circuits::ComparableCircuit< Time >::OperationsVector
Initial value:
std::vector<OperationPtr>

The vector of operations.

Definition at line 2724 of file Circuit.h.

◆ pointer

using Circuits::Circuit< Types::time_type >::pointer
inherited

Definition at line 65 of file Circuit.h.

◆ reference

using Circuits::Circuit< Types::time_type >::reference
inherited

Definition at line 67 of file Circuit.h.

◆ reverse_iterator

using Circuits::Circuit< Types::time_type >::reverse_iterator
inherited

Definition at line 74 of file Circuit.h.

◆ size_type

using Circuits::Circuit< Types::time_type >::size_type
inherited

Definition at line 69 of file Circuit.h.

◆ value_type

using Circuits::Circuit< Types::time_type >::value_type
inherited

Definition at line 63 of file Circuit.h.

Constructor & Destructor Documentation

◆ ComparableCircuit() [1/2]

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

Construct a new ComparableCircuit object.

Constructs a new ComparableCircuit object with the given operations.

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

Definition at line 2734 of file Circuit.h.

Referenced by operator=(), and operator==().

◆ ComparableCircuit() [2/2]

template<typename Time = Types::time_type>
Circuits::ComparableCircuit< Time >::ComparableCircuit ( const BaseClass & circ)
inline

Construct a new ComparableCircuit object.

Constructs a new ComparableCircuit object with the given Circuit.

Parameters
circuitThe circuit from where to add the operations to the comparable circuit.
See also
Circuit

Definition at line 2744 of file Circuit.h.

References Circuits::Circuit< Types::time_type >::GetOperations().

Member Function Documentation

◆ AccumulateResults()

void Circuits::Circuit< Types::time_type >::AccumulateResults ( ExecuteResults & results,
const ExecuteResults & newResults )
inlinestaticinherited

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 326 of file Circuit.h.

◆ AccumulateResultsWithRemapBack()

void Circuits::Circuit< Types::time_type >::AccumulateResultsWithRemapBack ( ExecuteResults & results,
const ExecuteResults & newResults,
const BitMapping & bitsMap = {},
bool ignoreNotMapped = true,
size_t sz = 0 )
inlinestaticinherited

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 345 of file Circuit.h.

◆ ActsOnlyOnAdjacentQubits()

bool Circuits::Circuit< Types::time_type >::ActsOnlyOnAdjacentQubits ( ) const
inlineinherited

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 1890 of file Circuit.h.

◆ AddCircuit()

void Circuits::Circuit< Types::time_type >::AddCircuit ( const std::shared_ptr< Circuit< Types::time_type > > & circuit)
inlineinherited

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 162 of file Circuit.h.

◆ AddOperation()

void Circuits::Circuit< Types::time_type >::AddOperation ( const OperationPtr & op)
inlineinherited

Adds an operation to the circuit.

Adds an operation to the circuit.

Parameters
opThe operation to add.
See also
IOperation

Definition at line 121 of file Circuit.h.

◆ AddOperations()

void Circuits::Circuit< Types::time_type >::AddOperations ( const OperationsVector & ops)
inlineinherited

Adds operations to the circuit.

Adds operations to the circuit.

Parameters
opsThe operations to add.
See also
IOperation

Definition at line 152 of file Circuit.h.

◆ AddResetsAtBeginningIfNeeded()

void Circuits::Circuit< Types::time_type >::AddResetsAtBeginningIfNeeded ( Types::time_type delay = 0)
inlineinherited

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 737 of file Circuit.h.

◆ AddResetsIfNeeded()

void Circuits::Circuit< Types::time_type >::AddResetsIfNeeded ( Types::time_type delay = 0)
inlineinherited

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 718 of file Circuit.h.

◆ AffectedBits()

std::vector< size_t > Circuits::Circuit< Types::time_type >::AffectedBits ( ) const
inlineoverridevirtualinherited

Returns the affected bits.

Returns the affected classical bits.

Returns
The affected bits.

Reimplemented from Circuits::IOperation< Types::time_type >.

Definition at line 631 of file Circuit.h.

Referenced by Circuits::ComparableCircuit< Time >::operator==().

◆ AffectedQubits()

Types::qubits_vector Circuits::Circuit< Types::time_type >::AffectedQubits ( ) const
inlineoverridevirtualinherited

Returns the affected qubits.

Returns the affected qubits by the operation.

Returns
A vector with the affected qubits.

Reimplemented from Circuits::IOperation< Types::time_type >.

Definition at line 614 of file Circuit.h.

Referenced by Circuits::ComparableCircuit< Time >::operator==().

◆ begin()

iterator Circuits::Circuit< Types::time_type >::begin ( )
inlinenoexceptinherited

Get the begin iterator for the operations.

Returns the begin iterator for the operations.

Returns
The begin iterator for the operations.

Definition at line 2448 of file Circuit.h.

◆ CanAffectQuantumState()

bool Circuits::Circuit< Types::time_type >::CanAffectQuantumState ( ) const
inlineoverridevirtualinherited

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< Types::time_type >.

Definition at line 665 of file Circuit.h.

◆ cbegin()

const_iterator Circuits::Circuit< Types::time_type >::cbegin ( ) const
inlinenoexceptinherited

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 2464 of file Circuit.h.

◆ cend()

const_iterator Circuits::Circuit< Types::time_type >::cend ( ) const
inlinenoexceptinherited

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 2472 of file Circuit.h.

◆ Clear()

void Circuits::Circuit< Types::time_type >::Clear ( )
inlineinherited

Clears the operations from the circuit.

Removes all operations from the circuit.

Definition at line 180 of file Circuit.h.

◆ CliffordPercentage()

double Circuits::Circuit< Types::time_type >::CliffordPercentage ( ) const
inlineinherited

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 1991 of file Circuit.h.

◆ Clone()

OperationPtr Circuits::Circuit< Types::time_type >::Clone ( ) const
inlineoverridevirtualinherited

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< Types::time_type >.

Definition at line 188 of file Circuit.h.

◆ CloneFlyweight()

OperationPtr Circuits::Circuit< Types::time_type >::CloneFlyweight ( ) const
inlineinherited

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 203 of file Circuit.h.

◆ ConvertForCutting()

void Circuits::Circuit< Types::time_type >::ConvertForCutting ( )
inlineinherited

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 401 of file Circuit.h.

◆ ConvertForDistribution()

void Circuits::Circuit< Types::time_type >::ConvertForDistribution ( )
inlineinherited

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 386 of file Circuit.h.

◆ crbegin()

const_reverse_iterator Circuits::Circuit< Types::time_type >::crbegin ( ) const
inlinenoexceptinherited

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 2496 of file Circuit.h.

◆ crend()

const_reverse_iterator Circuits::Circuit< Types::time_type >::crend ( ) const
inlinenoexceptinherited

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 2506 of file Circuit.h.

◆ empty()

auto Circuits::Circuit< Types::time_type >::empty ( ) const
inlineinherited

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 2522 of file Circuit.h.

◆ end()

iterator Circuits::Circuit< Types::time_type >::end ( )
inlinenoexceptinherited

Get the end iterator for the operations.

Returns the end iterator for the operations.

Returns
The end iterator for the operations.

Definition at line 2456 of file Circuit.h.

◆ EnsureProperOrderForMeasurements()

void Circuits::Circuit< Types::time_type >::EnsureProperOrderForMeasurements ( )
inlineinherited

Definition at line 420 of file Circuit.h.

◆ Execute()

void Circuits::Circuit< Types::time_type >::Execute ( const std::shared_ptr< Simulators::ISimulator > & sim,
OperationState & state ) const
inlineoverridevirtualinherited

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< Types::time_type >.

Definition at line 96 of file Circuit.h.

◆ ExecuteMeasurements()

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

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 1781 of file Circuit.h.

◆ ExecuteNonMeasurements()

std::vector< bool > Circuits::Circuit< Types::time_type >::ExecuteNonMeasurements ( const std::shared_ptr< Simulators::ISimulator > & sim,
OperationState & state ) const
inlineinherited

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 1677 of file Circuit.h.

◆ GetApproximateParamsCheck()

template<typename Time = Types::time_type>
bool Circuits::ComparableCircuit< Time >::GetApproximateParamsCheck ( ) const
inline

Gets whether to check approximate equality of gate parameters.

Gets whether to check approximate equality of gate parameters.

Returns
Whether to check approximate equality of gate parameters.

Definition at line 2906 of file Circuit.h.

◆ GetBits()

std::set< size_t > Circuits::Circuit< Types::time_type >::GetBits ( ) const
inlineinherited

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 598 of file Circuit.h.

◆ GetCircuitCut()

std::shared_ptr< Circuit< Types::time_type > > Circuits::Circuit< Types::time_type >::GetCircuitCut ( Types::qubit_t startQubit,
Types::qubit_t endQubit ) const
inlineinherited

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 1562 of file Circuit.h.

◆ GetCliffordQubits()

std::unordered_set< Types::qubit_t > Circuits::Circuit< Types::time_type >::GetCliffordQubits ( ) const
inlineinherited

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 2008 of file Circuit.h.

◆ GetDelay()

Types::time_type Circuits::IOperation< Types::time_type >::GetDelay ( ) const
inlineinherited

Get the delay of the operation.

Returns the delay due of the execution time of the operation.

Returns
The delay of the operation.

Definition at line 497 of file Operations.h.

Referenced by Circuits::ComparableCircuit< Time >::operator==().

◆ GetDepth()

std::pair< std::vector< size_t >, std::vector< Types::time_type > > Circuits::Circuit< Types::time_type >::GetDepth ( ) const
inlineinherited

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 1414 of file Circuit.h.

◆ GetFirstOperationsOnQubits()

std::unordered_map< size_t, OperationPtr > Circuits::Circuit< Types::time_type >::GetFirstOperationsOnQubits ( ) const
inlineinherited

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 697 of file Circuit.h.

◆ GetLastMeasurements()

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

Definition at line 1832 of file Circuit.h.

◆ GetLastOperationsOnQubits()

std::unordered_map< size_t, OperationPtr > Circuits::Circuit< Types::time_type >::GetLastOperationsOnQubits ( ) const
inlineinherited

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 679 of file Circuit.h.

◆ GetMaxCbitIndex()

size_t Circuits::Circuit< Types::time_type >::GetMaxCbitIndex ( ) const
inlineinherited

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 543 of file Circuit.h.

◆ GetMaxDepth()

std::pair< size_t, Types::time_type > Circuits::Circuit< Types::time_type >::GetMaxDepth ( ) const
inlineinherited

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 1514 of file Circuit.h.

◆ GetMaxQubitIndex()

size_t Circuits::Circuit< Types::time_type >::GetMaxQubitIndex ( ) const
inlineinherited

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 507 of file Circuit.h.

◆ GetMinCbitIndex()

size_t Circuits::Circuit< Types::time_type >::GetMinCbitIndex ( ) const
inlineinherited

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 561 of file Circuit.h.

◆ GetMinQubitIndex()

size_t Circuits::Circuit< Types::time_type >::GetMinQubitIndex ( ) const
inlineinherited

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 525 of file Circuit.h.

◆ GetNumberOfOperations()

size_t Circuits::Circuit< Types::time_type >::GetNumberOfOperations ( ) const
inlineinherited

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 1533 of file Circuit.h.

◆ GetOperation()

OperationPtr Circuits::Circuit< Types::time_type >::GetOperation ( size_t pos) const
inlineinherited

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 1543 of file Circuit.h.

Referenced by Circuits::ComparableCircuit< Time >::operator==().

◆ GetOperations()

const OperationsVector & Circuits::Circuit< Types::time_type >::GetOperations ( ) const
inlineinherited

Get the operations in the circuit.

Returns the operations in the circuit.

Returns
The operations in the circuit.
See also
IOperation

Definition at line 173 of file Circuit.h.

Referenced by Circuits::ComparableCircuit< Time >::ComparableCircuit().

◆ GetParamsEpsilon()

template<typename Time = Types::time_type>
double Circuits::ComparableCircuit< Time >::GetParamsEpsilon ( ) const
inline

Gets the epsilon used for checking approximate equality of gate parameters.

Gets the epsilon used for checking approximate equality of gate parameters.

Returns
The epsilon used for checking approximate equality of gate parameters.

Definition at line 2926 of file Circuit.h.

◆ getptr()

std::shared_ptr< IOperation< Types::time_type > > Circuits::IOperation< Types::time_type >::getptr ( )
inlineinherited

Get a shared pointer to this object.

Returns a shared pointer to this object. The object needs to be already wrapped in a shared pointer.

Returns
A shared pointer to this object.

Definition at line 487 of file Operations.h.

◆ GetQubits()

std::set< size_t > Circuits::Circuit< Types::time_type >::GetQubits ( ) const
inlineinherited

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 581 of file Circuit.h.

◆ GetType()

OperationType Circuits::Circuit< Types::time_type >::GetType ( ) const
inlineoverridevirtualinherited

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< Types::time_type >.

Definition at line 112 of file Circuit.h.

Referenced by Circuits::ComparableCircuit< Time >::operator==().

◆ HasConditionalOperations()

bool Circuits::Circuit< Types::time_type >::HasConditionalOperations ( ) const
inlineinherited

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 1867 of file Circuit.h.

◆ HasOpsAfterMeasurements()

bool Circuits::Circuit< Types::time_type >::HasOpsAfterMeasurements ( ) const
inlineinherited

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 1602 of file Circuit.h.

◆ IsBranching()

bool Circuits::Circuit< Types::time_type >::IsBranching ( ) const
inlineoverridevirtualinherited

Checks if any operation is a branching one.

Checks if any operation is a branching one, meaning that it can lead to splitting paths (relevant for the path integral simulator).

Returns
True if it branches a path, false otherwise.

Reimplemented from Circuits::IOperation< Types::time_type >.

Definition at line 2435 of file Circuit.h.

◆ IsClifford()

bool Circuits::Circuit< Types::time_type >::IsClifford ( ) const
inlineoverridevirtualinherited

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< Types::time_type >.

Definition at line 1975 of file Circuit.h.

◆ IsConditional()

virtual bool Circuits::IOperation< Types::time_type >::IsConditional ( ) const
inlinevirtualinherited

Find if the operation is a conditional operation.

Returns true if the operation is conditional, false otherwise.

Returns
True if the operation is conditional, false otherwise.

Definition at line 458 of file Operations.h.

◆ IsForest()

bool Circuits::Circuit< Types::time_type >::IsForest ( ) const
inlineinherited

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 1922 of file Circuit.h.

◆ LayersToCircuit()

std::shared_ptr< Circuits::Circuit< Types::time_type > > Circuits::Circuit< Types::time_type >::LayersToCircuit ( const std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > & layers)
inlinestaticinherited

Converts the layers back to a circuit.

The layers are converted back to a circuit by joining the individual circuits into a single one.

Parameters
layersThe layers to convert.
Returns
The circuit.
See also
Circuits::Circuit

Definition at line 2417 of file Circuit.h.

◆ MoveMeasurementsAndResets()

void Circuits::Circuit< Types::time_type >::MoveMeasurementsAndResets ( )
inlineinherited

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 1278 of file Circuit.h.

◆ NeedsEntanglementForDistribution()

bool Circuits::Circuit< Types::time_type >::NeedsEntanglementForDistribution ( ) const
inlineoverridevirtualinherited

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< Types::time_type >.

Definition at line 651 of file Circuit.h.

◆ operator!=()

template<typename Time = Types::time_type>
bool Circuits::ComparableCircuit< Time >::operator!= ( const BaseClass & rhs) const
inline

Comparison operator.

Compares two circuits for inequality.

Parameters
rhsThe circuit to compare to.

Definition at line 2890 of file Circuit.h.

◆ operator=()

template<typename Time = Types::time_type>
ComparableCircuit & Circuits::ComparableCircuit< Time >::operator= ( const BaseClass & circ)
inline

Assignment operator.

Assigns the operations from the given circuit to this circuit.

Parameters
circThe circuit from where to add the operations to this circuit.
Returns
A reference to this circuit.

Definition at line 2753 of file Circuit.h.

References ComparableCircuit(), Circuits::Circuit< Time >::GetOperations(), and Circuits::Circuit< Time >::SetOperations().

◆ operator==()

◆ operator[]()

auto & Circuits::Circuit< Types::time_type >::operator[] ( size_t pos)
inlineinherited

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 2531 of file Circuit.h.

◆ Optimize()

void Circuits::Circuit< Types::time_type >::Optimize ( bool optimizeRotationGates = true)
inlineinherited

Circuit optimization.

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

Definition at line 756 of file Circuit.h.

◆ rbegin()

reverse_iterator Circuits::Circuit< Types::time_type >::rbegin ( )
inlinenoexceptinherited

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 2480 of file Circuit.h.

◆ Remap() [1/2]

OperationPtr Circuits::Circuit< Types::time_type >::Remap ( const BitMapping & qubitsMap,
const BitMapping & bitsMap = {} ) const
inlineoverrideinherited

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.

Definition at line 221 of file Circuit.h.

◆ Remap() [2/2]

virtual std::shared_ptr< IOperation< Types::time_type > > Circuits::IOperation< Types::time_type >::Remap ( const std::unordered_map< Types::qubit_t, Types::qubit_t > & qubitsMap,
const std::unordered_map< Types::qubit_t, Types::qubit_t > & bitsMap = {} ) const
pure virtualinherited

Get a shared pointer to a remapped operation.

Returns a shared pointer to a copy of the operation 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 object.

◆ RemapResultsBack()

ExecuteResults Circuits::Circuit< Types::time_type >::RemapResultsBack ( const ExecuteResults & results,
const BitMapping & bitsMap = {},
bool ignoreNotMapped = false,
size_t sz = 0 )
inlinestaticinherited

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 294 of file Circuit.h.

◆ RemapToContinuous()

std::shared_ptr< Circuit< Types::time_type > > Circuits::Circuit< Types::time_type >::RemapToContinuous ( BitMapping & newQubitsMap,
BitMapping & reverseBitsMap,
size_t & nrQubits,
size_t & nrCbits ) const
inlineinherited

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 242 of file Circuit.h.

◆ RemoveExecutedOperations()

std::shared_ptr< Circuits::Circuit< Types::time_type > > Circuits::Circuit< Types::time_type >::RemoveExecutedOperations ( std::vector< bool > & executedOps) const
inlineinherited

Returns a new circuit with the operations that were not yet executed.

The parameter is modified to reflect the newly created circuit, which contains only the operations that were not yet executed.

Parameters
executedOpsA vector of bools indicating which operations were executed.
Returns
A new circuit with the operations that were not yet executed.

Definition at line 1808 of file Circuit.h.

◆ rend()

reverse_iterator Circuits::Circuit< Types::time_type >::rend ( )
inlinenoexceptinherited

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 2488 of file Circuit.h.

◆ ReplaceOperation()

void Circuits::Circuit< Types::time_type >::ReplaceOperation ( size_t index,
const OperationPtr & op )
inlineinherited

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 131 of file Circuit.h.

◆ resize()

void Circuits::Circuit< Types::time_type >::resize ( size_t size)
inlineinherited

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 2549 of file Circuit.h.

◆ SetApproximateParamsCheck()

template<typename Time = Types::time_type>
void Circuits::ComparableCircuit< Time >::SetApproximateParamsCheck ( bool check)
inline

Sets whether to check approximate equality of gate parameters.

Sets whether to check approximate equality of gate parameters.

Parameters
checkWhether to check approximate equality of gate parameters.

Definition at line 2898 of file Circuit.h.

Referenced by operator==().

◆ SetDelay()

void Circuits::IOperation< Types::time_type >::SetDelay ( Types::time_type d)
inlineinherited

Set the delay of the operation.

Sets the delay due of the execution time of the operation.

Parameters
dThe delay of the operation.

Definition at line 505 of file Operations.h.

◆ SetOperations()

void Circuits::Circuit< Types::time_type >::SetOperations ( const OperationsVector & ops)
inlineinherited

Set the operations in the circuit.

Sets the operations in the circuit.

Parameters
opsThe operations to set.
See also
IOperation

Definition at line 143 of file Circuit.h.

◆ SetParamsEpsilon()

template<typename Time = Types::time_type>
void Circuits::ComparableCircuit< Time >::SetParamsEpsilon ( double eps)
inline

Sets the epsilon used for checking approximate equality of gate parameters.

Sets the epsilon used for checking approximate equality of gate parameters.

Parameters
epsThe epsilon used for checking approximate equality of gate parameters.

Definition at line 2916 of file Circuit.h.

◆ size()

auto Circuits::Circuit< Types::time_type >::size ( ) const
inlineinherited

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 2514 of file Circuit.h.

Referenced by Circuits::ComparableCircuit< Time >::operator==().

◆ SplitCircuit()

std::vector< std::shared_ptr< Circuit< Types::time_type > > > Circuits::Circuit< Types::time_type >::SplitCircuit ( ) const
inlineinherited

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 2035 of file Circuit.h.

◆ ToLayers()

std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > Circuits::Circuit< Types::time_type >::ToLayers ( ) const
inlineinherited

Converts the circuit to layers.

The circuit is split in layers, each layer being a separate circuit. Operations are cloned.

Returns
The layers.

Definition at line 2133 of file Circuit.h.

◆ ToLayersNoClone()

std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > Circuits::Circuit< Types::time_type >::ToLayersNoClone ( ) const
inlineinherited

Converts the circuit to layers.

The circuit is split in layers, each layer being a separate circuit. Operations are not cloned, the shared pointers point to the same operations as the ones from the circuit.

Returns
The layers.

Definition at line 2200 of file Circuit.h.

◆ ToMultipleQubitsLayers()

std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > Circuits::Circuit< Types::time_type >::ToMultipleQubitsLayers ( ) const
inlineinherited

Converts the circuit to layers oriented on multiple qubit gates.

The circuit is split in layers, each layer being a separate circuit. Operations are cloned. It's not as ToLayers above, the order of the operations in a layer matters. If the one qubit gates would be contracted into the ones on more than one qubit, then it would be the situation of normal layers.

Returns
The layers.

Definition at line 2270 of file Circuit.h.

◆ ToMultipleQubitsLayersNoClone()

std::vector< std::shared_ptr< Circuits::Circuit< Types::time_type > > > Circuits::Circuit< Types::time_type >::ToMultipleQubitsLayersNoClone ( ) const
inlineinherited

Converts the circuit to layers oriented on multiple qubit gates.

The circuit is split in layers, each layer being a separate circuit. Operations are not cloned. It's not as ToLayers above, the order of the operations in a layer matters. If the one qubit gates would be contracted into the ones on more than one qubit, then it would be the situation of normal layers.

Returns
The layers.

Definition at line 2341 of file Circuit.h.


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