C++ cengines

namespace cengines
class ComputeCircuit
#include <compute.hpp>

Circuit wrapper class that implements the compute-uncompute pattern.

Public Types

using cbit_t = tweedledum::Cbit

Public Functions

inline explicit ComputeCircuit(circuit_t &original)

Constructor.

Parameters

original – A quantum circuit

inline ~ComputeCircuit()

Destructor.

Only when the ComputeCircuit object is being destroyed are the instructions added to it so far will be transferred to the original quantum circuit object.

ComputeCircuit(const ComputeCircuit&) = delete
ComputeCircuit(ComputeCircuit&&) = default
ComputeCircuit &operator=(const ComputeCircuit&) = delete
ComputeCircuit &operator=(ComputeCircuit&&) = delete
inline void done_compute()

For internal-use only.

inline circuit_t &compute()

Read-write getter to the circuit storing the computed instructions.

inline circuit_t &non_compute()

Read-write getter to the circuit storing the instructions between the compute and uncompute regions.

class ControlledCircuit
#include <control.hpp>

Public Types

using cbit_t = tweedledum::Cbit

Public Functions

inline ControlledCircuit(circuit_t &original, const qubits_t &controls)
inline ~ControlledCircuit()
ControlledCircuit(const ControlledCircuit&) = delete
ControlledCircuit(ControlledCircuit&&) = default
ControlledCircuit &operator=(const ControlledCircuit&) = delete
ControlledCircuit &operator=(ControlledCircuit&&) = delete
inline void apply()
inline explicit operator circuit_t&()
class CppGraphMapper
#include <cpp_graph_mapper.hpp>

C++ class to represent an arbitrary graph mapper.

This is intended to be instantiated in Python by users in order to define the hardware architecture they want to use for mapping

Subclassed by mindquantum::python::CppGraphMapper

Public Types

using device_t = tweedledum::Device
using circuit_t = tweedledum::Circuit
using placement_t = tweedledum::Placement
using mapping_t = tweedledum::Mapping
using mapping_ret_t = std::pair<circuit_t, mapping_t>
using mapping_param_t = std::variant<mapping::sabre_config, mapping::jit_config>
using edge_list_t = std::vector<std::tuple<uint32_t, uint32_t>>

Public Functions

explicit CppGraphMapper(const mapping_param_t &params)

Constructor with empty graph.

The mapping algorithm used by the mapper is defined by the type of the parameters that is passed in argument. The mapper currently supports three mapping algorithms:

  • SABRE (SWAP-based Bidirectional heuristic search algorithm)

  • JIT (just-in-time algorithm)

  • SAT (boolean satisfiability problem solver)

Parameters

params – Parameters for the mapping algorithm

CppGraphMapper(uint32_t num_qubits, const edge_list_t &edge_list, const mapping_param_t &params)

Constructor with graph defined by number of qubits and edges.

The mapping algorithm used by the mapper is defined by the type of the parameters that is passed in argument. The mapper currently supports three mapping algorithms:

  • SABRE (SWAP-based Bidirectional heuristic search algorithm)

  • ZDD (zero-suppressed decision diagram)

  • SAT (boolean satisfiability problem solver)

Parameters
  • num_qubits – Number of qubits

  • edge_list – List of edges in the graph

  • params – Parameters for the mapping algorithm

inline const auto &device() const

Simple getter for the underlying device used by this mapper.

mapping_ret_t hot_start(const device_t &device, const circuit_t &circuit, placement_t &placement) const

Apply the mapping algorithm to a network given an initial mapping.

This method will use the architecture defined within the instance of the CppGraphMapper, as well as the mapping parameters in order to choose which mapping algorithm to call.

Parameters

state – Current mapping state

mapping_ret_t cold_start(const device_t &device, const circuit_t &circuit) const

Apply the mapping algorithm to a network without an initial mapping.

This method will use the architecture defined within the instance of the CppGraphMapper, as well as the mapping parameters in order to choose which mapping algorithm to call.

Parameters

state – Current mapping state

inline const auto &get_mapping_parameters() const

Simple getter for mapping parameters.

void path_device(uint32_t num_qubits, bool cyclic = false)

Set device graph to be a 1D arrangement of qubits.

void grid_device(uint32_t num_columns, uint32_t num_rows)

Set device graph to be a 2D grid of qubits.

class CppPrinter
#include <cpp_printer.hpp>

