Quantum++  v1.2
A modern C++11 quantum computing library
qpp::QEngine Class Reference

Quantum circuit engine, executes qpp::QCircuit. More...

#include <classes/circuits.h>

Inheritance diagram for qpp::QEngine:
Collaboration diagram for qpp::QEngine:

Public Member Functions

 QEngine (const QCircuit &qc)
 Constructs a quantum engine out of a quantum circuit. More...
 
 QEngine (const QEngine &)=default
 Default copy constructor. More...
 
QEngineoperator= (const QEngine &)=default
 Default copy assignment operator. More...
 
 QEngine (QCircuit &&)=delete
 Disables rvalue QCircuit. More...
 
virtual ~QEngine ()=default
 Default virtual destructor. More...
 
ket get_psi () const
 Underlying quantum state. More...
 
ketget_ref_psi ()
 Reference to the underlying quantum state. More...
 
std::vector< idxget_dits () const
 Vector with the values of the underlying classical dits. More...
 
idx get_dit (idx i) const
 Value of the classical dit at position i. More...
 
std::vector< double > get_probs () const
 Vector of underlying measurement outcome probabilities. More...
 
bool get_measured (idx i) const
 Check whether qudit i was already measured. More...
 
std::vector< idxget_measured () const
 Vector of already measured qudit indexes. More...
 
std::vector< idxget_not_measured () const
 Vector of non-measured qudit indexes. More...
 
const QCircuitget_circuit () const noexcept
 Quantum circuit. More...
 
QEngineset_dit (idx i, idx value)
 Sets the classical dit at position i. More...
 
void reset ()
 Resets the engine. More...
 
void execute (const QCircuit::iterator::value_type &elem)
 Executes one step in the quantum circuit. More...
 
void execute (const QCircuit::iterator &it)
 Executes one step in the quantum circuit. More...
 
std::string to_JSON (bool enclosed_in_curly_brackets=true) const override
 qpp::IJOSN::to_JSON() override More...
 
- Public Member Functions inherited from qpp::IDisplay
 IDisplay ()=default
 Default constructor. More...
 
 IDisplay (const IDisplay &)=default
 Default copy constructor. More...
 
 IDisplay (IDisplay &&)=default
 Default move constructor. More...
 
IDisplayoperator= (const IDisplay &)=default
 Default copy assignment operator. More...
 
IDisplayoperator= (IDisplay &&)=default
 Default move assignment operator. More...
 
virtual ~IDisplay ()=default
 Default virtual destructor. More...
 
- Public Member Functions inherited from qpp::IJSON
 IJSON ()=default
 Default constructor. More...
 
 IJSON (const IJSON &)=default
 Default copy constructor. More...
 
 IJSON (IJSON &&)=default
 Default move constructor. More...
 
IJSONoperator= (const IJSON &)=default
 Default copy assignment operator. More...
 
IJSONoperator= (IJSON &&)=default
 Default move assignment operator. More...
 
virtual ~IJSON ()=default
 Default virtual destructor. More...
 

Protected Member Functions

void set_measured_ (idx i)
 Marks qudit i as measured then re-label accordingly the remaining non-measured qudits. More...
 
std::vector< idxget_relative_pos_ (std::vector< idx > v)
 Giving a vector V of non-measured qudits, get their relative position with respect to the measured qudits. More...
 

Protected Attributes

const QCircuitqc_
 pointer to constant quantum circuit More...
 
ket psi_
 state vector More...
 
std::vector< idxdits_
 classical dits More...
 
std::vector< double > probs_
 measurement probabilities More...
 
std::vector< idxsubsys_
 

Private Member Functions

std::ostream & display (std::ostream &os) const override
 qpp::IDisplay::display() override More...
 

Detailed Description

Quantum circuit engine, executes qpp::QCircuit.

See also
qpp::QCircuit

Constructor & Destructor Documentation

◆ QEngine() [1/3]

qpp::QEngine::QEngine ( const QCircuit qc)
inlineexplicit

Constructs a quantum engine out of a quantum circuit.

Note
The quantum circuit must be an lvalue
See also
qpp::QEngine(QCircuit&&)
Note
The initial underlying quantum state is set to $|0\rangle^{\otimes n}$
Parameters
qcQuantum circuit

◆ QEngine() [2/3]

qpp::QEngine::QEngine ( const QEngine )
default

Default copy constructor.

◆ QEngine() [3/3]

qpp::QEngine::QEngine ( QCircuit &&  )
delete

Disables rvalue QCircuit.

◆ ~QEngine()

virtual qpp::QEngine::~QEngine ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

