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

Random operation. More...

#include <RandomOp.h>

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

Public Member Functions

 Random (const std::vector< size_t > &ind={}, size_t seed=0, Time delay=0)
 Construct a new Random object.
 
std::vector< size_t > AffectedBits () const override
 Get the affected bits.
 
virtual Types::qubits_vector AffectedQubits () const
 Returns the affected qubits.
 
virtual bool CanAffectQuantumState () const
 Find if the operation can affect the quantum state.
 
std::shared_ptr< IOperation< Time > > Clone () const override
 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.
 
const std::vector< size_t > & GetBitsIndices () const
 Get the indices of the classical bits affected by this operation.
 
Time GetDelay () const
 Get the delay of the operation.
 
std::shared_ptr< IOperation< Time > > getptr ()
 Get a shared pointer to this object.
 
OperationType GetType () const override
 Get the type of the operation.
 
bool IsClifford () const override
 Checks if the operation is a Clifford one.
 
virtual bool IsConditional () const
 Find if the operation is a conditional 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 Seed (size_t sd)
 Seeds the random generator.
 
void SetBitsIndices (const std::vector< size_t > &ind)
 Set the indices of the classical bits affected by this operation.
 
void SetDelay (Time d)
 Set the delay of the operation.
 

Protected Member Functions

void SetBit (size_t index, Types::qubit_t bit)
 Set the classical bit to index.
 

Detailed Description

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

Random operation.

Implements an operation that can generate random classical bits that are stored in the classical state/register.

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

Definition at line 34 of file RandomOp.h.

Constructor & Destructor Documentation

◆ Random()

template<typename Time = Types::time_type>
Circuits::Random< Time >::Random ( const std::vector< size_t > &  ind = {},
size_t  seed = 0,
Time  delay = 0 
)
inline

Construct a new Random object.

Constructs a new Random object.

Parameters
indThe indices of the classical bits to be set by the generator.
seedThe seed used for the random number generator.
delayThe excution time.

Definition at line 44 of file RandomOp.h.

Member Function Documentation

◆ AffectedBits()

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

Get the affected bits.

Returns the indices of the classical bits affected by this operation.

Returns
The indices of the bits affected by this operation.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 114 of file RandomOp.h.

References Circuits::Random< Time >::GetBitsIndices().

◆ AffectedQubits()

◆ CanAffectQuantumState()

template<typename Time = Types::time_type>
virtual bool Circuits::IOperation< Time >::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 >, and Circuits::Circuit< Types::time_type >.

Definition at line 429 of file Operations.h.

References Circuits::IOperation< Time >::GetType(), Circuits::kComposite, Circuits::kConditionalGate, Circuits::kConditionalMeasurement, Circuits::kGate, Circuits::kMeasurement, and Circuits::kReset.

◆ Clone()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::Random< 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 103 of file RandomOp.h.

References Circuits::Random< Time >::GetBitsIndices(), and Circuits::IOperation< Time >::GetDelay().

◆ Execute()

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

Execute the operation.

Executes the operation.

Parameters
simThe simulator to be used for the execution.
stateThe state of the simulator.

Implements Circuits::IOperation< Time >.

Definition at line 56 of file RandomOp.h.

References Circuits::OperationState::SetBit().

◆ GetBitsIndices()

template<typename Time = Types::time_type>
const std::vector< size_t > & Circuits::Random< Time >::GetBitsIndices ( ) const
inline

Get the indices of the classical bits affected by this operation.

Returns the indices of the classical bits affected by this operation.

Returns
The indices of the classical bits affected by this operation.

Definition at line 75 of file RandomOp.h.

Referenced by Circuits::Random< Time >::AffectedBits(), and Circuits::Random< Time >::Clone().

◆ GetDelay()

