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

Quantum circuit class. More...

#include <classes/circuits.h>

Inheritance diagram for qpp::QCircuit:
Collaboration diagram for qpp::QCircuit:

Classes

struct  GateStep
 One step consisting only of gates/operators in the circuit. More...
 
class  iterator
 Quantum circuit bound-checking (safe) iterator. More...
 
struct  MeasureStep
 One step consisting only of measurements in the circuit. More...
 

Public Types

enum  GateType {
  GateType::NONE, GateType::SINGLE, GateType::TWO, GateType::THREE,
  GateType::CUSTOM, GateType::FAN, GateType::QFT, GateType::TFQ,
  GateType::SINGLE_CTRL_SINGLE_TARGET, GateType::SINGLE_CTRL_MULTIPLE_TARGET, GateType::MULTIPLE_CTRL_SINGLE_TARGET, GateType::MULTIPLE_CTRL_MULTIPLE_TARGET,
  GateType::CUSTOM_CTRL, GateType::SINGLE_cCTRL_SINGLE_TARGET, GateType::SINGLE_cCTRL_MULTIPLE_TARGET, GateType::MULTIPLE_cCTRL_SINGLE_TARGET,
  GateType::MULTIPLE_cCTRL_MULTIPLE_TARGET, GateType::CUSTOM_cCTRL
}
 Type of gate being executed in a gate step. More...
 
enum  MeasureType { MeasureType::NONE, MeasureType::MEASURE_Z, MeasureType::MEASURE_V, MeasureType::MEASURE_V_MANY }
 Type of measurement being executed in a measurement step. More...
 
enum  StepType { StepType::NONE, StepType::GATE, StepType::MEASUREMENT }
 Types of each step in the quantum circuit. More...
 
using const_iterator = iterator
 both iterators are const_iterators More...
 

Public Member Functions

iterator begin ()
 Iterator to the first element. More...
 
const_iterator begin () const noexcept
 Constant iterator to the first element. More...
 
const_iterator cbegin () const noexcept
 Constant iterator to the first element. More...
 
iterator end ()
 Iterator to the next to the last element. More...
 
const_iterator end () const noexcept
 Constant iterator to the next to the last element. More...
 
const_iterator cend () const noexcept
 Constant iterator to the next to the last element. More...
 
 QCircuit (idx nq, idx nc=0, idx d=2, std::string name="")
 Constructs a quantum circuit. More...
 
virtual ~QCircuit ()=default
 Default virtual destructor. More...
 
idx get_nq () const noexcept
 Total number of qudits in the circuit. More...
 
idx get_nc () const noexcept
 Total number of classical dits in the circuit. More...
 
idx get_d () const noexcept
 Dimension of the comprising qudits. More...
 
std::string get_name () const
 Quantum circuit name. More...
 
idx 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_non_measured () const
 Vector of non-measured qudit indexes. More...
 
idx get_gate_count () const noexcept
 Quantum circuit total gate count. More...
 
idx get_gate_count (const std::string &name) const
 Quantum circuit gate count. More...
 
idx get_gate_depth () const
 Quantum circuit total gate depth. More...
 
idx get_gate_depth (const std::string &name QPP_UNUSED_) const
 Quantum circuit gate depth. More...
 
idx get_measurement_count () const noexcept
 Quantum circuit total measurement count. More...
 
idx get_measurement_count (const std::string &name) const
 Quantum circuit measurement count. More...
 
idx get_step_count () const noexcept
 Quantum circuit total steps count, i.e. the sum of gate count and measurement count. More...
 
QCircuitgate (const cmat &U, idx i, std::string name="")
 Applies the single qudit gate U on single qudit i. More...
 
QCircuitgate (const cmat &U, idx i, idx j, std::string name="")
 Applies the two qudit gate U on qudits i and j. More...
 
QCircuitgate (const cmat &U, idx i, idx j, idx k, std::string name="")
 Applies the three qudit gate U on qudits i, j and k. More...
 
QCircuitgate_fan (const cmat &U, const std::vector< idx > &target, std::string name="")
 Applies the single qudit gate U on every qudit listed in target. More...
 
QCircuitgate_fan (const cmat &U, const std::initializer_list< idx > &target, std::string name="")
 Applies the single qudit gate U on every qudit listed in target. More...
 
QCircuitgate_fan (const cmat &U, std::string name="")
 Applies the single qudit gate U on every remaining non-measured qudit. More...
 
