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

An operation conditioned on classical values. More...

#include <Conditional.h>

Inheritance diagram for Circuits::IConditionalOperation< Time >:
Circuits::IOperation< Types::time_type >

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.
void Execute (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
 Execute the operation.
void SetOperation (const std::shared_ptr< IOperation< Time > > &op)
 Set the operation for the conditional operation.
std::shared_ptr< IOperation< Time > > GetOperation () const
 Get the operation for the conditional operation.
void SetCondition (const std::shared_ptr< ICondition > &cond)
 Set the condition for the conditional operation.
std::shared_ptr< IConditionGetCondition () const
 Get the condition for the conditional operation.
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.
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.
bool IsClifford () const override
 Checks if the operation is a Clifford one.
Public Member Functions inherited from Circuits::IOperation< Types::time_type >
 IOperation (Types::time_type delay=0)
 Construct a new IOperation object.
virtual ~IOperation ()=default
 Destroy the IOperation object.
virtual OperationType GetType () const
 Get the type of the operation.
virtual std::shared_ptr< IOperation< Types::time_type > > Clone () const=0
 Get a shared pointer to a clone of this object.
virtual bool CanAffectQuantumState () const
 Find if the operation can affect the quantum state.
virtual bool NeedsEntanglementForDistribution () const
 Find if the operation needs entanglement for distribution.
virtual bool IsConditional () const
 Find if the operation is a conditional operation.
std::shared_ptr< IOperation< Types::time_type > > getptr ()
 Get a shared pointer to this object.
Types::time_type GetDelay () const
 Get the delay of the operation.
void SetDelay (Types::time_type d)
 Set the delay of the 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 218 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 231 of file Conditional.h.

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 315 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 328 of file Conditional.h.

◆ 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 248 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 307 of file Conditional.h.

◆ 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 287 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 367 of file Conditional.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 346 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 296 of file Conditional.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 263 of file Conditional.h.


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