template<typename Time = Types::time_type>
Time Circuits::IOperation< Time >::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::ConditionalGate< Time >::Clone(), Circuits::MeasurementOperation< Time >::Clone(), Circuits::NoOperation< Time >::Clone(), Circuits::PhaseGate< Time >::Clone(), Circuits::XGate< Time >::Clone(), Circuits::YGate< Time >::Clone(), Circuits::ZGate< Time >::Clone(), Circuits::HadamardGate< Time >::Clone(), Circuits::SGate< Time >::Clone(), Circuits::SdgGate< Time >::Clone(), Circuits::TGate< Time >::Clone(), Circuits::TdgGate< Time >::Clone(), Circuits::SxGate< Time >::Clone(), Circuits::SxDagGate< Time >::Clone(), Circuits::KGate< Time >::Clone(), Circuits::RxGate< Time >::Clone(), Circuits::RyGate< Time >::Clone(), Circuits::RzGate< Time >::Clone(), Circuits::UGate< Time >::Clone(), Circuits::SwapGate< Time >::Clone(), Circuits::CXGate< Time >::Clone(), Circuits::CYGate< Time >::Clone(), Circuits::CZGate< Time >::Clone(), Circuits::CPGate< Time >::Clone(), Circuits::CRxGate< Time >::Clone(), Circuits::CRyGate< Time >::Clone(), Circuits::CRzGate< Time >::Clone(), Circuits::CHGate< Time >::Clone(), Circuits::CSxGate< Time >::Clone(), Circuits::CSxDagGate< Time >::Clone(), Circuits::CUGate< Time >::Clone(), Circuits::CCXGate< Time >::Clone(), Circuits::CSwapGate< Time >::Clone(), Circuits::Random< Time >::Clone(), Circuits::Reset< Time >::Clone(), and Circuits::ComparableCircuit< Time >::operator==().

◆ getptr()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::IOperation< Time >::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.

◆ GetType()

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

Get the type of the operation.

Returns the type of the operation, in this case, random.

Returns
The type of the operation.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 67 of file RandomOp.h.

References Circuits::kRandomGen.

◆ IsClifford()

template<typename Time = Types::time_type>
bool Circuits::Random< 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< Time >.

Definition at line 150 of file RandomOp.h.

◆ IsConditional()

template<typename Time = Types::time_type>
virtual bool Circuits::IOperation< Time >::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.

References Circuits::IOperation< Time >::GetType(), Circuits::kConditionalGate, Circuits::kConditionalMeasurement, and Circuits::kConditionalRandomGen.

◆ NeedsEntanglementForDistribution()

template<typename Time = Types::time_type>
virtual bool Circuits::IOperation< Time >::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 >, and Circuits::Circuit< Types::time_type >.

Definition at line 446 of file Operations.h.

References Circuits::IOperation< Time >::AffectedQubits(), Circuits::IOperation< Time >::GetType(), Circuits::kConditionalGate, and Circuits::kGate.

◆ Remap()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::Random< 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< Time >.

Definition at line 126 of file RandomOp.h.

◆ Seed()

template<typename Time = Types::time_type>
void Circuits::Random< Time >::Seed ( size_t  sd)
inline

Seeds the random generator.

Seeds the random generator using the specified seed.

Parameters
sdThe seed to be used.

Definition at line 91 of file RandomOp.h.

◆ SetBit()

template<typename Time = Types::time_type>
void Circuits::Random< Time >::SetBit ( size_t  index,
Types::qubit_t  bit 
)
inlineprotected

Set the classical bit to index.

This method sets the classical bit index at the specified index.

Parameters
indexThe index of the classical bit index.
bitThe classical bit index to set.

Definition at line 160 of file RandomOp.h.

◆ SetBitsIndices()

template<typename Time = Types::time_type>
void Circuits::Random< Time >::SetBitsIndices ( const std::vector< size_t > &  ind)
inline

Set the indices of the classical bits affected by this operation.

Sets the indices of the classical bits affected by this operation.

Parameters
indThe indices of the classical bits affected by this operation.

Definition at line 83 of file RandomOp.h.

◆ SetDelay()

template<typename Time = Types::time_type>
void Circuits::IOperation< Time >::SetDelay ( Time  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.


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