QCircuitgate_custom (const cmat &U, const std::vector< idx > &target, std::string name="")
 Jointly applies the custom multiple qudit gate U on the qudit indexes specified by target. More...
 
QCircuitQFT (const std::vector< idx > &target, bool swap QPP_UNUSED_=true)
 Applies the quantum Fourier transform (as a series of gates) on the qudit indexes specified by target. More...
 
QCircuitTFQ (const std::vector< idx > &target, bool swap QPP_UNUSED_=true)
 Applies the inverse quantum Fourier transform (as a series of gates) on the qudit indexes specified by target. More...
 
QCircuitCTRL (const cmat &U, idx ctrl, idx target, std::string name="")
 Applies the single qudit controlled gate U with control qudit ctrl and target qudit target. More...
 
QCircuitCTRL (const cmat &U, idx ctrl, const std::vector< idx > &target, std::string name="")
 Applies the single qudit controlled gate U with control qudit ctrl on every qudit listed in target. More...
 
QCircuitCTRL (const cmat &U, const std::vector< idx > &ctrl, idx target, std::string name="")
 Applies the single qudit controlled gate U with multiple control qudits listed in ctrl on the target qudit target. More...
 
QCircuitCTRL (const cmat &U, const std::vector< idx > &ctrl, const std::vector< idx > &target, std::string name="")
 Applies the single qudit controlled gate U with multiple control qudits listed in ctrl on every qudit listed in target. More...
 
QCircuitCTRL_custom (const cmat &U, const std::vector< idx > &ctrl, const std::vector< idx > &target, std::string name="")
 Jointly applies the custom multiple-qudit controlled gate U with multiple control qudits listed in ctrl on the qudit indexes specified by target. More...
 
QCircuitcCTRL (const cmat &U, idx ctrl_dit, idx target, std::string name="")
 Applies the single qubit controlled gate U with classical control dit ctrl and target qudit target. More...
 
QCircuitcCTRL (const cmat &U, idx ctrl_dit, const std::vector< idx > &target, std::string name="")
 Applies the single qudit controlled gate U with classical control dit ctrl on every qudit listed in target. More...
 
QCircuitcCTRL (const cmat &U, const std::vector< idx > &ctrl_dits, idx target, std::string name="")
 Applies the single qudit controlled gate U with multiple classical control dits listed in ctrl on the target qudit target. More...
 
QCircuitcCTRL (const cmat &U, const std::vector< idx > &ctrl_dits, const std::vector< idx > &target, std::string name="")
 Applies the single qudit controlled gate U with multiple classical control dits listed in ctrl on every qudit listed in target. More...
 
QCircuitcCTRL_custom (const cmat &U, const std::vector< idx > &ctrl_dits, const std::vector< idx > &target, std::string name="")
 Jointly applies the custom multiple-qudit controlled gate U with multiple classical control dits listed in ctrl on the qudit indexes specified by target. More...
 
QCircuitmeasureZ (idx target, idx c_reg, std::string name="")
 Measurement of single qudit in the computational basis (Z-basis) More...
 
QCircuitmeasureV (const cmat &V, idx target, idx c_reg, std::string name="")
 Measurement of single qudit in the orthonormal basis or rank-1 projectors specified by the columns of matrix V. More...
 
QCircuitmeasureV (const cmat &V, const std::vector< idx > &target, idx c_reg, std::string name="")
 Joint measurement of multiple qudits in the orthonormal basis or rank-1 projectors specified by the columns of matrix V. 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...
 

Private Member Functions

void add_hash_ (const cmat &U, std::size_t hashU)
 Adds matrix to the hash table. More...
 
const std::vector< MeasureStep > & get_measurements_ () const noexcept
 Vector of qpp::QCircuit::MeasureStep. More...
 
const std::vector< GateStep > & get_gates_ () const noexcept
 Vector of qpp::QCircuit::GateStep. More...
 
const std::unordered_map< std::size_t, cmat > & get_cmat_hash_tbl_ () const noexcept
 Hash table with the matrices used in the circuit. More...
 
std::ostream & display (std::ostream &os) const override
 qpp::IDisplay::display() override More...
 

Private Attributes

const idx nq_
 number of qudits More...
 
const idx nc_
 number of classical "dits" More...
 
const idx d_
 qudit dimension More...
 
