Maestro 0.3.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Circuits::OperationState Class Reference

The state class that stores the classical state of a quantum circuit execution. More...

#include <Operations.h>

Collaboration diagram for Circuits::OperationState:

Public Member Functions

 OperationState (const OperationState &other)
 Construct a new Operation State object.
 OperationState (const std::vector< bool > &b)
 Construct a new Operation State object.
 OperationState (OperationState &&other) noexcept
 Construct a new Operation State object.
 OperationState (size_t numBits=0)
 Construct a new Operation State object.
 OperationState (std::vector< bool > &&b)
 Construct a new Operation State object.
void AllocateBits (size_t numBits)
 Allocate more bits.
void Clear ()
 Clear the classical state.
const std::vector< bool > & GetAllBits () const
 Get the classical bits.
std::vector< bool > GetAllBitsCopy () const
 Get the classical bits.
bool GetBit (size_t index) const
 Get the classical bit at the specified index.
std::vector< bool > GetBits (const std::vector< size_t > &indices) const
 Get the classical bits at the specified indices.
size_t GetNumBits () const
 Get the number of classical bits.
OperationState & operator= (const OperationState &other)
 Assign the bits.
OperationState & operator= (const std::vector< bool > &b)
 Assign the bits.
OperationState & operator= (OperationState &&other) noexcept
 Assign the bits.
OperationState & operator= (std::vector< bool > &&b)
 Assign the bits.
void Remap (const std::unordered_map< Types::qubit_t, Types::qubit_t > &mapping, bool ignoreNotMapped=false, size_t newSize=0)
 Convert the state using the provided mapping.
void RemapWithVector (const std::vector< Types::qubit_t > &mapping, bool ignoreNotMapped=false, size_t newSize=0)
 Convert the state using the provided mapping.
void Reset (bool value=false)
 Set the classical bits with the specified value.
void SetBit (size_t index, bool value=true)
 Set the classical bit at the specified index.
void SetResults (const std::vector< size_t > &indices, size_t results)
 Set the classical bits at the specified indices.
void SetResultsInOrder (const std::vector< bool > &results)
 Set the classical bits.
void Swap (OperationState &results)
 Set results.

Detailed Description

The state class that stores the classical state of a quantum circuit execution.

Contains the classical state (such as measurement results and classical values for conditions) of a quantum circuit execution.

Definition at line 67 of file Operations.h.

Constructor & Destructor Documentation

◆ OperationState() [1/5]

Circuits::OperationState::OperationState ( size_t numBits = 0)
inline

Construct a new Operation State object.

Pass the number of bits to allocate. If not specified, the default is 0, they can be allocated later.

Parameters
numBitsThe number of bits to allocate.

Definition at line 77 of file Operations.h.

References AllocateBits().

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

◆ OperationState() [2/5]

Circuits::OperationState::OperationState ( const OperationState & other)
inline

Construct a new Operation State object.

Copy constructor.

Parameters
otherThe OperationState object to copy.

Definition at line 89 of file Operations.h.

References OperationState().

◆ OperationState() [3/5]

Circuits::OperationState::OperationState ( OperationState && other)
inlinenoexcept

Construct a new Operation State object.

Move constructor.

Parameters
otherThe OperationState object to move.

Definition at line 100 of file Operations.h.

References OperationState().

◆ OperationState() [4/5]

Circuits::OperationState::OperationState ( const std::vector< bool > & b)
inline

Construct a new Operation State object.

Construct a new Operation State object with the specified bits.

Parameters
bitsThe bits to set.

Definition at line 110 of file Operations.h.

◆ OperationState() [5/5]

Circuits::OperationState::OperationState ( std::vector< bool > && b)
inline

Construct a new Operation State object.

Construct a new Operation State object with the specified bits.

Parameters
bitsThe bits to set.

Definition at line 120 of file Operations.h.

Member Function Documentation

◆ AllocateBits()

void Circuits::OperationState::AllocateBits ( size_t numBits)
inline

Allocate more bits.

Allocate more bits, the number of classical bits is increased by the number of bits specified.

Parameters
numBitsThe number of bits to suplementary allocate.

Definition at line 179 of file Operations.h.

Referenced by OperationState(), Network::ExecuteJob< Time >::DoWork(), Network::ExecuteJob< Time >::DoWorkNoLock(), and Estimators::SimulatorsEstimatorInterface< Time >::ExecuteUpToMeasurements().

◆ Clear()

void Circuits::OperationState::Clear ( )
inline

Clear the classical state.

Clear the classical state, the number of allocated bits is reset to 0.

Definition at line 189 of file Operations.h.

Referenced by Network::SimpleDisconnectedNetwork< Time, Controller >::RepeatedExecute(), and Network::SimpleDisconnectedNetwork< Time, Controller >::RepeatedExecuteOnHost().

◆ GetAllBits()

const std::vector< bool > & Circuits::OperationState::GetAllBits ( ) const
inline

◆ GetAllBitsCopy()

std::vector< bool > Circuits::OperationState::GetAllBitsCopy ( ) const
inline

Get the classical bits.

Get the values of the classical bits.

Returns
A copy of the classical bit values.

