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

An operation conditioned on classical values. More...

#include <Conditional.h>

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

Public Member Functions

 IConditionalOperation (const std::shared_ptr< IOperation< Time > > &operation, const std::shared_ptr< ICondition > &condition, Time delay=0)
 Construct a new IConditionalOperation object.
std::vector< size_t > AffectedBits () const override
 Get bits that are involved in the condition.
Types::qubits_vector AffectedQubits () const override
 Get the qubits affected by the operation.
virtual bool CanAffectQuantumState () const
 Find if the operation can affect the quantum state.
virtual std::shared_ptr< IOperation< Types::time_type > > Clone () const=0
 Get a shared pointer to a clone of this object.
void Execute (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
 Execute the operation.
std::shared_ptr< ICondition > GetCondition () const
 Get the condition for the conditional operation.
Types::time_type GetDelay () const
 Get the delay of the operation.
std::shared_ptr< IOperation< Time > > GetOperation () const
 Get the operation for the conditional operation.
std::shared_ptr< IOperation< Types::time_type > > getptr ()
 Get a shared pointer to this object.
virtual OperationType GetType () const
 Get the type of the operation.
bool IsBranching () const override
 Checks if the operation is a branching one.
bool IsClifford () const override
 Checks if the operation is a Clifford one.
virtual bool IsConditional () const
 Find if the operation is a conditional operation.
bool IsNoiseless () const
 Whether noise models skip this operation.
virtual bool NeedsEntanglementForDistribution () const
 Find if the operation needs entanglement for distribution.
std::shared_ptr< IOperation< Time > > Remap (const std::unordered_map< Types::qubit_t, Types::qubit_t > &qubitsMap, const std::unordered_map< Types::qubit_t, Types::qubit_t > &bitsMap={}) const override
 Get a shared pointer to a remapped operation.
void SetCondition (const std::shared_ptr< ICondition > &cond)
 Set the condition for the conditional operation.
virtual void SetDelay (Types::time_type d)
 Set the delay of the operation.
void SetNoiseless (bool value=true)
 Mark the operation as exempt from injected gate noise.
void SetOperation (const std::shared_ptr< IOperation< Time > > &op)
 Set the operation for the conditional operation.

Detailed Description

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

An operation conditioned on classical values.

An operation that is executed only if a condition is met.

Template Parameters
TimeThe type of the time parameter that is used for operations timing.
See also
IConditionalOperation
IOperation

Definition at line 236 of file Conditional.h.

Constructor & Destructor Documentation

◆ IConditionalOperation()

template<typename Time = Types::time_type>
Circuits::IConditionalOperation< Time >::IConditionalOperation ( const std::shared_ptr< IOperation< Time > > & operation,
const std::shared_ptr< ICondition > & condition,
Time delay = 0 )
inline

Construct a new IConditionalOperation object.

Construct a new IConditionalOperation object with the given operation, condition and delay.

Parameters
operationThe operation to execute if the condition is met.
conditionThe condition to check.
delayThe delay of the operation.
See also
IOperation
ICondition

Definition at line 250 of file Conditional.h.

References Circuits::IOperation< Types::time_type >::IOperation().

Member Function Documentation

◆ AffectedBits()

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

Get bits that are involved in the condition.

Get the classical bits that are involved in the condition.

Returns
The bits involved.

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

Definition at line 341 of file Conditional.h.

◆ AffectedQubits()

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

Get the qubits affected by the operation.

Get the qubits affected by the operation.

Returns
The qubits affected by the operation.

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

Definition at line 355 of file Conditional.h.

◆ CanAffectQuantumState()

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

Find if the operation can affect the quantum state.

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

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

Reimplemented in Circuits::Circuit< Time >, Circuits::Circuit< Types::time_type >, Circuits::Delay< Time >, and Circuits::QuantumChannelOperation< Time >.

Definition at line 473 of file Operations.h.

◆ Clone()

virtual std::shared_ptr< IOperation< Types::time_type > > Circuits::IOperation< Types::time_type >::Clone ( ) const
pure virtualinherited

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.

Implemented in Circuits::Circuit< Time >, Circuits::Circuit< Types::time_type >, Circuits::CloneableGate< CCXGate, ThreeQubitsGate, Types::time_type >, Circuits::CloneableGate< CHGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< CPGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< CRxGate, ControlledRotationGate, Types::time_type >, Circuits::CloneableGate< CRyGate, ControlledRotationGate, Types::time_type >, Circuits::CloneableGate< CRzGate, ControlledRotationGate, Types::time_type >, Circuits::CloneableGate< CSwapGate, ThreeQubitsGate, Types::time_type >, Circuits::CloneableGate< CSxDagGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< CSxGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< CUGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< CXGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< CYGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< CZGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< HadamardGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< KGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< PhaseGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< RxGate, RotationGate, Types::time_type >, Circuits::CloneableGate< RyGate, RotationGate, Types::time_type >, Circuits::CloneableGate< RzGate, RotationGate, Types::time_type >, Circuits::CloneableGate< SdgGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< SGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< SwapGate, TwoQubitsGate, Types::time_type >, Circuits::CloneableGate< SxDagGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< SxGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< TdgGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< TGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< UGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< XGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< YGate, SingleQubitGate, Types::time_type >, Circuits::CloneableGate< ZGate, SingleQubitGate, Types::time_type >, Circuits::ConditionalGate< Time >, Circuits::ConditionalMeasurement< Time >, Circuits::ConditionalRandomGen< Time >, Circuits::Delay< Time >, Circuits::MeasurementOperation< Time >, Circuits::NoOperation< Time >, Circuits::QuantumChannelOperation< Time >, Circuits::Random< Time >, and Circuits::Reset< Time >.

◆ Execute()

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

Execute the operation.

Execute the operation if the condition is met with the specified classical state, in the specified simulator.

Parameters
simThe simulator to execute the operation on.
stateThe classical state to execute the operation on (check condition against it and if it has a classical result, put the results there).
See also
ISimulator
OperationState

Implements Circuits::IOperation< Types::time_type >.

Definition at line 267 of file Conditional.h.

◆ GetCondition()

template<typename Time = Types::time_type>
std::shared_ptr< ICondition > Circuits::IConditionalOperation< Time >::GetCondition ( ) const
inline

Get the condition for the conditional operation.

Get the condition to check.

Returns
The condition to check.
See also
ICondition

Definition at line 330 of file Conditional.h.

Referenced by Circuits::ConditionalGate< Time >::Clone(), Circuits::ConditionalMeasurement< Time >::Clone(), and Circuits::ConditionalRandomGen< Time >::Clone().

◆ 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 546 of file Operations.h.

Referenced by Circuits::NoOperation< Time >::Clone().

◆ GetOperation()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::IConditionalOperation< Time >::GetOperation ( ) const
inline

Get the operation for the conditional operation.

Get the operation to execute if the condition is met.

Returns
The operation to execute if the condition is met.
See also
IOperation

Definition at line 306 of file Conditional.h.

Referenced by Circuits::ConditionalGate< Time >::Clone(), Circuits::ConditionalMeasurement< Time >::Clone(), Circuits::ConditionalRandomGen< Time >::Clone(), and Circuits::Circuit< Time >::HasUnseededRandomOperations().

◆ 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 535 of file Operations.h.

◆ GetType()

◆ IsBranching()

template<typename Time = Types::time_type>
bool Circuits::IConditionalOperation< Time >::IsBranching ( ) const
inlineoverridevirtual

Checks if the operation is a branching one.

Checks if the 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 409 of file Conditional.h.

◆ IsClifford()

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

Checks if the operation is a Clifford one.

Checks if the operation is a Clifford one, allowing to be simulated in a stabilizers simulator.

Returns
True if it can be applied in a stabilizers simulator, false otherwise.

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

Definition at line 393 of file Conditional.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 500 of file Operations.h.

◆ IsNoiseless()

bool Circuits::IOperation< Types::time_type >::IsNoiseless ( ) const
inlineinherited

Whether noise models skip this operation.

Returns
True if no gate noise is injected after this operation.

Definition at line 580 of file Operations.h.

◆ NeedsEntanglementForDistribution()

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

Find if the operation needs entanglement for distribution.

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

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

Reimplemented in Circuits::Circuit< Time >, Circuits::Circuit< Types::time_type >, and Circuits::QuantumChannelOperation< Time >.

Definition at line 488 of file Operations.h.

◆ Remap()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::IConditionalOperation< Time >::Remap ( const std::unordered_map< Types::qubit_t, Types::qubit_t > & qubitsMap,
const std::unordered_map< Types::qubit_t, Types::qubit_t > & bitsMap = {} ) const
inlineoverridevirtual

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.

Implements Circuits::IOperation< Types::time_type >.

Definition at line 373 of file Conditional.h.

◆ SetCondition()

template<typename Time = Types::time_type>
void Circuits::IConditionalOperation< Time >::SetCondition ( const std::shared_ptr< ICondition > & cond)
inline

Set the condition for the conditional operation.

Assigns the condition to check.

Parameters
condThe assigned condition.
See also
ICondition

Definition at line 318 of file Conditional.h.

◆ SetDelay()

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

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 557 of file Operations.h.

◆ SetNoiseless()

void Circuits::IOperation< Types::time_type >::SetNoiseless ( bool value = true)
inlineinherited

Mark the operation as exempt from injected gate noise.

Noise models add no noise after a noiseless operation. This is for basis changes that belong to a non-Z measurement or reset rather than being gates in their own right. Gate copies (Clone, Remap) keep the mark.

Parameters
valueTrue to exempt the operation from gate noise.

Definition at line 570 of file Operations.h.

◆ SetOperation()

template<typename Time = Types::time_type>
void Circuits::IConditionalOperation< Time >::SetOperation ( const std::shared_ptr< IOperation< Time > > & op)
inline

Set the operation for the conditional operation.

Assigns the operation to execute if the condition is met.

Parameters
opThe assigned operation.

Definition at line 284 of file Conditional.h.

References Circuits::IOperation< Types::time_type >::IOperation(), Circuits::kConditionalGate, Circuits::kConditionalMeasurement, Circuits::kConditionalRandomGen, Circuits::kGate, Circuits::kMeasurement, and Circuits::kRandomGen.


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