std::string name_
 optional circuit name More...
 
std::vector< bool > measured_
 keeps track of the measured qudits More...
 
std::unordered_map< std::size_t, cmatcmat_hash_tbl_ {}
 
std::unordered_map< std::string, idxcount_ {}
 keeps track of the gate counts More...
 
std::unordered_map< std::string, idxdepth_ {}
 keeps track of the gate depths More...
 
std::unordered_map< std::string, idxmeasurement_count_ {}
 keeps track of the measurement counts More...
 
std::vector< GateStepgates_ {}
 gates More...
 
std::vector< MeasureStepmeasurements_ {}
 measurements More...
 
std::vector< StepTypestep_types_ {}
 type of each step More...
 

Friends

class QEngine
 
std::ostream & operator<< (std::ostream &os, const GateType &gate_type)
 Extraction operator overload for qpp::QCircuit::GateType enum class. More...
 
std::ostream & operator<< (std::ostream &os, const GateStep &gate_step)
 Extraction operator overload for qpp::QCircuit::GateStep class. More...
 
std::ostream & operator<< (std::ostream &os, const MeasureType &measure_type)
 Extraction operator overload for qpp::QCircuit::MeasureType enum class. More...
 
std::ostream & operator<< (std::ostream &os, const MeasureStep &measure_step)
 Extraction operator overload for qpp::QCircuit::MeasureStep class. More...
 

Detailed Description

Quantum circuit class.

See also
qpp::QEngine

Member Typedef Documentation

◆ const_iterator

both iterators are const_iterators

Member Enumeration Documentation

◆ GateType

Type of gate being executed in a gate step.

Enumerator
NONE 

represents no gate

SINGLE 

unitary gate on a single qudit

TWO 

unitary gate on 2 qudits

THREE 

unitary gate on 3 qudits

CUSTOM 

custom gate on multiple qudits

FAN 

same unitary gate on multiple qudits

QFT 

quantum Fourier transform,

TFQ 

quantum inverse Fourier transform,

SINGLE_CTRL_SINGLE_TARGET 

controlled 1 qudit unitary gate with one control and one target

SINGLE_CTRL_MULTIPLE_TARGET 

controlled 1 qudit unitary gate with one control and multiple targets

MULTIPLE_CTRL_SINGLE_TARGET 

controlled 1 qudit unitary gate with multiple controls and single target

MULTIPLE_CTRL_MULTIPLE_TARGET 

controlled 1 qudit unitary gate with multiple controls and multiple targets

CUSTOM_CTRL 

custom controlled gate with multiple controls and multiple targets

SINGLE_cCTRL_SINGLE_TARGET 

controlled 1 qudit unitary gate with one classical control and one target

SINGLE_cCTRL_MULTIPLE_TARGET 

controlled 1 qudit unitary gate with one classical control and multiple targets

MULTIPLE_cCTRL_SINGLE_TARGET 

controlled 1 qudit unitary gate with multiple classical controls and single target

MULTIPLE_cCTRL_MULTIPLE_TARGET 

controlled 1 qudit unitary gate with multiple classical controls and multiple targets

CUSTOM_cCTRL 

custom controlled gate with multiple controls and multiple targets

◆ MeasureType

Type of measurement being executed in a measurement step.

Enumerator
NONE 

represents no measurement

MEASURE_Z 

Z measurement of single qudit.

MEASURE_V 

measurement of single qudit in the orthonormal basis or rank-1 projectors specified by the columns of matrix V

MEASURE_V_MANY 

measurement of multiple qudits in the orthonormal basis or rank-1 projectors specified by the columns of matrix V

◆ StepType

Types of each step in the quantum circuit.

Enumerator
NONE 

represents no step

GATE 

quantum gate

MEASUREMENT 

measurement

Constructor & Destructor Documentation

◆ QCircuit()

qpp::QCircuit::QCircuit ( idx  nq,
idx  nc = 0,
idx  d = 2,
std::string  name = "" 
)
inlineexplicit

Constructs a quantum circuit.

Note
The measurement results can only be stored in the classical dits of which number is specified by nc
Parameters
nqNumber of qbits
ncNumber of classical dits
dSubsystem dimensions (optional, default is qubit, i.e. d = 2)
nameCircuit name (optional)

◆ ~QCircuit()

virtual qpp::QCircuit::~QCircuit ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

◆ add_hash_()