Definition at line 255 of file Operations.h.

◆ GetBit()

bool Circuits::OperationState::GetBit ( size_t index) const
inline

Get the classical bit at the specified index.

Get the value of the classical bit at the specified index.

Parameters
indexThe index of the bit to get.
Returns
The classical bit value at the specified index.

Definition at line 212 of file Operations.h.

◆ GetBits()

std::vector< bool > Circuits::OperationState::GetBits ( const std::vector< size_t > & indices) const
inline

Get the classical bits at the specified indices.

Get the values of the classical bits at the specified indices.

Parameters
indicesThe indices of the bits to get.
Returns
The classical bit values at the specified indices.

Definition at line 227 of file Operations.h.

Referenced by Circuits::EqualCondition::IsConditionMet().

◆ GetNumBits()

size_t Circuits::OperationState::GetNumBits ( ) const
inline

Get the number of classical bits.

Get the number of allocated classical bits.

Returns
The number of classical bits.

Definition at line 200 of file Operations.h.

◆ operator=() [1/4]

OperationState & Circuits::OperationState::operator= ( const OperationState & other)
inline

Assign the bits.

Assign the bits.

Parameters
otherThe OperationState object to copy.

Definition at line 130 of file Operations.h.

References OperationState().

◆ operator=() [2/4]

OperationState & Circuits::OperationState::operator= ( const std::vector< bool > & b)
inline

Assign the bits.

Assign the bits.

Parameters
bitsThe bits to set.

Definition at line 154 of file Operations.h.

References OperationState().

◆ operator=() [3/4]

OperationState & Circuits::OperationState::operator= ( OperationState && other)
inlinenoexcept

Assign the bits.

Assign the bits.

Parameters
otherThe OperationState object to move.

Definition at line 142 of file Operations.h.

References OperationState().

◆ operator=() [4/4]

OperationState & Circuits::OperationState::operator= ( std::vector< bool > && b)
inline

Assign the bits.

Assign the bits.

Parameters
bitsThe bits to set.

Definition at line 166 of file Operations.h.

References OperationState().

◆ Remap()

void Circuits::OperationState::Remap ( const std::unordered_map< Types::qubit_t, Types::qubit_t > & mapping,
bool ignoreNotMapped = false,
size_t newSize = 0 )
inline

Convert the state using the provided mapping.

Set the values of the classical bits.

Parameters
mappingThe mapping of the bits.
ignoreNotMappedIf true, the bits that are not in the mapping are ignored. The size of the state will be the size of the mapping.
newSizeThe new size of the state. If zero, the size of the state is used. Ignored if ignoreNotMapped is true.
offsetThe offset to add to the remapping.

Definition at line 345 of file Operations.h.

Referenced by Network::SimpleDisconnectedNetwork< Time, Controller >::ConvertBackResults(), and Network::SimpleDisconnectedNetwork< Time, Controller >::ConvertBackState().

◆ RemapWithVector()

void Circuits::OperationState::RemapWithVector ( const std::vector< Types::qubit_t > & mapping,
bool ignoreNotMapped = false,
size_t newSize = 0 )
inline

Convert the state using the provided mapping.

Set the values of the classical bits.

Parameters
mappingThe mapping of the bits.
ignoreNotMappedIf true, the bits that are not in the mapping are ignored. The size of the state will be the size of the mapping.
newSizeThe new size of the state. If zero, the size of the state is used. Ignored if ignoreNotMapped is true.
offsetThe offset to add to the remapping.

Definition at line 373 of file Operations.h.

◆ Reset()

void Circuits::OperationState::Reset ( bool value = false)
inline

Set the classical bits with the specified value.

Set the values of the classical bits with the specified value. If not specified, the default value is false.

Parameters
valueThe value assigned to the classical bits.

Definition at line 282 of file Operations.h.

Referenced by Network::ExecuteJob< Time >::DoWork(), Network::ExecuteJob< Time >::DoWorkNoLock(), Circuits::Circuit< Time >::ExecuteBD(), and Circuits::Circuit< Time >::ExecuteMeasurements().

◆ SetBit()

void Circuits::OperationState::SetBit ( size_t index,
bool value = true )
inline

Set the classical bit at the specified index.

Set the value of the classical bit at the specified index.

Parameters
indexThe index of the bit to set.
valueThe value to set the bit to.

Definition at line 267 of file Operations.h.

Referenced by Circuits::Random< Time >::Execute(), and Circuits::MeasurementOperation< Time >::SetStateFromSample().

◆ SetResults()

void Circuits::OperationState::SetResults ( const std::vector< size_t > & indices,
size_t results )
inline

Set the classical bits at the specified indices.

Set the values of the classical bits at the specified indices to the values specified in results. Each bit in results specifies a value.

Parameters
indicesThe indices of the bits to set.
resultsThe value that contains the values for the bits.

Definition at line 310 of file Operations.h.

◆ SetResultsInOrder()

◆ Swap()

void Circuits::OperationState::Swap ( OperationState & results)
inline

Set results.

Set the values of the classical bits. Destroys the source, it's implemented for increasing performance.

Parameters
resultsThe new values.

Definition at line 328 of file Operations.h.

References OperationState().


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