tket
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
tket::Box Class Referenceabstract

Abstract class for an operation from which a circuit can be extracted. More...

#include <Boxes.hpp>

Inheritance diagram for tket::Box:
Inheritance graph
[legend]
Collaboration diagram for tket::Box:
Collaboration graph
[legend]

Public Member Functions

 Box (const OpType &type, const op_signature_t &signature={})
 
 Box (const Box &other)
 
unsigned n_qubits () const override
 Number of Quantum inputs.
 
unsigned n_boolean () const
 Number of Boolean inputs.
 
unsigned n_classical () const
 Number of Classical inputs.
 
op_signature_t get_signature () const override
 Vector specifying type of data for each port on op.
 
nlohmann::json serialize () const override
 
std::shared_ptr< Circuitto_circuit () const
 Circuit represented by box.
 
virtual std::optional< Eigen::MatrixXcd > get_box_unitary () const
 If meaningful and implemented, return the numerical unitary matrix (in ILO-BE convention) which this Box represents.
 
Eigen::MatrixXcd get_unitary () const override
 If meaningful and implemented, return the numerical unitary matrix (in ILO-BE convention) which this Op represents.
 
boost::uuids::uuid get_id () const
 Unique identifier (preserved on copy)
 
- Public Member Functions inherited from tket::Op
virtual Op_ptr dagger () const
 Inverse (of a unitary operation)
 
virtual Op_ptr transpose () const
 Transpose of a unitary operation.
 
virtual Op_ptr symbol_substitution (const SymEngine::map_basic_basic &sub_map) const =0
 Operation with values for symbols substituted.
 
virtual std::vector< Exprget_params () const
 Sequence of phase parameters, if applicable.
 
virtual std::vector< Exprget_params_reduced () const
 Sequence of phase parameters reduced to canonical range, if applicable.
 
virtual std::string get_name (bool latex=false) const
 String representation.
 
virtual std::string get_command_str (const unit_vector_t &args) const
 Command representation.
 
OpDesc get_desc () const
 Get operation descriptor.
 
OpType get_type () const
 Get operation type.
 
virtual SymSet free_symbols () const =0
 Set of all free symbols occurring in operation parameters.
 
virtual std::optional< Paulicommuting_basis (port_t i) const
 Which Pauli, if any, commutes with the operation at a given port.
 
virtual bool commutes_with_basis (const std::optional< Pauli > &colour, port_t i) const
 Whether the operation commutes with the given Pauli at the given port.
 
virtual bool is_extern () const
 return if the op is external
 
virtual std::optional< double > is_identity () const
 Test whether operation is identity up to a phase and return phase if so.
 
virtual bool is_clifford () const
 Test whether operation is in the Clifford group.
 
virtual bool has_symmetry (unsigned port1, unsigned port2) const
 Checks for symmetry of port pairs.
 
virtual ~Op ()
 
bool operator== (const Op &other) const
 
virtual bool is_equal (const Op &) const
 Checks equality between two instances of the same class.
 

Static Public Member Functions

static Op_ptr deserialize (const nlohmann::json &j)
 

Protected Member Functions

virtual void generate_circuit () const =0
 
- Protected Member Functions inherited from tket::Op
 Op (const OpType &type)
 

Static Protected Member Functions

static boost::uuids::uuid idgen ()
 

Protected Attributes

op_signature_t signature_
 
std::shared_ptr< Circuitcirc_
 
boost::uuids::uuid id_
 
- Protected Attributes inherited from tket::Op
const OpDesc desc_
 Operation descriptor.
 
const OpType type_
 Operation type.
 

Friends

template<typename BoxT >
Op_ptr set_box_id (BoxT &b, boost::uuids::uuid newid)
 Set explicit ID on a box.
 

Detailed Description

Abstract class for an operation from which a circuit can be extracted.

Definition at line 38 of file Boxes.hpp.

Constructor & Destructor Documentation

◆ Box() [1/2]

tket::Box::Box ( const OpType type,
const op_signature_t signature = {} 
)
inlineexplicit

Definition at line 40 of file Boxes.hpp.

◆ Box() [2/2]

tket::Box::Box ( const Box other)
inline

Definition at line 45 of file Boxes.hpp.

Member Function Documentation

◆ deserialize()

Op_ptr tket::Box::deserialize ( const nlohmann::json &  j)
static

Definition at line 70 of file Boxes.cpp.

◆ generate_circuit()

virtual void tket::Box::generate_circuit ( ) const
protectedpure virtual

◆ get_box_unitary()

virtual std::optional< Eigen::MatrixXcd > tket::Box::get_box_unitary ( ) const
inlinevirtual

If meaningful and implemented, return the numerical unitary matrix (in ILO-BE convention) which this Box represents.

Returns
unitary matrix (ILO-BE) which this Box represents

Reimplemented in tket::Unitary1qBox, tket::Unitary2qBox, tket::Unitary3qBox, tket::ExpBox, tket::QControlBox, and tket::ToffoliBox.

Definition at line 78 of file Boxes.hpp.

◆ get_id()

boost::uuids::uuid tket::Box::get_id ( ) const
inline

Unique identifier (preserved on copy)

Definition at line 91 of file Boxes.hpp.

◆ get_signature()

op_signature_t tket::Box::get_signature ( ) const
overridevirtual

◆ get_unitary()

Eigen::MatrixXcd tket::Box::get_unitary ( ) const
inlineoverridevirtual

If meaningful and implemented, return the numerical unitary matrix (in ILO-BE convention) which this Op represents.

Precondition
No symbolic parameters.
Returns
unitary matrix (ILO-BE) which this Op represents
Exceptions
BadOpTypeupon error.

Reimplemented from tket::Op.

Definition at line 82 of file Boxes.hpp.

◆ idgen()

static boost::uuids::uuid tket::Box::idgen ( )
inlinestaticprotected

Definition at line 97 of file Boxes.hpp.

◆ n_boolean()

unsigned tket::Box::n_boolean ( ) const

Number of Boolean inputs.

Definition at line 45 of file Boxes.cpp.

◆ n_classical()

unsigned tket::Box::n_classical ( ) const

Number of Classical inputs.

Definition at line 50 of file Boxes.cpp.

◆ n_qubits()

unsigned tket::Box::n_qubits ( ) const
overridevirtual

Number of Quantum inputs.

Reimplemented from tket::Op.

Definition at line 40 of file Boxes.cpp.

◆ serialize()

nlohmann::json tket::Box::serialize ( ) const
overridevirtual

Reimplemented from tket::Op.

Definition at line 63 of file Boxes.cpp.

◆ to_circuit()

std::shared_ptr< Circuit > tket::Box::to_circuit ( ) const
inline

Circuit represented by box.

Definition at line 67 of file Boxes.hpp.

Friends And Related Symbol Documentation

◆ set_box_id

template<typename BoxT >
Op_ptr set_box_id ( BoxT &  b,
boost::uuids::uuid  newid 
)
friend

Set explicit ID on a box.

This is used for deserialization.

Parameters
bbox
[in]newidnew ID
Template Parameters
BoxTconcrete box type
Returns
box with desired ID

Definition at line 125 of file Boxes.hpp.

Member Data Documentation

◆ circ_

std::shared_ptr<Circuit> tket::Box::circ_
mutableprotected

Definition at line 103 of file Boxes.hpp.

◆ id_

boost::uuids::uuid tket::Box::id_
protected

Definition at line 104 of file Boxes.hpp.

◆ signature_

op_signature_t tket::Box::signature_
protected

Definition at line 102 of file Boxes.hpp.


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