void qpp::QCircuit::add_hash_ ( const cmat U,
std::size_t  hashU 
)
inlineprivate

Adds matrix to the hash table.

Note
Throws if a hash collision is detected., i.e., if two different matrices have the same hash
Parameters
UComplex matrix
hashUHash value of U

◆ begin() [1/2]

iterator qpp::QCircuit::begin ( )
inline

Iterator to the first element.

Returns
Iterator to the first element

◆ begin() [2/2]

const_iterator qpp::QCircuit::begin ( ) const
inlinenoexcept

Constant iterator to the first element.

Returns
Constant iterator to the first element

◆ cbegin()

const_iterator qpp::QCircuit::cbegin ( ) const
inlinenoexcept

Constant iterator to the first element.

Returns
Constant iterator to the first element

◆ cCTRL() [1/4]

QCircuit& qpp::QCircuit::cCTRL ( const cmat U,
idx  ctrl_dit,
idx  target,
std::string  name = "" 
)
inline

Applies the single qubit controlled gate U with classical control dit ctrl and target qudit target.

Parameters
USingle qudit quantum gate
ctrl_ditClassical control dit index
targetTarget qudit index
nameOptional gate name
Returns
Reference to the current instance

◆ cCTRL() [2/4]

QCircuit& qpp::QCircuit::cCTRL ( const cmat U,
idx  ctrl_dit,
const std::vector< idx > &  target,
std::string  name = "" 
)
inline

Applies the single qudit controlled gate U with classical control dit ctrl on every qudit listed in target.

Parameters
USingle qudit quantum gate
ctrl_ditClassical control dit index
targetTarget qudit indexes; the gate U is applied on every one of them depending on the values of the classical control dits
nameOptional gate name
Returns
Reference to the current instance

◆ cCTRL() [3/4]

QCircuit& qpp::QCircuit::cCTRL ( const cmat U,
const std::vector< idx > &  ctrl_dits,
idx  target,
std::string  name = "" 
)
inline

Applies the single qudit controlled gate U with multiple classical control dits listed in ctrl on the target qudit target.

Parameters
USingle qudit quantum gate
ctrl_ditsClassical control dits indexes
targetTarget qudit index
nameOptional gate name
Returns
Reference to the current instance

◆ cCTRL() [4/4]

QCircuit& qpp::QCircuit::cCTRL ( const cmat U,
const std::vector< idx > &  ctrl_dits,
const std::vector< idx > &  target,
std::string  name = "" 
)
inline

Applies the single qudit controlled gate U with multiple classical control dits listed in ctrl on every qudit listed in target.

Parameters
USingle qudit quantum gate
ctrl_ditsClassical control dits indexes
targetTarget qudit indexes; the gate U is applied on every one of them depending on the values of the classical control dits
nameOptional gate name
Returns
Reference to the current instance

◆ cCTRL_custom()

QCircuit& qpp::QCircuit::cCTRL_custom ( const cmat U,
const std::vector< idx > &  ctrl_dits,
const std::vector< idx > &  target,
std::string  name = "" 
)
inline

Jointly applies the custom multiple-qudit controlled gate U with multiple classical control dits listed in ctrl on the qudit indexes specified by target.

Parameters
UMultiple-qudit quantum gate
ctrl_ditsClassical control dits indexes
targetTarget qudit indexes where the gate U is applied depending on the values of the classical control dits
nameOptional gate name
Returns
Reference to the current instance

◆ cend()

const_iterator qpp::QCircuit::cend ( ) const
inlinenoexcept

Constant iterator to the next to the last element.

Returns
Constant iterator to the next to the last element

◆ CTRL() [1/4]

QCircuit& qpp::QCircuit::CTRL ( const cmat U,
idx  ctrl,
idx  target,
std::string  name = "" 
)
inline

Applies the single qudit controlled gate U with control qudit ctrl and target qudit target.

Parameters
USingle qudit quantum gate
ctrlControl qudit index
targetTarget qudit index
nameOptional gate name
Returns
Reference to the current instance

◆ CTRL() [2/4]

QCircuit& qpp::QCircuit::CTRL ( const cmat U,
idx  ctrl,
const std::vector< idx > &  target,
std::string  name = "" 
)
inline

Applies the single qudit controlled gate U with control qudit ctrl on every qudit listed in target.