◆ display()

std::ostream& qpp::QEngine::display ( std::ostream &  os) const
inlineoverrideprivatevirtual

qpp::IDisplay::display() override

Writes to the output stream a textual representation of the state of the engine

Parameters
osOutput stream passed by reference
Returns
Reference to the output stream

Implements qpp::IDisplay.

◆ execute() [1/2]

void qpp::QEngine::execute ( const QCircuit::iterator::value_type elem)
inline

Executes one step in the quantum circuit.

Parameters
elemStep to be executed

◆ execute() [2/2]

void qpp::QEngine::execute ( const QCircuit::iterator it)
inline

Executes one step in the quantum circuit.

Parameters
itIterator to the step to be executed

◆ get_circuit()

const QCircuit& qpp::QEngine::get_circuit ( ) const
inlinenoexcept

Quantum circuit.

Returns
Underlying quantum circuit

◆ get_dit()

idx qpp::QEngine::get_dit ( idx  i) const
inline

Value of the classical dit at position i.

Parameters
iClassical dit index
Returns
Value of the classical dit at position i

◆ get_dits()

std::vector<idx> qpp::QEngine::get_dits ( ) const
inline

Vector with the values of the underlying classical dits.

Returns
Vector of underlying classical dits

◆ get_measured() [1/2]

bool qpp::QEngine::get_measured ( idx  i) const
inline

Check whether qudit i was already measured.

Parameters
iQudit index
Returns
True if qudit i was already measured, false othwewise

◆ get_measured() [2/2]

std::vector<idx> qpp::QEngine::get_measured ( ) const
inline

Vector of already measured qudit indexes.

Returns
Vector of already measured qudit indexes

◆ get_not_measured()

std::vector<idx> qpp::QEngine::get_not_measured ( ) const
inline

Vector of non-measured qudit indexes.

Returns
Vector of non-measured qudit indexes

◆ get_probs()

std::vector<double> qpp::QEngine::get_probs ( ) const
inline

Vector of underlying measurement outcome probabilities.

Note
The probability vector has the same length as the vector of classical dits. If the measurement result is stored at the index c_reg, then the outcome probability is automatically stored at the same index c_reg in the probability vector.
Returns
Vector of underlying measurement outcome probabilities

◆ get_psi()

ket qpp::QEngine::get_psi ( ) const
inline

Underlying quantum state.

Returns
Underlying quantum state

◆ get_ref_psi()

ket& qpp::QEngine::get_ref_psi ( )
inline

Reference to the underlying quantum state.

Returns
Reference to the underlying quantum state

◆ get_relative_pos_()

std::vector<idx> qpp::QEngine::get_relative_pos_ ( std::vector< idx v)
inlineprotected

Giving a vector V of non-measured qudits, get their relative position with respect to the measured qudits.

Parameters
v
Returns
Vector of qudit indexes

◆ operator=()

QEngine& qpp::QEngine::operator= ( const QEngine )
default

Default copy assignment operator.

Returns
Reference to the current instance

◆ reset()

void qpp::QEngine::reset ( )
inline

Resets the engine.

Re-initializes everything to zero and sets the initial state to $|0\rangle^{\otimes n}$

◆ set_dit()

QEngine& qpp::QEngine::set_dit ( idx  i,
idx  value 
)
inline

Sets the classical dit at position i.

Parameters
iClassical dit index
valueClassical dit value
Returns
Reference to the current instance

◆ set_measured_()

void qpp::QEngine::set_measured_ ( idx  i)
inlineprotected

Marks qudit i as measured then re-label accordingly the remaining non-measured qudits.

Parameters
iQudit index

◆ to_JSON()

std::string qpp::QEngine::to_JSON ( bool  enclosed_in_curly_brackets = true) const
inlineoverridevirtual

qpp::IJOSN::to_JSON() override

Displays the state of the engine in JSON format

Parameters
enclosed_in_curly_bracketsIf true, encloses the result in curly brackets
Returns
String containing the JSON representation of the state of the engine

Implements qpp::IJSON.

Member Data Documentation

◆ dits_

std::vector<idx> qpp::QEngine::dits_
protected

classical dits

◆ probs_

std::vector<double> qpp::QEngine::probs_
protected

measurement probabilities

◆ psi_

ket qpp::QEngine::psi_
protected

state vector

◆ qc_

const QCircuit* qpp::QEngine::qc_
protected

pointer to constant quantum circuit

◆ subsys_

std::vector<idx> qpp::QEngine::subsys_
protected

keeps track of the measured subsystems, relabel them after measurements


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