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

Classical reversible circuit simulator. More...

#include <classes/reversible.h>

Inheritance diagram for qpp::Bit_circuit:
Collaboration diagram for qpp::Bit_circuit:

Classes

struct  Gate_count
 

Public Member Functions

 Bit_circuit (const Dynamic_bitset &dynamic_bitset)
 Conversion constructor, used to initialize a qpp::Bit_circuit with a qpp::Dynamic_bitset. More...
 
Bit_circuitX (idx pos)
 Bit flip. More...
 
Bit_circuitNOT (idx pos)
 Bit flip. More...
 
Bit_circuitCNOT (const std::vector< idx > &pos)
 Controlled-NOT. More...
 
Bit_circuitTOF (const std::vector< idx > &pos)
 Toffoli gate. More...
 
Bit_circuitSWAP (const std::vector< idx > &pos)
 Swap bits. More...
 
Bit_circuitFRED (const std::vector< idx > &pos)
 Fredkin gate (Controlled-SWAP) More...
 
Bit_circuitreset () noexcept
 Reset the circuit all zero, clear all gates. More...
 
 Dynamic_bitset (idx N)
 Inherited constructor. More...
 
- Public Member Functions inherited from qpp::Dynamic_bitset
 Dynamic_bitset (idx N)
 Constructor, initializes all bits to false (zero) More...
 
virtual ~Dynamic_bitset ()=default
 Default virtual destructor. More...
 
const storage_typedata () const
 Raw storage space of the bitset. More...
 
idx size () const noexcept
 Number of bits stored in the bitset. More...
 
idx storage_size () const noexcept
 Size of the underlying storage space (in units of value_type, unsigned int by default) More...
 
idx count () const noexcept
 Number of bits set to one in the bitset (Hamming weight) More...
 
bool get (idx pos) const noexcept
 The value of the bit at position pos. More...
 
bool none () const noexcept
 Checks whether none of the bits are set. More...
 
bool all () const noexcept
 Checks whether all bits are set. More...
 
bool any () const noexcept
 Checks whether any bit is set. More...
 
Dynamic_bitsetset (idx pos, bool value=true)
 Sets the bit at position pos. More...
 
Dynamic_bitsetset () noexcept
 Set all bits to true. More...
 
Dynamic_bitsetrand (idx pos, double p=0.5)
 Sets the bit at position pos according to a Bernoulli(p) distribution. More...
 
Dynamic_bitsetrand (double p=0.5)
 Sets all bits according to a Bernoulli(p) distribution. More...
 
Dynamic_bitsetreset (idx pos)
 Sets the bit at position pos to false. More...
 
Dynamic_bitsetreset () noexcept
 Sets all bits to false. More...
 
Dynamic_bitsetflip (idx pos)
 Flips the bit at position pos. More...
 
Dynamic_bitsetflip () noexcept
 Flips all bits. More...
 
bool operator== (const Dynamic_bitset &rhs) const noexcept
 Equality operator. More...
 
bool operator!= (const Dynamic_bitset &rhs) const noexcept
 Inequality operator. More...
 
idx operator- (const Dynamic_bitset &rhs) const noexcept
 Number of places the two bitsets differ (Hamming distance) More...
 
template<class CharT = char, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
std::basic_string< CharT, Traits, Allocator > to_string (CharT zero=CharT('0'), CharT one=CharT('1')) const
 String representation. 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 Attributes

struct qpp::Bit_circuit::Gate_count gate_count
 Gate counters. More...
 

Additional Inherited Members

- Public Types inherited from qpp::Dynamic_bitset
using value_type = unsigned int
 Type of the storage elements. More...
 
using storage_type = std::vector< value_type >
 Type of the storage. More...
 
- Protected Member Functions inherited from qpp::Dynamic_bitset
idx index_ (idx pos) const
 Index of the pos bit in the storage space. More...
 
idx offset_ (idx pos) const
 Offset of the pos bit in the storage space relative to its index. More...
 
- Protected Attributes inherited from qpp::Dynamic_bitset
idx storage_size_
 Storage size. More...
 
idx N_
 Number of bits. More...
 
std::vector< value_typev_
 Storage space. More...
 

Detailed Description

Classical reversible circuit simulator.

Constructor & Destructor Documentation

◆ Bit_circuit()

qpp::Bit_circuit::Bit_circuit ( const Dynamic_bitset dynamic_bitset)
inlineexplicit

Conversion constructor, used to initialize a qpp::Bit_circuit with a qpp::Dynamic_bitset.

Parameters
dynamic_bitsetDynamic bitset

Member Function Documentation

◆ CNOT()

Bit_circuit& qpp::Bit_circuit::CNOT ( const std::vector< idx > &  pos)
inline

Controlled-NOT.

Parameters
posBit position in the circuit
Returns
Reference to the current instance

◆ Dynamic_bitset()

qpp::Dynamic_bitset::Dynamic_bitset
inlineexplicit

Inherited constructor.

◆ FRED()

Bit_circuit& qpp::Bit_circuit::FRED ( const std::vector< idx > &  pos)
inline

Fredkin gate (Controlled-SWAP)

Parameters
posBit positions in the circuit, in the order control-target-target
Returns
Reference to the current instance

◆ NOT()

Bit_circuit& qpp::Bit_circuit::NOT ( idx  pos)
inline

Bit flip.

See also
qpp::Bit_circuit::X()
Parameters
posBit position in the circuit
Returns
Reference to the current instance

◆ reset()

Bit_circuit& qpp::Bit_circuit::reset ( )
inlinenoexcept

Reset the circuit all zero, clear all gates.

Returns
Reference to the current instance

◆ SWAP()

Bit_circuit& qpp::Bit_circuit::SWAP ( const std::vector< idx > &  pos)
inline

Swap bits.

Parameters
posBit positions in the circuit
Returns
Reference to the current instance

◆ TOF()

Bit_circuit& qpp::Bit_circuit::TOF ( const std::vector< idx > &  pos)
inline

Toffoli gate.

Parameters
posBit positions in the circuit, in the order control-control-target
Returns
Reference to the current instance

◆ X()

Bit_circuit& qpp::Bit_circuit::X ( idx  pos)
inline

Bit flip.

See also
qpp::Bit_circuit::NOT()
Parameters
posBit position in the circuit
Returns
Reference to the current instance

Member Data Documentation

◆ gate_count

struct qpp::Bit_circuit::Gate_count qpp::Bit_circuit::gate_count

Gate counters.


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