Parameters
USingle qudit quantum gate
ctrlControl qudit index
targetTarget qudit indexes; the gate U is applied on every one of them depending on the values of the control qudits
nameOptional gate name
Returns
Reference to the current instance

◆ CTRL() [3/4]

QCircuit& qpp::QCircuit::CTRL ( const cmat U,
const std::vector< idx > &  ctrl,
idx  target,
std::string  name = "" 
)
inline

Applies the single qudit controlled gate U with multiple control qudits listed in ctrl on the target qudit target.

Parameters
USingle qudit quantum gate
ctrlControl qudit indexes
targetTarget qudit index
nameOptional gate name
Returns
Reference to the current instance

◆ CTRL() [4/4]

QCircuit& qpp::QCircuit::CTRL ( const cmat U,
const std::vector< idx > &  ctrl,
const std::vector< idx > &  target,
std::string  name = "" 
)
inline

Applies the single qudit controlled gate U with multiple control qudits listed in ctrl on every qudit listed in target.

Parameters
USingle qudit quantum gate
ctrlControl qudit indexes
targetTarget qudit indexes; the gate U is applied on every one of them depending on the values of the control qudits
nameOptional gate name
Returns
Reference to the current instance

◆ CTRL_custom()

QCircuit& qpp::QCircuit::CTRL_custom ( const cmat U,
const std::vector< idx > &  ctrl,
const std::vector< idx > &  target,
std::string  name = "" 
)
inline

Jointly applies the custom multiple-qudit controlled gate U with multiple control qudits listed in ctrl on the qudit indexes specified by target.

Parameters
UMultiple-qudit quantum gate
ctrlControl qudit indexes
targetTarget qudit indexes where the gate U is applied depending on the values of the control qudits
nameOptional gate name
Returns
Reference to the current instance

◆ display()

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

qpp::IDisplay::display() override

Writes to the output stream a textual representation of the quantum circuit

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

Implements qpp::IDisplay.

◆ end() [1/2]

iterator qpp::QCircuit::end ( )
inline

Iterator to the next to the last element.

Returns
Iterator to the next to the last element

◆ end() [2/2]

const_iterator qpp::QCircuit::end ( ) const
inlinenoexcept

Constant iterator to the next to the last element.

Returns
Constant iterator to the next to the last element

◆ gate() [1/3]

QCircuit& qpp::QCircuit::gate ( const cmat U,
idx  i,
std::string  name = "" 
)
inline

Applies the single qudit gate U on single qudit i.

Parameters
USingle qudit quantum gate
iQudit index
nameOptional gate name
Returns
Reference to the current instance

◆ gate() [2/3]

QCircuit& qpp::QCircuit::gate ( const cmat U,
idx  i,
idx  j,
std::string  name = "" 
)
inline

Applies the two qudit gate U on qudits i and j.

Parameters
UTwo qudit quantum gate
iQudit index
jQudit index
nameOptional gate name
Returns
Reference to the current instance

◆ gate() [3/3]

QCircuit& qpp::QCircuit::gate ( const cmat U,
idx  i,
idx  j,
idx  k,
std::string  name = "" 
)
inline

Applies the three qudit gate U on qudits i, j and k.

Parameters
UThree qudit quantum gate
iQudit index
jQudit index
kQudit index
nameOptional gate name
Returns
Reference to the current instance

◆ gate_custom()

QCircuit& qpp::QCircuit::gate_custom ( const cmat U,
const std::vector< idx > &  target,
std::string  name = "" 
)
inline

Jointly applies the custom multiple qudit gate U on the qudit indexes specified by target.

Parameters
UMultiple qudit quantum gate
targetSubsystem indexes where the gate U is applied
nameOptional gate name
Returns
Reference to the current instance

◆ gate_fan() [1/3]

QCircuit& qpp::QCircuit::gate_fan ( const cmat U,
const std::vector< idx > &  target,
std::string  name = "" 
)
inline

Applies the single qudit gate U on every qudit listed in target.

Parameters
USingle qudit quantum gate
targetTarget qudit indexes; the gate U is applied on every one of them
nameOptional gate name
Returns
Reference to the current instance

◆ gate_fan() [2/3]

QCircuit& qpp::QCircuit::gate_fan ( const cmat U,
const std::initializer_list< idx > &  target,
std::string  name = "" 
)
inline

Applies the single qudit gate U on every qudit listed in target.

