|
Maestro 0.2.5
Unified interface for quantum circuit simulation
|
Measurement operation class. More...
#include <Measurements.h>
Inheritance diagram for Circuits::MeasurementOperation< Time >:
Collaboration diagram for Circuits::MeasurementOperation< Time >:Public Member Functions | |
| MeasurementOperation (const std::vector< std::pair< Types::qubit_t, size_t > > &qs={}, Time delay=0) | |
| Constructor. | |
| std::vector< size_t > | AffectedBits () const override |
| Returns the classical bits affected by the measurement. | |
| Types::qubits_vector | AffectedQubits () const override |
| Returns the qubits affected by the measurement. | |
| virtual bool | CanAffectQuantumState () const |
| Find if the operation can affect the quantum state. | |
| void | Clear () |
| Clears the qubits and classical bits involved in the measurement. | |
| 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 |
| Executes the measurement on the given simulator. | |
| const std::vector< size_t > & | GetBitsIndices () const |
| Returns the classical bits where the measurement results are stored. | |
| Time | GetDelay () const |
| Get the delay of the operation. | |
| virtual size_t | GetNumQubits () const |
| Get the number of qubits affected by the operation. | |
| std::shared_ptr< IOperation< Time > > | getptr () |
| Get a shared pointer to this object. | |
| const Types::qubits_vector & | GetQubits () const |
| Returns the qubits that are to be measured. | |
| 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 | Sample (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const |
| Samples the measurement on the given simulator. | |
| void | SetBit (size_t index, Types::qubit_t bit) |
| Set the classical bit to index. | |
| void | SetDelay (Time d) |
| Set the delay of the operation. | |
| void | SetQubit (size_t index, Types::qubit_t qubit) |
| Set the qubit to measure. | |
| void | SetQubits (const std::vector< std::pair< Types::qubit_t, size_t > > &qs) |
| Sets the qubits and classical bits involved in the measurement. | |
| void | SetStateFromSample (const std::vector< bool > &measurements, OperationState &state) const |
Measurement operation class.
Implementation of an operation that does a qubits measurements on a simulator. The results are stored in a classical 'state'. Each qubit has a corresponding classical 'bit' where the measurement result is stored.
| Time | The time type used for the simulation. |
Definition at line 37 of file Measurements.h.
|
inline |
Constructor.
Creates a measurement operation that measures the given qubits and stores the results in the given bits.
| qs | The qubits to measure and the classical bits where the result is stored, specified as pairs. |
| delay | The duration of the operation. |
Definition at line 49 of file Measurements.h.
|
inlineoverridevirtual |
Returns the classical bits affected by the measurement.
Returns the classical bits affected by the measurement.
Reimplemented from Circuits::IOperation< Time >.
Definition at line 193 of file Measurements.h.
References Circuits::MeasurementOperation< Time >::GetBitsIndices().
|
inlineoverridevirtual |
Returns the qubits affected by the measurement.
Returns the qubits affected by the measurement.
Reimplemented from Circuits::IOperation< Time >.
Definition at line 185 of file Measurements.h.
|
inlinevirtualinherited |
Find if the operation can affect the quantum state.
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.
|
inline |
Clears the qubits and classical bits involved in the measurement.
Clears the qubits and classical bits involved in the measurement.
Definition at line 78 of file Measurements.h.
|
inlineoverridevirtual |
Get a shared pointer to a clone of this object.
Returns a shared pointer to a copy of this object.
Implements Circuits::IOperation< Time >.
Definition at line 170 of file Measurements.h.
References Circuits::IOperation< Time >::GetDelay().
|
inlineoverridevirtual |
Executes the measurement on the given simulator.
Executes the measurement on the given simulator.
| sim | The simulator to execute the measurement on. |
| state | The classical state for the simulator. |
Implements Circuits::IOperation< Time >.
Definition at line 126 of file Measurements.h.
References Circuits::MeasurementOperation< Time >::SetStateFromSample().
|
inline |
Returns the classical bits where the measurement results are stored.
Returns the classical bits where the measurement results are stored.
Definition at line 114 of file Measurements.h.
Referenced by Circuits::MeasurementOperation< Time >::AffectedBits().
|
inlineinherited |
Get the delay of the operation.
Returns the delay due of the execution time 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==().
|
inlinevirtual |
Get the number of qubits affected by the operation.
Returns the number of qubits affected by the operation.
Definition at line 71 of file Measurements.h.
|
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.
Definition at line 487 of file Operations.h.
|
inline |
Returns the qubits that are to be measured.
Returns the qubits that are to be measured.
Definition at line 106 of file Measurements.h.
|
inlineoverridevirtual |
Get the type of the operation.
Returns the type of the operation, in this case, measurement.
Reimplemented from Circuits::IOperation< Time >.
Definition at line 63 of file Measurements.h.
References Circuits::kMeasurement.
|
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.
Reimplemented from Circuits::IOperation< Time >.
Definition at line 241 of file Measurements.h.
|
inlinevirtualinherited |
Find if the operation is a conditional operation.
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.
|
inlinevirtualinherited |
Find if the operation needs entanglement for distribution.
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.
|
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.
| qubitsMap | The map of qubits to remap. |
| bitsMap | The map of classical bits to remap. |
Implements Circuits::IOperation< Time >.
Definition at line 205 of file Measurements.h.
|
inline |
Samples the measurement on the given simulator.
Samples the measurement on the given simulator. Should not apply the measurement.
| sim | The simulator to sample the measurement on. |
| state | The classical state for the simulator. |
Definition at line 146 of file Measurements.h.
References Circuits::MeasurementOperation< Time >::SetStateFromSample().
|
inline |
Set the classical bit to index.
This method sets the classical bit index at the specified index.
| index | The index of the classical bit index. |
| bit | The classical bit index to set. |
Definition at line 261 of file Measurements.h.
|
inlineinherited |
Set the delay of the operation.
Sets the delay due of the execution time of the operation.
| d | The delay of the operation. |
Definition at line 505 of file Operations.h.
|
inline |
Set the qubit to measure.
This method sets the qubit to measure at the specified index.
| index | The index of the qubit to measure. |
| qubit | The qubit to measure. |
Definition at line 250 of file Measurements.h.
|
inline |
Sets the qubits and classical bits involved in the measurement.
Sets the qubits and classical bits involved in the measurement, specified as pairs.
| qs | The qubits to measure and the classical bits where the result is stored, specified as pairs. |
Definition at line 91 of file Measurements.h.
|
inline |
Definition at line 155 of file Measurements.h.
References Circuits::OperationState::SetBit().
Referenced by Circuits::MeasurementOperation< Time >::Execute(), and Circuits::MeasurementOperation< Time >::Sample().