Maestro 0.1.0
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>

Public Member Functions

 OperationState (size_t numBits=0)
 Construct a new Operation State object.
 OperationState (const OperationState &other)
 Construct a new Operation State object.
 OperationState (OperationState &&other) noexcept
 Construct a new Operation State object.
 OperationState (const std::vector< bool > &b)
 Construct a new Operation State object.
 OperationState (std::vector< bool > &&b)
 Construct a new Operation State object.
OperationStateoperator= (const OperationState &other)
 Assign the bits.
OperationStateoperator= (OperationState &&other) noexcept
 Assign the bits.
OperationStateoperator= (const std::vector< bool > &b)
 Assign the bits.
OperationStateoperator= (std::vector< bool > &&b)
 Assign the bits.
void AllocateBits (size_t numBits)
 Allocate more bits.
void Clear ()
 Clear the classical state.
size_t GetNumBits () const
 Get the number of 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.
const std::vector< bool > & GetAllBits () const
 Get the classical bits.
std::vector< bool > GetAllBitsCopy () const
 Get the classical bits.
void SetBit (size_t index, bool value=true)
 Set the classical bit at the specified index.
void Reset (bool value=false)
 Set the classical bits with the specified value.
void SetResultsInOrder (const std::vector< bool > &results)
 Set the classical bits.
void SetResults (const std::vector< size_t > &indices, size_t results)
 Set the classical bits at the specified indices.
void Swap (OperationState &results)
 Set results.
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.

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

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

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

◆ 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 98 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 106 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 159 of file Operations.h.

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

◆ GetAllBits()

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

Get the classical bits.

Get the values of the classical bits.

Returns
The classical bit values reference.

Definition at line 215 of file Operations.h.

◆ 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 223 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 185 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 199 of file Operations.h.

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

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

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

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

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

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

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

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

◆ SetResultsInOrder()

void Circuits::OperationState::SetResultsInOrder ( const std::vector< bool > & results)
inline

Set the classical bits.

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

Parameters
resultsA vector of bools that contains the values for the bits.

Definition at line 255 of file Operations.h.

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


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