Parameters
USingle qudit quantum gate
targetTarget qudit indexes; the gate U is applied on every one of them
nameOptional gate name
Returns
Reference to the current instance

◆ gate_fan() [3/3]

QCircuit& qpp::QCircuit::gate_fan ( const cmat U,
std::string  name = "" 
)
inline

Applies the single qudit gate U on every remaining non-measured qudit.

Parameters
USingle qudit quantum gate
nameOptional gate name
Returns
Reference to the current instance

◆ get_cmat_hash_tbl_()

const std::unordered_map<std::size_t, cmat>& qpp::QCircuit::get_cmat_hash_tbl_ ( ) const
inlineprivatenoexcept

Hash table with the matrices used in the circuit.

Returns
Hash table with the matrices used in the circuit

◆ get_d()

idx qpp::QCircuit::get_d ( ) const
inlinenoexcept

Dimension of the comprising qudits.

Returns
Qudit dimension

◆ get_gate_count() [1/2]

idx qpp::QCircuit::get_gate_count ( ) const
inlinenoexcept

Quantum circuit total gate count.

Returns
Total gate count

◆ get_gate_count() [2/2]

idx qpp::QCircuit::get_gate_count ( const std::string &  name) const
inline

Quantum circuit gate count.

Parameters
nameGate name
Returns
Gate count

◆ get_gate_depth() [1/2]

idx qpp::QCircuit::get_gate_depth ( ) const
inline

Quantum circuit total gate depth.

Returns
Total gate depth

◆ get_gate_depth() [2/2]

idx qpp::QCircuit::get_gate_depth ( const std::string &name  QPP_UNUSED_) const
inline

Quantum circuit gate depth.

Parameters
nameGate name
Returns
Gate depth

◆ get_gates_()

const std::vector<GateStep>& qpp::QCircuit::get_gates_ ( ) const
inlineprivatenoexcept

Vector of qpp::QCircuit::GateStep.

Returns
Vector of qpp::QCircuit::GateStep

◆ get_measured() [1/2]

idx qpp::QCircuit::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::QCircuit::get_measured ( ) const
inline

Vector of already measured qudit indexes.

Returns
Vector of already measured qudit indexes

◆ get_measurement_count() [1/2]

idx qpp::QCircuit::get_measurement_count ( ) const
inlinenoexcept

Quantum circuit total measurement count.

Returns
Total measurement count

◆ get_measurement_count() [2/2]

idx qpp::QCircuit::get_measurement_count ( const std::string &  name) const
inline

Quantum circuit measurement count.

Parameters
nameMeasurement name
Returns
Measurement count

◆ get_measurements_()

const std::vector<MeasureStep>& qpp::QCircuit::get_measurements_ ( ) const
inlineprivatenoexcept

◆ get_name()

std::string qpp::QCircuit::get_name ( ) const
inline

Quantum circuit name.

Returns
Quantum circuit name

◆ get_nc()

idx qpp::QCircuit::get_nc ( ) const
inlinenoexcept

Total number of classical dits in the circuit.

Returns
Total number of classical dits

◆ get_non_measured()

std::vector<idx> qpp::QCircuit::get_non_measured ( ) const
inline

Vector of non-measured qudit indexes.

Returns
Vector of non-measured qudit indexes

◆ get_nq()

idx qpp::QCircuit::get_nq ( ) const
inlinenoexcept

Total number of qudits in the circuit.

Returns
Total number of qudits

◆ get_step_count()

idx qpp::QCircuit::get_step_count ( ) const
inlinenoexcept

Quantum circuit total steps count, i.e. the sum of gate count and measurement count.

Returns
Total (gates + measurements) count

◆ measureV() [1/2]

QCircuit& qpp::QCircuit::measureV ( const cmat V,
idx  target,
idx  c_reg,
std::string  name = "" 
)
inline

Measurement of single qudit in the orthonormal basis or rank-1 projectors specified by the columns of matrix V.

Parameters
VOrthonormal basis or rank-1 projectors specified by the columns of matrix V
targetQudit index
c_regClassical register where the value of the measurement is stored
nameOptional measurement name
Returns
Reference to the current instance

◆ measureV() [2/2]

QCircuit& qpp::QCircuit::measureV ( const cmat V,
const std::vector< idx > &  target,
idx  c_reg,
std::string  name = "" 
)
inline

Joint measurement of multiple qudits in the orthonormal basis or rank-1 projectors specified by the columns of matrix V.