C++ class to represent a command printer with seleprojectqctable language.

This is intended to be instantiated in Python by users in order to define the output language they want to use

Subclassed by mindquantum::python::CommandPrinter

Public Types

enum language_t

Values:

enumerator projectq
enumerator openqasm
enumerator qasm
enumerator qiskit

Public Functions

explicit CppPrinter(language_t language) noexcept

Constructor.

This is intended to be instantiated in Python by users in order to print all the gates stored in the C++ network.

Parameters

language – The format in which the network should be printed.g

explicit CppPrinter(std::string_view language)

Constructor.

This is intended to be instantiated in Python by users in order to print all the gates stored in the C++ network.

Parameters

language – The format in which the network should be printed.

Throws

std::runtime_error – if format is invalid

template<typename circuit_t>
void print_output(const circuit_t &circuit, std::ostream &output_stream)

Print circuit to using specified format.

Parameters
  • circuit – The network to be printed

  • output_stream – Where to print the network Tweedledum ids

Public Static Functions

static constexpr std::string_view lang_to_str(language_t language)

Convert language_t to string.

static constexpr std::optional<language_t> str_to_lang(std::string_view language)

Convert string to language_t.

struct ResourceCounter
#include <cpp_resource_counter.hpp>

C++ equivalent to projectq.backends.ResourceCounter.

Prints all gate classes and specific gates it encountered (cumulative over several flushes)

Subclassed by mindquantum::python::ResourceCounter

Public Types

using param_t = std::optional<double>
using ctrl_count_t = std::size_t
using class_desc_t = std::pair<std::string_view, ctrl_count_t>
using gate_desc_t = std::tuple<std::string_view, param_t, ctrl_count_t>

Public Functions

void add_gate_count(std::string_view kind, param_t param, std::size_t n_controls, std::size_t count)
void add_gate_counts(const tweedledum::Circuit &network)

Add gates in Network to gate (class) counts.

Public Members

std::size_t max_width_
std::map<class_desc_t, std::size_t> gate_class_counts_
std::map<gate_desc_t, std::size_t> gate_counts_
void *origin_
namespace cpp

Typedefs

using mapping_t = std::map<unsigned int, unsigned int>
class GridMapper
#include <cpp_mapping.hpp>

Subclassed by mindquantum::python::cpp::GridMapper

Public Functions

DECLARE_ATTRIBUTE(mapping_t, _current_mapping)
DECLARE_ATTRIBUTE(unsigned int, num_qubits)
DECLARE_ATTRIBUTE(unsigned int, num_mappings)
DECLARE_ATTRIBUTE(unsigned int, storage)
DECLARE_ATTRIBUTE(unsigned int, num_rows)
DECLARE_ATTRIBUTE(unsigned int, num_columns)
class InstructionFilter
#include <cpp_engine_list.hpp>

Subclassed by mindquantum::python::cpp::InstructionFilter

class LinearMapper
#include <cpp_mapping.hpp>

Subclassed by mindquantum::python::cpp::LinearMapper

Public Functions

DECLARE_ATTRIBUTE(mapping_t, _current_mapping)
DECLARE_ATTRIBUTE(unsigned int, num_qubits)
DECLARE_ATTRIBUTE(unsigned int, num_mappings)
DECLARE_ATTRIBUTE(unsigned int, storage)
DECLARE_ATTRIBUTE(bool, cyclic)
class LocalOptimizer
#include <cpp_optimisation.hpp>

Subclassed by mindquantum::python::cpp::LocalOptimizer

Public Members

unsigned int _m_
class TagRemover
#include <cpp_engine_list.hpp>

Subclassed by mindquantum::python::cpp::TagRemover

namespace details
class ComputeCircuitProxy
#include <compute.hpp>

Helper class to implement WITH_COMPUTE statements in C++.

Public Functions

inline explicit ComputeCircuitProxy(ComputeCircuit &compute)

Constructor.

Parameters

compute – ComputCircuit object to wrap.

inline ~ComputeCircuitProxy()

Destructor.

ComputeCircuitProxy(const ComputeCircuitProxy&) = delete
ComputeCircuitProxy(ComputeCircuitProxy&&) = delete
ComputeCircuitProxy &operator=(const ComputeCircuitProxy&) = delete
ComputeCircuitProxy &operator=(ComputeCircuitProxy&&) = delete
inline operator circuit_t&() &

Read-write getter to the circuit storing the computed instructions.