Parameters
VOrthonormal basis or rank-1 projectors specified by the columns of matrix V
targetTarget qudit indexes that are jointly measured
c_regClassical register where the value of the measurement is stored
nameOptional measurement name
Returns
Reference to the current instance

◆ measureZ()

QCircuit& qpp::QCircuit::measureZ ( idx  target,
idx  c_reg,
std::string  name = "" 
)
inline

Measurement of single qudit in the computational basis (Z-basis)

Parameters
targetQudit index
c_regClassical register where the value of the measurement is being stored
nameOptional measurement name, default is "Measure Z"
Returns
Reference to the current instance

◆ QFT()

QCircuit& qpp::QCircuit::QFT ( const std::vector< idx > &  target,
bool swap  QPP_UNUSED_ = true 
)
inline

Applies the quantum Fourier transform (as a series of gates) on the qudit indexes specified by target.

Parameters
targetSubsystem indexes where the quantum Fourier transform is applied
swapSwaps the qubits at the end (true by default)
Returns
Reference to the current instance

◆ TFQ()

QCircuit& qpp::QCircuit::TFQ ( const std::vector< idx > &  target,
bool swap  QPP_UNUSED_ = true 
)
inline

Applies the inverse quantum Fourier transform (as a series of gates) on the qudit indexes specified by target.

Parameters
targetSubsystem indexes where the inverse quantum Fourier transform is applied
swapSwaps the qubits at the end (true by default)
Returns
Reference to the current instance

◆ to_JSON()

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

qpp::IJOSN::to_JSON() override

Displays the quantum circuit in JSON format

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

Implements qpp::IJSON.

Friends And Related Function Documentation

◆ operator<< [1/4]

std::ostream& operator<< ( std::ostream &  os,
const GateType gate_type 
)
friend

Extraction operator overload for qpp::QCircuit::GateType enum class.

Parameters
osOutput stream
gate_typeqpp::QCircuit::GateType enum class
Returns
Output stream

◆ operator<< [2/4]

std::ostream& operator<< ( std::ostream &  os,
const GateStep gate_step 
)
friend

Extraction operator overload for qpp::QCircuit::GateStep class.

Parameters
osOutput stream
gate_typeqpp::QCircuit::GateStep class
Returns
Output stream

◆ operator<< [3/4]

std::ostream& operator<< ( std::ostream &  os,
const MeasureType measure_type 
)
friend

Extraction operator overload for qpp::QCircuit::MeasureType enum class.

Parameters
osOutput stream
gate_typeqpp::QCircuit::MeasureType enum class
Returns
Output stream

◆ operator<< [4/4]

std::ostream& operator<< ( std::ostream &  os,
const MeasureStep measure_step 
)
friend

Extraction operator overload for qpp::QCircuit::MeasureStep class.

Parameters
osOutput stream
gate_typeqpp::QCircuit::MeasureStep enum class
Returns
Output stream

◆ QEngine

friend class QEngine
friend

Member Data Documentation

◆ cmat_hash_tbl_

std::unordered_map<std::size_t, cmat> qpp::QCircuit::cmat_hash_tbl_ {}
private

hash table with the matrices used in the circuit, with [Key = idx, Value = cmat]

◆ count_

std::unordered_map<std::string, idx> qpp::QCircuit::count_ {}
private

keeps track of the gate counts

◆ d_

const idx qpp::QCircuit::d_
private

qudit dimension

◆ depth_

std::unordered_map<std::string, idx> qpp::QCircuit::depth_ {}
private

keeps track of the gate depths

◆ gates_

std::vector<GateStep> qpp::QCircuit::gates_ {}
private

gates

◆ measured_

std::vector<bool> qpp::QCircuit::measured_
private

keeps track of the measured qudits

◆ measurement_count_

std::unordered_map<std::string, idx> qpp::QCircuit::measurement_count_ {}
private

keeps track of the measurement counts

◆ measurements_

std::vector<MeasureStep> qpp::QCircuit::measurements_ {}
private

measurements

◆ name_

std::string qpp::QCircuit::name_
private

optional circuit name

◆ nc_

const idx qpp::QCircuit::nc_
private

number of classical "dits"

◆ nq_

const idx qpp::QCircuit::nq_
private

number of qudits

◆ step_types_

std::vector<StepType> qpp::QCircuit::step_types_ {}
private

type of each step


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