tket
Loading...
Searching...
No Matches
Namespaces | Classes | Concepts | Typedefs | Enumerations | Functions | Variables
tket Namespace Reference

Defines tket::DeviceCharacterisation, used in NoiseAwarePlacement and in commute_SQ_gates_through_SWAPS as a simple device noise model. More...

Namespaces

namespace  aas
 
namespace  CircPool
 
namespace  graphs
 Computation of Articulation Points (APs) on undirected graphs.
 
namespace  internal
 
namespace  test_Ops
 
namespace  tket_sim
 
namespace  Transforms
 
namespace  WeightedSubgraphMonomorphism
 
namespace  zx
 

Classes

class  AASLabellingMethod
 
class  AASRouteError
 
class  AASRouteRoutingMethod
 
class  AbstractSquasher
 Abstract Squasher interface. More...
 
class  Architecture
 
class  ArchitectureBase
 Generic architecture class. More...
 
class  ArchitectureInvalidity
 
class  ArchitectureMapping
 Intended for use with TokenSwapping. More...
 
class  BadCommand
 
class  BadOpType
 Operation type not valid in the current context. More...
 
class  BarrierOp
 
class  BasePass
 
struct  BestTsaWithArch
 A simple wrapper around BestFullTsa from TokenSwapping, using Architecture objects directly to find distances and neighbours. More...
 
class  Bit
 Location holding a bit. More...
 
struct  BoolPauli
 Boolean encoding of Pauli <x, z> = <false, false> ==> I <x, z> = <false, true> ==> Z <x, z> = <true, false> ==> X <x, z> = <true, true> ==> Y. More...
 
struct  BoundaryElement
 
class  Box
 Abstract class for an operation from which a circuit can be extracted. More...
 
class  BoxDecomposition
 
class  BoxDecompositionRoutingMethod
 
class  ChoiMixTableau
 
class  CircBox
 Operation defined as a circuit. More...
 
class  CircToPhasePolyConversion
 this class realises the conversion all sub circuits of a given circuits which contains only CX+Rz to a PhasePolyBox. More...
 
class  Circuit
 A circuit. More...
 
class  CircuitInequality
 
class  CircuitInvalidity
 
class  ClassicalEvalOp
 
class  ClassicalOp
 A purely classical operation. More...
 
class  ClassicalTransformOp
 A general classical operation where all inputs are also outputs. More...
 
class  ClExpr
 A classical expression. More...
 
class  ClExprOp
 
class  ClExprWiringError
 
class  CliffordCircuitPredicate
 
class  CliffordReductionPass
 
class  CliffordReductionPassTester
 a simple friend class of CliffordReductionPass used for testing private member functions More...
 
struct  ClRegVar
 A register variable within an expression. More...
 
class  Command
 
class  CommutableMeasuresPredicate
 Asserts that any internal measurements can be commuted to the end of the circuit. More...
 
class  CompilationUnit
 
class  CompositeGateDef
 
class  Conditional
 Decorates another op, adding a QASM-style classical condition. More...
 
class  ConjugationBox
 Box to express computations that follow the compute-action-uncompute pattern. More...
 
class  ConnectivityPredicate
 
class  CopyBitsOp
 An operation to copy some bit values. More...
 
class  CustomGate
 
struct  CutFrontier
 
class  CXMaker
 
class  Cycle
 
struct  CycleCom
 
class  CycleFinder
 
struct  CycleHistory
 
class  DefaultRegisterPredicate
 
struct  DependencyEdgeProperties
 
class  DeviceCharacterisation
 
class  DiagMatrix
 
class  DiagonalBox
 Box to synthesise a diagonal operator. More...
 
class  DirectednessPredicate
 
class  DistancesFromArchitecture
 Directly get distances from an architecture object, but evaluated lazily. More...
 
class  DummyBox
 A placeholder operation that holds resource data. More...
 
class  DummyBoxNotDecomposable
 Exception indicating that dummy boxes cannot be decomposed. More...
 
struct  EdgeProperties
 Description of an edge in a circuit, representing a directional wire. More...
 
class  ExpBox
 Two-qubit operation defined in terms of a hermitian matrix and a phase. More...
 
class  ExplicitModifierOp
 A modifying operation defined explicitly by a truth table. More...
 
class  ExplicitPredicateOp
 A predicate defined explicitly by a truth table. More...
 
class  FlowOp
 
class  FrameRandomisation
 
class  FrameRandomisationTester
 
class  FullyConnected
 
class  Gate
 
class  GateSetPredicate
 Asserts that all operations are in the specified set of types. More...
 
struct  GateSpec
 
struct  GateUnitaryMatrix
 Functions to return the unitary matrix which a gate represents. More...
 
struct  GateUnitaryMatrixError
 We do not wish to couple tightly to exception classes elsewhere. More...
 
class  GraphPlacement
 
class  IncompatibleCompilerPasses
 
class  IncorrectPredicate
 
struct  InteractionMatch
 Represents a position to which two 2q Clifford gadgets could be commuted to Assumes: More...
 
struct  InteractionPoint
 Represents a position that one port of a 2qb Clifford gadget could be commuted to (towards the end of the circuit). More...
 
class  InvalidParameterCount
 Wrong number of parameters for an operation. More...
 
class  InvalidUnitConversion
 Conversion invalid. More...
 
class  JsonError
 
class  LexicographicalComparison
 A class for running lexicographical comparisons of SWAP gates for some architecture and set of interacting qubits. More...
 
class  LexicographicalComparisonError
 
class  LexiLabellingMethod
 
class  LexiRoute
 A class for modifiying a Circuit held in a MappingFrontier object with either an Architecture permitted single SWAP gate or BRIDGE gate. More...
 
class  LexiRouteError
 
class  LexiRouteRoutingMethod
 
class  LinePlacement
 
struct  MappingFrontier
 
class  MappingFrontierError
 
class  MappingManager
 
class  MappingManagerError
 
class  MaxNClRegPredicate
 Asserts that the circuit only contains N classical registers or less. More...
 
class  MaxNQubitsPredicate
 
class  MaxTwoQubitGatesPredicate
 
class  MeasurementSetup
 MeasurementSetup Captures an expectation value experiment. More...
 
class  MetaOp
 
class  MidCircuitMeasurementNotAllowed
 
class  MissingEdge
 
class  MissingVertex
 
class  ModifyingOp
 A classical operation with one output bit which is also an input bit. More...
 
class  MultiBitOp
 A classical operation applied simultaneously to multiple bits. More...
 
class  MultiGateReorder
 
class  MultiGateReorderRoutingMethod
 
class  MultiplexedRotationBox
 Multiplexed single-axis rotations. More...
 
class  MultiplexedTensoredU2Box
 Multiplexed-Tensored-U2 gate. More...
 
class  MultiplexedU2Box
 Multiplexed U2 gate. More...
 
struct  MultiplexedU2Commands
 
class  MultiplexorBox
 Multiplexed ops. More...
 
class  NeighbourPlacements
 Given a placement map generates n nearby placement maps. More...
 
class  NeighboursFromArchitecture
 Stores and returns upon request the adjacent vertices to a given vertex on a graph, using an underlying Architecture object. More...
 
struct  no_coeff_t
 A trivial option for PauliTensor to represent Pauli strings up to global scalar. More...
 
class  NoBarriersPredicate
 Asserts that the circuit contains no OpType::Barrier. More...
 
class  NoClassicalBitsPredicate
 
class  NoClassicalControlPredicate
 Asserts that there are no conditional gates in the circuit. More...
 
class  Node
 Architectural qubit location. More...
 
class  NoFastFeedforwardPredicate
 
class  NoiseAwarePlacement
 
class  NoMidMeasurePredicate
 Asserts that any measurements occur at the end of the circuit. More...
 
class  NormalisedTK2Predicate
 Asserts that all TK2 gates are normalised. More...
 
class  NoSymbolsPredicate
 Asserts that no gates in the circuit have symbolic parameters. More...
 
class  NoWireSwapsPredicate
 
class  Op
 Abstract class representing an operation type. More...
 
class  OpDesc
 Operation descriptor. More...
 
class  OpJsonFactory
 
struct  OpTypeInfo
 General information about an OpType. More...
 
class  PassNotSerializable
 
class  PauliExpBox
 Operation defined as the exponential of a tensor of Pauli operators. More...
 
class  PauliExpBoxInvalidity
 
class  PauliExpCommutingSetBox
 
class  PauliExpPairBox
 
class  PauliFrameRandomisation
 
struct  PauliGadgetProperties
 
class  PauliGraph
 Dependency graph of a circuit wrt Pauli Gadgets. More...
 
class  PauliPartitionerGraph
 A helper class for converting QubitOperator into PauliACGraphs and then colouring the PauliACGraph using some method. More...
 
class  PauliTensor
 PauliTensor<PauliContainer, CoeffType> More...
 
class  PhasePolyBox
 A PhasePolyBox is capable of representing arbitrary Circuits made up of CNOT and RZ, as a PhasePolynomial plus a boolean matrix representing an additional linear transformation. More...
 
class  Placement
 
class  PlacementPredicate
 
struct  PostConditions
 
class  PowerCycle
 
class  Predicate
 
class  PredicateNotSerializable
 
class  PredicateOp
 A classical operation with single output bit. More...
 
class  ProjectorAssertionBox
 
class  QControlBox
 Wraps another quantum op, adding control qubits. More...
 
class  Qubit
 Location holding a qubit. More...
 
class  QubitGraph
 Instance of DirectedGraph to hold dependencies between Qubit UnitID objects as given from some Circuit. More...
 
class  RangePredicateOp
 A predicate defined by a range of values in binary encoding. More...
 
class  RepeatPass
 
class  RepeatUntilSatisfiedPass
 
class  RepeatWithMetricPass
 
struct  ResourceBounds
 
struct  ResourceData
 
struct  RevInteractionPoint
 Represents a position that one port of a 2qb Clifford gadget could be commuted to (towards the start of the circuit). More...
 
class  RingArch
 
class  Rotation
 A faithful representation of SU(2). More...
 
class  RoutingMethod
 
class  RoutingMethodCircuit
 
class  SequencePass
 
class  SetBitsOp
 An operation to set some bits to specified values. More...
 
class  SimpleOnly
 
class  SingleQubitSquash
 Squashes single qubit gates using given Squasher. More...
 
class  SliceIterator
 
class  SquareGrid
 
class  StabiliserAssertionBox
 
class  StandardPass
 
class  StatePreparationBox
 Box to synthesise a statevector. More...
 
struct  Subcircuit
 Structure to describe a convex region of the interaction graph. More...
 
struct  SubgraphMonomorphisms
 A simple wrapper around the Weighted Subgraph Monomorphism code. More...
 
class  SubstitutionFailure
 
class  SymbolsNotSupported
 Exception indicating that symbolic values are not supported. More...
 
struct  SymCompareLess
 
class  SymplecticTableau
 
struct  SymTable
 Utility class for accessing the global symbol table. More...
 
struct  TagEdge
 
struct  TagID
 
struct  TagIn
 
struct  TagKey
 
struct  TagOut
 
struct  TagReg
 
struct  TagSeq
 
struct  TagSource
 
struct  TagType
 
struct  TagValue
 
class  TermSequenceBox
 
class  ToffoliBox
 Box to synthesise a state permutation. More...
 
class  Transform
 A transformation of a circuit that preserves its semantics. More...
 
struct  TraversalPoint
 
struct  unit_bimaps_t
 A pair of ("initial" and "final") correspondences between unit IDs. More...
 
class  Unitary1qBox
 One-qubit operation defined as a unitary matrix. More...
 
class  Unitary2qBox
 Two-qubit operation defined as a unitary matrix (ILO-BE) More...
 
class  Unitary3qBox
 Three-qubit operation defined as a unitary matrix (ILO-BE) More...
 
class  UnitaryRevTableau
 
class  UnitaryTableau
 
class  UnitaryTableauBox
 Encapsulation of a unitary stabilizer tableau as a Box to use within a circuit. More...
 
class  UnitID
 Location holding a bit or qubit of information. More...
 
class  UniversalFrameRandomisation
 
class  UnknownPauliPartitionStrat
 
class  UnsatisfiedPredicate
 
class  Unsupported
 
class  UserDefinedPredicate
 
struct  VertexProperties
 Description of a node in a circuit, representing some operation. More...
 
class  WasmNode
 WASM UID. More...
 
class  WASMOp
 Op containing a classical wasm function call. More...
 
class  WasmState
 Location holding a wasm UID. More...
 
class  WiredClExpr
 A classical expression defined over a sequence of bits. More...
 

Concepts

concept  arithmetic
 

Typedefs

typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS > cube_graph_t
 
typedef boost::graph_traits< cube_graph_t >::vertex_descriptor perm_vert_t
 
typedef std::vector< std::vector< bool > > cycle_permutation_t
 
typedef std::vector< transposition_t > cycle_transposition_t
 
typedef std::vector< std::pair< std::vector< bool >, unsigned > > gray_code_t
 
typedef std::pair< VertPort, ZXPortTypeTypedVertPort
 
typedef std::pair< ZXVert, std::optional< unsigned > > ZXVertPort
 
typedef std::vector< ZXVertPortZXVertPortVec
 
typedef boost::bimap< ZXVert, VertexBoundaryVertMap
 
using RelabelledPatternGraph = RelabelledGraphWSM< Qubit, QubitGraph::UndirectedConnGraph >
 
using RelabelledTargetGraph = RelabelledGraphWSM< Node, Architecture::UndirectedConnGraph >
 
using BimapValue = boost::bimap< Qubit, Node >::value_type
 
using dist_vec = graphs::dist_vec
 
typedef std::shared_ptr< ArchitectureArchitecturePtr
 
typedef std::pair< Edge, Edgeedge_pair_t
 
typedef double gate_error_t
 
typedef double readout_error_t
 
typedef std::map< Node, gate_error_tavg_node_errors_t
 
typedef std::map< Node, readout_error_tavg_readout_errors_t
 
typedef std::map< std::pair< Node, Node >, gate_error_tavg_link_errors_t
 
typedef std::map< OpType, gate_error_top_errors_t
 
typedef std::map< Node, op_errors_top_node_errors_t
 
typedef std::map< std::pair< Node, Node >, op_errors_top_link_errors_t
 
typedef std::shared_ptr< CompositeGateDefcomposite_def_ptr_t
 
typedef std::vector< EdgeVecBundleVec
 
typedef std::vector< SliceSliceVec
 
typedef std::vector< VertPortQPathDetailed
 
typedef std::unordered_map< Vertex, Vertexvertex_map_t
 
typedef std::map< Edge, Edgeedge_map_t
 
typedef boost::multi_index::multi_index_container< BoundaryElement, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< TagID >, boost::multi_index::member< BoundaryElement, UnitID, &BoundaryElement::id_ > >, boost::multi_index::ordered_unique< boost::multi_index::tag< TagIn >, boost::multi_index::member< BoundaryElement, Vertex, &BoundaryElement::in_ > >, boost::multi_index::ordered_unique< boost::multi_index::tag< TagOut >, boost::multi_index::member< BoundaryElement, Vertex, &BoundaryElement::out_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< TagType >, boost::multi_index::const_mem_fun< BoundaryElement, UnitType, &BoundaryElement::type > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< TagReg >, boost::multi_index::const_mem_fun< BoundaryElement, std::string, &BoundaryElement::reg_name > > > > boundary_t
 
typedef std::unordered_map< unsigned, unsigned > permutation_t
 
typedef boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, boost::property< boost::vertex_index_t, std::size_t, VertexProperties >, EdgePropertiesDAG
 Graph representing a circuit, with operations as nodes.
 
typedef boost::graph_traits< DAG >::vertex_descriptor Vertex
 
typedef boost::graph_traits< DAG >::vertex_iterator V_iterator
 
typedef std::unordered_set< VertexVertexSet
 
typedef std::vector< VertexVertexVec
 
typedef std::list< VertexVertexList
 
typedef std::unordered_map< Vertex, std::size_t > IndexMap
 
typedef boost::adj_list_vertex_property_map< DAG, std::size_t, std::size_t &, boost::vertex_index_t > VIndex
 
typedef std::pair< std::size_t, VertexIVertex
 A vertex with an index.
 
typedef boost::graph_traits< DAG >::edge_descriptor Edge
 
typedef boost::graph_traits< DAG >::edge_iterator E_iterator
 
typedef DAG::in_edge_iterator E_in_iterator
 
typedef DAG::out_edge_iterator E_out_iterator
 
typedef std::set< EdgeEdgeSet
 
typedef std::vector< EdgeEdgeVec
 
typedef std::list< EdgeEdgeList
 
typedef std::pair< Vertex, port_tVertPort
 
typedef std::map< std::vector< bool >, Op_ptrctrl_op_map_t
 Map bitstrings to Ops.
 
typedef std::map< std::vector< bool >, std::vector< Op_ptr > > ctrl_tensored_op_map_t
 Map bitstrings to tensored Ops.
 
typedef Eigen::VectorXcd StateVector
 
typedef VertexVec Slice
 
typedef sequenced_map_t< UnitID, Edgeunit_frontier_t
 
typedef sequenced_map_t< Bit, EdgeVecb_frontier_t
 
typedef std::map< std::vector< bool >, std::vector< bool > > state_perm_t
 Map bitstrings to bitstrings.
 
typedef std::map< std::vector< bool >, ExprPhasePolynomial
 PhasePolynomial is just a sequence of parities: that is, terms of the form \( e^{\alpha \bigotimes Z} \), where Z is a Pauli Z.
 
typedef std::pair< std::vector< bool >, Exprphase_term_t
 
typedef std::map< SpPauliString, ExprQubitOperator
 QubitOperator, defined to be useful for diagonalisation and partitioning.
 
typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, SpPauliStringPauliACGraph
 A PauliACGraph is a graph where each vertex is a Pauli tensor, and an edge corresponds to anticommuting tensors.
 
typedef boost::graph_traits< PauliACGraph >::vertex_descriptor PauliACVertex
 
typedef std::shared_ptr< const GateGate_ptr
 
typedef std::map< Node, Nodeinteracting_nodes_t
 
typedef std::pair< Node, Nodeswap_t
 
typedef std::set< swap_tswap_set_t
 
typedef std::vector< std::size_t > lexicographical_distances_t
 
typedef sequenced_bimap_t< UnitID, VertPortunit_vertport_frontier_t
 
typedef std::shared_ptr< MappingFrontierMappingFrontier_ptr
 
typedef std::shared_ptr< const RoutingMethodRoutingMethodPtr
 
typedef struct tket::ClRegVar ClRegVar
 A register variable within an expression.
 
typedef std::variant< ClBitVar, ClRegVarClExprVar
 A (bit or register) variable within an expression.
 
typedef std::variant< uint64_t, ClExprVarClExprTerm
 A term in a classical expression (either a constant or a variable)
 
typedef std::variant< ClExprTerm, ClExprClExprArg
 An argument to a classical operation in an expression.
 
typedef unsigned port_t
 A specific entry or exit port of a vertex.
 
typedef std::shared_ptr< const OpOp_ptr
 
typedef std::vector< EdgeTypeop_signature_t
 
typedef std::optional< unsigned > OptUInt
 Optional unsigned integer.
 
typedef std::unordered_set< OpTypeOpTypeSet
 Set of operation types.
 
typedef std::vector< OpTypeOpTypeVector
 Vector of operation types.
 
typedef boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, boost::property< boost::vertex_index_t, int, PauliGadgetProperties >, DependencyEdgePropertiesPauliDAG
 
typedef boost::graph_traits< PauliDAG >::vertex_descriptor PauliVert
 
typedef boost::graph_traits< PauliDAG >::edge_descriptor PauliEdge
 
typedef sequence_set_t< PauliVertPauliVertSet
 
typedef sequence_set_t< PauliEdgePauliEdgeSet
 
typedef boost::adj_list_vertex_property_map< PauliDAG, int, int &, boost::vertex_index_t > PauliVIndex
 
typedef std::list< std::pair< OpType, qubit_vector_t > > Conjugations
 
typedef std::map< std::type_index, PredicatePtrPredicatePtrMap
 
typedef std::pair< const std::type_index, PredicatePtrTypePredicatePair
 
typedef std::map< std::type_index, std::pair< PredicatePtr, bool > > PredicateCache
 
typedef std::shared_ptr< BasePassPassPtr
 
typedef std::map< std::type_index, GuaranteePredicateClassGuarantees
 
typedef std::pair< PredicatePtrMap, PostConditionsPassConditions
 
typedef std::function< void(const CompilationUnit &, const nlohmann::json &)> PassCallback
 
typedef std::shared_ptr< PredicatePredicatePtr
 
typedef boost::multi_index::multi_index_container< InteractionPoint, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::tag< TagKey >, boost::multi_index::const_mem_fun< InteractionPoint, std::pair< Edge, Vertex >, &InteractionPoint::key > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< TagEdge >, boost::multi_index::member< InteractionPoint, Edge, &InteractionPoint::e > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< TagSource >, boost::multi_index::member< InteractionPoint, Vertex, &InteractionPoint::source > > > > interaction_table_t
 Stores all current InteractionPoints encountered.
 
typedef std::complex< double > Complex
 Complex number.
 
typedef std::tuple< Eigen::MatrixXcd, Eigen::MatrixXcd, Eigen::MatrixXcd, Eigen::MatrixXcd, Eigen::MatrixXd, Eigen::MatrixXd > csd_t
 Cosine-sine decomposition.
 
typedef SymEngine::Expression Expr
 Representation of a phase as a multiple of \( \pi \).
 
typedef SymEngine::RCP< const SymEngine::Basic > ExprPtr
 Shared pointer to an Expr.
 
typedef SymEngine::RCP< const SymEngine::Symbol > Sym
 Shared pointer to a free symbol.
 
typedef std::set< Sym, SymCompareLessSymSet
 
typedef std::map< Sym, Expr, SymEngine::RCPBasicKeyLess > symbol_map_t
 Map from symbols to expressions.
 
typedef std::vector< std::deque< bool > > GrayCode
 
typedef Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic > MatrixXb
 
typedef Eigen::Matrix< bool, Eigen::Dynamic, 1 > VectorXb
 
typedef Eigen::Matrix< bool, 2, 1 > Vector2b
 
typedef Eigen::Matrix< std::complex< double >, 8, 8 > Matrix8cd
 
typedef Eigen::Triplet< std::complex< double > > TripletCd
 It is sometimes more convenient to deal with Triplets directly, rather than sparse matrices.
 
typedef Eigen::SparseMatrix< std::complex< double > > SparseMatrixXcd
 
typedef Eigen::SparseMatrix< Complex, Eigen::ColMajor > CmplxSpMat
 
typedef unsigned quarter_turns_t
 A fourth root of unity {1, i, -1, -i}, represented as an unsigned integer giving the power of i.
 
typedef std::map< Qubit, PauliQubitPauliMap
 A sparse, Qubit-indexed Pauli container.
 
typedef std::vector< PauliDensePauliMap
 A dense, unsigned-indexed Pauli container.
 
typedef PauliTensor< QubitPauliMap, no_coeff_tSpPauliString
 
typedef PauliTensor< DensePauliMap, no_coeff_tPauliString
 
typedef PauliTensor< QubitPauliMap, quarter_turns_tSpPauliStabiliser
 
typedef PauliTensor< DensePauliMap, quarter_turns_tPauliStabiliser
 
typedef PauliTensor< QubitPauliMap, ComplexSpCxPauliTensor
 
typedef PauliTensor< DensePauliMap, ComplexCxPauliTensor
 
typedef PauliTensor< QubitPauliMap, ExprSpSymPauliTensor
 
typedef PauliTensor< DensePauliMap, ExprSymPauliTensor
 
typedef std::vector< PauliStabiliserPauliStabiliserVec
 
template<typename A , typename B >
using sequenced_bimap_t = boost::multi_index::multi_index_container< std::pair< A, B >, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< TagKey >, boost::multi_index::member< std::pair< A, B >, A, &std::pair< A, B >::first > >, boost::multi_index::ordered_unique< boost::multi_index::tag< TagValue >, boost::multi_index::member< std::pair< A, B >, B, &std::pair< A, B >::second > >, boost::multi_index::sequenced< boost::multi_index::tag< TagSeq > > > >
 
template<typename A , typename B >
using sequenced_map_t = boost::multi_index::multi_index_container< std::pair< A, B >, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< TagKey >, boost::multi_index::member< std::pair< A, B >, A, &std::pair< A, B >::first > >, boost::multi_index::sequenced< boost::multi_index::tag< TagSeq > > > >
 
template<typename T >
using sequence_set_t = boost::multi_index::multi_index_container< T, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< TagKey >, boost::multi_index::identity< T > >, boost::multi_index::sequenced< boost::multi_index::tag< TagSeq > > > >
 
typedef std::pair< UnitType, unsigned > register_info_t
 The type and dimension of a register.
 
typedef std::optional< register_info_topt_reg_info_t
 
typedef boost::bimap< UnitID, UnitIDunit_bimap_t
 A correspondence between two sets of unit IDs.
 
typedef std::vector< UnitIDunit_vector_t
 
typedef std::map< UnitID, UnitIDunit_map_t
 
typedef std::set< UnitIDunit_set_t
 
typedef std::vector< Qubitqubit_vector_t
 
typedef std::map< Qubit, Qubitqubit_map_t
 
typedef std::vector< Bitbit_vector_t
 
typedef std::map< Bit, Bitbit_map_t
 
typedef std::set< Nodenode_set_t
 
typedef std::vector< Nodenode_vector_t
 
typedef std::map< unsigned, UnitIDregister_t
 A register of locations sharing the same name.
 

Enumerations

enum class  VertexType { Quantum , Classical , Measure }
 
enum class  RecursionNodeType { Left = 0 , Right = 1 , Root = 2 }
 Indicates whether a recursion step in recursive_demultiplex_rotation is either a left child, a right child, or the root. More...
 
enum class  ZXPortType { In , Out }
 
enum  ReverseType { dagger = 1 , transpose = 2 }
 
enum class  PortType { Source , Target }
 Whether a vertex port is out-going (source) or in-coming (target) More...
 
enum class  ToffoliBoxSynthStrat { Matching , Cycle }
 Strategies for synthesising ToffoliBoxes Matching: use multiplexors to perform parallel swaps on hypercubes Cycle: use CnX gates to perform transpositions. More...
 
enum class  PauliPartitionStrat { NonConflictingSets , CommutingSets }
 A choice of strategies to partition Pauli tensors into sets. More...
 
enum class  GraphColourMethod { Lazy , LargestFirst , Exhaustive }
 A choice of methods to perform graph colouring for Pauli partitioning. More...
 
enum class  ClOp {
  INVALID , BitAnd , BitOr , BitXor ,
  BitEq , BitNeq , BitNot , BitZero ,
  BitOne , RegAnd , RegOr , RegXor ,
  RegEq , RegNeq , RegNot , RegZero ,
  RegOne , RegLt , RegGt , RegLeq ,
  RegGeq , RegAdd , RegSub , RegMul ,
  RegDiv , RegPow , RegLsh , RegRsh ,
  RegNeg
}
 An function acting on bits or bit registers. More...
 
enum class  EdgeType { Quantum , Classical , Boolean , WASM }
 Type of a wire in a circuit or input to an op. More...
 
enum class  OpType {
  Input , Output , Create , Discard ,
  ClInput , ClOutput , WASMInput , WASMOutput ,
  Barrier , Label , Branch , Goto ,
  Stop , ClassicalTransform , WASM , SetBits ,
  CopyBits , RangePredicate , ExplicitPredicate , ExplicitModifier ,
  MultiBit , Phase , Z , X ,
  Y , S , Sdg , T ,
  Tdg , V , Vdg , SX ,
  SXdg , H , Rx , Ry ,
  Rz , U3 , U2 , U1 ,
  GPI , GPI2 , AAMS , TK1 ,
  TK2 , CX , CY , CZ ,
  CH , CV , CVdg , CSX ,
  CSXdg , CS , CSdg , CRz ,
  CRx , CRy , CU1 , CU3 ,
  PhaseGadget , CCX , SWAP , CSWAP ,
  BRIDGE , noop , Measure , Collapse ,
  Reset , ECR , ISWAP , PhasedX ,
  NPhasedX , ZZMax , XXPhase , YYPhase ,
  ZZPhase , XXPhase3 , ESWAP , FSim ,
  Sycamore , ISWAPMax , PhasedISWAP , CnRy ,
  CnRx , CnRz , CnX , CnZ ,
  CnY , CircBox , Unitary1qBox , Unitary2qBox ,
  Unitary3qBox , ExpBox , PauliExpBox , PauliExpPairBox ,
  PauliExpCommutingSetBox , TermSequenceBox , CliffBox , CustomGate ,
  PhasePolyBox , QControlBox , MultiplexorBox , MultiplexedRotationBox ,
  MultiplexedU2Box , MultiplexedTensoredU2Box , StatePreparationBox , DiagonalBox ,
  ConjugationBox , Conditional , ProjectorAssertionBox , StabiliserAssertionBox ,
  ToffoliBox , UnitaryTableauBox , DummyBox , ClExpr
}
 Named operation types. More...
 
enum class  Guarantee { Clear , Preserve }
 
enum class  SafetyMode { Audit , Default , Off }
 
enum class  BasisOrder { ilo , dlo }
 Enum for readout basis and ordering. More...
 
enum  Pauli { I = 0 , X , Y , Z }
 Symbols for the Pauli operators (and identity) More...
 
enum class  CXConfigType { Snake , Tree , Star , MultiQGate }
 Whenever a decomposition choice of Pauli gadgets is presented, users may use either Snake (a.k.a. More...
 
enum class  UnitType { Qubit , Bit , WasmState }
 Type of information held. More...
 

Functions

int tri_lexicographical_comparison (const std::vector< std::size_t > &dist1, const std::vector< std::size_t > &dist2)
 
void to_json (nlohmann::json &j, const Architecture::Connection &link)
 
void from_json (const nlohmann::json &j, Architecture::Connection &link)
 
void to_json (nlohmann::json &j, const Architecture &ar)
 
void from_json (const nlohmann::json &j, Architecture &ar)
 
void to_json (nlohmann::json &j, const FullyConnected &ar)
 
void from_json (const nlohmann::json &j, FullyConnected &ar)
 
void to_json (nlohmann::json &j, const DeviceCharacterisation &dc)
 
void from_json (const nlohmann::json &j, DeviceCharacterisation &dc)
 
void add_noop_frames (std::vector< Cycle > &cycles, Circuit &circ)
 
std::vector< std::vector< OpTypeVector > > get_all_frame_permutations (const unsigned &max_frame_size, const OpTypeSet &frame_types)
 
std::vector< std::vector< OpTypeVector > > combine_vectors (const std::vector< std::vector< OpTypeVector > > &vec_0, const std::vector< OpTypeVector > &vec_1)
 
std::vector< std::vector< OpTypeVector > > get_all_permutation_combinations (const std::vector< unsigned > &frame_sizes, const std::vector< std::vector< OpTypeVector > > &frame_permutations)
 
std::pair< std::vector< unsigned >, unsigned > get_frame_sizes (const std::vector< Cycle > &cycles)
 
std::tuple< Circuit, std::vector< bool > > projector_assertion_synthesis (const Eigen::MatrixXcd &P)
 Synthesise an assertion circuit from an arbitrary 2x2, 4x4 or 8x8 projector matrix.
 
std::tuple< Circuit, std::vector< bool > > stabiliser_assertion_synthesis (const PauliStabiliserVec &paulis)
 Synthesise an assertion circuit from a list of Paulis strings with +/-1 coefficients.
 
std::ostream & operator<< (std::ostream &out, const Circuit &circ)
 
nlohmann::json core_box_json (const Box &box)
 
void to_json (nlohmann::json &j, const composite_def_ptr_t &cdef)
 
void from_json (const nlohmann::json &j, composite_def_ptr_t &cdef)
 
void to_json (nlohmann::json &j, const Circuit &circ)
 
void from_json (const nlohmann::json &j, Circuit &circ)
 
Eigen::Matrix2cd get_matrix (const Circuit &circ, const Vertex &vert)
 Convert a vertex holding a TK1 operation to its corresponding matrix.
 
Eigen::Matrix2cd get_matrix_from_circ (const Circuit &circ)
 Convert a one-qubit circuit of TK1 operations to its corresponding matrix.
 
Eigen::Matrix4cd get_matrix_from_2qb_circ (const Circuit &circ)
 Convert a two-qubit circuit to its corresponding matrix.
 
Circuit two_qubit_canonical (const Eigen::Matrix4cd &U, OpType target_2qb_gate=OpType::TK2)
 Convert a 4x4 unitary matrix optimally to a corresponding circuit.
 
std::pair< Circuit, Complexdecompose_2cx_VD (const Eigen::Matrix4cd &U)
 Decompose a unitary matrix into a 2-CX circuit following a diagonal operator.
 
std::pair< Circuit, Complexdecompose_2cx_DV (const Eigen::Matrix4cd &U)
 Decompose a unitary matrix into a 2-CXs preceding a diagonal operator.
 
Circuit phase_gadget (unsigned n_qubits, const Expr &angle, CXConfigType cx_config=CXConfigType::Snake)
 Construct a phase gadget.
 
Circuit pauli_gadget (SpSymPauliTensor pauli, CXConfigType cx_config=CXConfigType::Snake)
 Construct a 'Pauli gadget' corresponding to a tensor of Pauli operators.
 
Circuit pauli_gadget_pair (SpSymPauliTensor paulis0, SpSymPauliTensor paulis1, CXConfigType cx_config=CXConfigType::Snake)
 Construct a circuit realising a pair of Pauli gadgets with the fewest two-qubit gates.
 
void replace_CX_with_TK2 (Circuit &c)
 Utility function to replace all CX gates with TK2 and single-qubit gates.
 
Circuit with_TK2 (Gate_ptr op)
 Express a gate as a circuit using TK2 as the only multi-qubit gate.
 
Circuit with_CX (Gate_ptr op)
 Express a gate as a circuit using CX as the only multi-qubit gate.
 
Circuit with_controls (const Circuit &c, unsigned n_controls=1)
 Construct a controlled version of a given circuit.
 
std::tuple< Circuit, std::array< Expr, 3 >, Circuitnormalise_TK2_angles (Expr a, Expr b, Expr c)
 Get normalised TK2 angles and local change of basis for normalisation.
 
void to_json (nlohmann::json &j, const Command &com)
 
void from_json (const nlohmann::json &j, Command &com)
 
bool is_valid (const DAG &G)
 Check that the DAG satisfies the requirements of the Circuit class.
 
void add_latex_for_command (LatexContext &context, const Command &command)
 
boundary_t::iterator boundary_elem (const Circuit &circ, const UnitID &unit)
 
Circuit operator* (const Circuit &c1, const Circuit &c2)
 
Circuit operator>> (const Circuit &ci1, const Circuit &ci2)
 
Circuit recursive_conditional_circuit (const Op_ptr &op, const Circuit &base_circ)
 
void add_cx_u1 (Circuit &circ, const std::vector< MultiplexedU2Commands > &m_u2_decomps, unsigned n_controls_, unsigned n_targets_)
 
std::pair< ctrl_op_map_t, Eigen::VectorXcd > disentangle_final_qubit_from_diagonal (const Eigen::VectorXcd &full_diag, unsigned n_controls_)
 
void add_multi_rz (Circuit &circ, const std::vector< ctrl_op_map_t > &all_multiplexed_rz, unsigned n_controls_, unsigned n_targets_)
 
Eigen::VectorXcd combine_diagonals (const std::vector< Eigen::VectorXcd > &all_diags, unsigned n_controls_, unsigned n_targets_)
 
void from_json (const nlohmann::json &j, Op_ptr &op)
 
DensePauliMap pad_sparse_pauli_map (const QubitPauliMap &sparse_string, size_t size)
 
void append_single_pauli_gadget_as_pauli_exp_box (Circuit &circ, const SpSymPauliTensor &pauli, CXConfigType cx_config)
 Constructs a PauliExpBox for a single pauli gadget and appends it to a circuit.
 
void append_pauli_gadget_pair_as_box (Circuit &circ, const SpSymPauliTensor &pauli0, const SpSymPauliTensor &pauli1, CXConfigType cx_config)
 Constructs a PauliExpPairBox for a pair of pauli gadgets and appends it to a circuit.
 
void append_commuting_pauli_gadget_set_as_box (Circuit &circ, const std::list< SpSymPauliTensor > &gadgets, CXConfigType cx_config)
 Constructs a PauliExpCommutingSetBox for a set of mutually commuting pauli gadgets and appends it to a circuit.
 
void to_json (nlohmann::json &j, const ResourceData &data)
 
void from_json (const nlohmann::json &j, ResourceData &data)
 
Circuit three_qubit_synthesis (const Eigen::MatrixXcd &U)
 Synthesise a 3-qubit circuit from an arbitrary 8x8 unitary.
 
Circuit three_qubit_tk_synthesis (const Eigen::MatrixXcd &U)
 Synthesise a 3-qubit circuit from an arbitrary 8x8 unitary.
 
Eigen::MatrixXcd get_3q_unitary (const Circuit &c)
 Convert a 3-qubit circuit to its corresponding unitary matrix.
 
Circuit get_bitstring_circuit (const std::vector< bool > &bitstring, const unsigned &target, const unsigned &n_qubits)
 
std::ostream & operator<< (std::ostream &os, const ChoiMixTableau &tab)
 
void to_json (nlohmann::json &j, const ChoiMixTableau::TableauSegment &seg)
 
void from_json (const nlohmann::json &j, ChoiMixTableau::TableauSegment &seg)
 
void to_json (nlohmann::json &j, const ChoiMixTableau &tab)
 
void from_json (const nlohmann::json &j, ChoiMixTableau &tab)
 
std::ostream & operator<< (std::ostream &os, const SymplecticTableau &tab)
 
void to_json (nlohmann::json &j, const SymplecticTableau &tab)
 
void from_json (const nlohmann::json &j, SymplecticTableau &tab)
 
std::ostream & operator<< (std::ostream &os, const UnitaryTableau &tab)
 
void to_json (nlohmann::json &j, const UnitaryTableau &tab)
 
void from_json (const nlohmann::json &j, UnitaryTableau &tab)
 
std::ostream & operator<< (std::ostream &os, const UnitaryRevTableau &tab)
 
void to_json (nlohmann::json &j, const UnitaryRevTableau &tab)
 
void from_json (const nlohmann::json &j, UnitaryRevTableau &tab)
 
ChoiMixTableau circuit_to_cm_tableau (const Circuit &circ)
 Construct a ChoiMixTableau for a given circuit.
 
std::pair< Circuit, qubit_map_tcm_tableau_to_exact_circuit (const ChoiMixTableau &tab, CXConfigType cx_config=CXConfigType::Snake)
 Constructs a circuit producing the same effect as a ChoiMixTableau.
 
std::pair< Circuit, qubit_map_tcm_tableau_to_unitary_extension_circuit (const ChoiMixTableau &tab, const std::vector< Qubit > &init_names={}, const std::vector< Qubit > &post_names={}, CXConfigType cx_config=CXConfigType::Snake)
 We define a unitary extension of a ChoiMixTableau to be a unitary circuit whose stabilizer group contain all the rows of the ChoiMixTableau and possibly more.
 
std::ostream & operator<< (std::ostream &out, const DiagMatrix &diam)
 
PauliGraph circuit_to_pauli_graph (const Circuit &circ)
 
Circuit pauli_graph_to_pauli_exp_box_circuit_individually (const PauliGraph &pg, CXConfigType cx_config=CXConfigType::Snake)
 Synthesises a circuit equivalent to the PauliGraph by adding each pauli gadget to the circuit as a PauliExpBox individually in the order given by TopSortIterator.
 
Circuit pauli_graph_to_pauli_exp_box_circuit_pairwise (const PauliGraph &pg, CXConfigType cx_config=CXConfigType::Snake)
 Synthesises a circuit equivalent to the PauliGraph by inserting pairs of pauli gadgets as PauliExpPairBoxes into the circuit The tableau is then synthesised at the end.
 
Circuit pauli_graph_to_pauli_exp_box_circuit_sets (const PauliGraph &pg, CXConfigType cx_config=CXConfigType::Snake)
 Synthesises a circuit equivalent to the PauliGraph by building sets of mutually commuting pauli gadgets and inserting them into the circuit as PauliExpCommutingSetBoxes The tableau is then synthesised at the end.
 
Circuit gray_synth (unsigned n_qubits, const std::list< phase_term_t > &parities, const MatrixXb &linear_transformation)
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > load_dynamic_matrix (const nlohmann::json &j, std::size_t rows, std::size_t cols)
 
UnitaryTableau circuit_to_unitary_tableau (const Circuit &circ)
 Construct the tableau for a given circuit.
 
Circuit unitary_tableau_to_circuit (const UnitaryTableau &tab)
 Constructs a circuit producing the same effect as the tableau.
 
UnitaryRevTableau circuit_to_unitary_rev_tableau (const Circuit &circ)
 
Circuit unitary_rev_tableau_to_circuit (const UnitaryRevTableau &tab)
 
bool is_spiderless_optype (const OpType &optype)
 
std::pair< ZXVertPort, ZXVertPortadd_switch (ZXDiagram &zxd, const bool &on_value, const QuantumType &qtype)
 
std::pair< std::pair< ZXVertPort, ZXVertPort >, ZXVertPortVecadd_conditional_zx (ZXDiagram &zxd, const ZXVert &left, const ZXVert &right, const QuantumType &qtype)
 
std::pair< ZXVertPortVec, ZXVertPortadd_n_bit_and (ZXDiagram &zxd, unsigned n, const QuantumType &qtype)
 
BoundaryVertMap circuit_to_zx_recursive (const Circuit &circ, ZXDiagram &zxd, bool add_boundary)
 
std::pair< ZXDiagram, BoundaryVertMapcircuit_to_zx (const Circuit &circuit)
 Construct a zx diagram from a given circuit.
 
void clean_frontier (ZXDiagram &diag, ZXVertVec &frontier, Circuit &circ, std::map< ZXVert, unsigned > &qubit_map, std::map< ZXVert, ZXVert > &input_qubits)
 
ZXVertSeqSet neighbours_of_frontier (const ZXDiagram &diag, const ZXVertVec &frontier)
 
void extend_if_input (ZXDiagram &diag, const ZXVert &v, std::map< ZXVert, ZXVert > &input_qubits)
 
bool remove_all_gadgets (ZXDiagram &diag, const ZXVertVec &frontier, std::map< ZXVert, ZXVert > &input_qubits)
 
Circuit zx_to_circuit (const zx::ZXDiagram &diag)
 Takes a unitary ZX diagram in MBQC form with the promise that a gflow exists.
 
void check_easy_diagonalise (std::list< SpSymPauliTensor > &gadgets, std::set< Qubit > &qubits, Circuit &circ)
 Check whether there are any qubits which only requires a single qubit Clifford to make all Paulis I or Z.
 
std::optional< std::pair< Pauli, Pauli > > check_pair_compatibility (const Qubit &qb1, const Qubit &qb2, const std::list< SpSymPauliTensor > &gadgets)
 Given two qubits, attempt to find a basis in which a single CX will make the Paulis on one of qubits fully diagonal.
 
void greedy_diagonalise (const std::list< SpSymPauliTensor > &gadgets, std::set< Qubit > &qubits, Conjugations &conjugations, Circuit &circ, CXConfigType cx_config)
 Diagonalise a qubit greedily by finding the Pauli Gadget with the lowest residual support over the non-diagonal qubits, and apply single qubit Cliffords and CXs to make it a ZIII...I string.
 
Circuit mutual_diagonalise (std::list< SpSymPauliTensor > &gadgets, std::set< Qubit > qubits, CXConfigType cx_config)
 Diagonalise a mutually commuting set of Pauli strings.
 
void apply_conjugations (SpSymPauliTensor &qps, const Conjugations &conjugations)
 Applies Clifford conjugations to a SpSymPauliTensor.
 
std::pair< Circuit, Qubitreduce_pauli_to_z (const SpPauliStabiliser &pauli, CXConfigType cx_config)
 Given a Pauli tensor P, produces a short Clifford circuit C which maps P to Z on a single qubit, i.e.
 
std::pair< Circuit, std::optional< Qubit > > reduce_overlap_of_paulis (SpPauliStabiliser &pauli0, SpPauliStabiliser &pauli1, CXConfigType cx_config, bool allow_matching_final=false)
 Given a pair of (either commuting or anticommuting) Pauli tensors P0, P1, produces a short Clifford circuit C which maps P0 and P1 to strings which overlap on at most one qubit (which is also returned).
 
std::pair< Circuit, Qubitreduce_anticommuting_paulis_to_z_x (SpPauliStabiliser pauli0, SpPauliStabiliser pauli1, CXConfigType cx_config)
 Given a pair of anticommuting Pauli tensors P0, P1, produces a short Clifford circuit C which maps P0 to Z and P1 to X on the same qubit, i.e.
 
std::tuple< Circuit, Qubit, Qubitreduce_commuting_paulis_to_zi_iz (SpPauliStabiliser pauli0, SpPauliStabiliser pauli1, CXConfigType cx_config)
 Given a pair of commuting Pauli tensors P0, P1, produces a short Clifford circuit C which maps P0 and P1 to Z on different qubits, i.e.
 
void insert_into_gadget_map (QubitOperator &gadget_map, const PauliGadgetProperties &pgp)
 
std::list< std::list< SpPauliString > > term_sequence (const std::list< SpPauliString > &strings, PauliPartitionStrat strat, GraphColourMethod method=GraphColourMethod::Lazy)
 Partitions a QubitOperator into lists of mutually commuting gadgets.
 
Gate_ptr as_gate_ptr (Op_ptr op)
 Cast a general Op (of gate type) to a Gate.
 
Op_ptr get_op_ptr (OpType chosen_type, const Expr &param, unsigned n_qubits=0)
 Get an operation with a given type, single parameter and qubit count.
 
Op_ptr get_op_ptr (OpType chosen_type, const std::vector< Expr > &params={}, unsigned n_qubits=0)
 Get an operation from a type, vector of parameters and qubit count.
 
std::ostream & operator<< (std::ostream &os, const Rotation &q)
 
std::vector< double > tk1_angles_from_unitary (const Eigen::Matrix2cd &U)
 Construct TK1 angles and phase from matrix.
 
std::tuple< double, double, double > get_bloch_coordinate_from_state (const Complex &a, const Complex &b)
 Get the bloch sphere coordinate of a 1-qubit state.
 
Eigen::Matrix2cd get_matrix_from_tk1_angles (std::vector< Expr > params)
 Construct matrix from TK1 angles and phase.
 
bool is_vertex_CX (const Circuit &circ_, const Vertex &v)
 
UnitID get_unitid_from_unit_frontier (const std::shared_ptr< unit_vertport_frontier_t > &u_frontier, const VertPort &vp)
 unit_vertport_frontier_t is <UnitID, VertPort>, helper function returns UnitID corresponding to given VertPort
 
std::shared_ptr< unit_frontier_tfrontier_convert_vertport_to_edge (const Circuit &circuit, const std::shared_ptr< unit_vertport_frontier_t > &u_frontier)
 linear_boundary stored as vertport so that correct edge can be recovered after subcircuit substitution method uses Vertex and port_t and Circuit::get_nth_out_edge to generate unit_frontier_t object
 
EdgeVec convert_u_frontier_to_edges (const unit_frontier_t &u_frontier)
 convert_u_frontier_to_edges Subcircuit requires EdgeVec, not unit_frontier_t as boundary information Helper Functions to convert types
 
EdgeVec convert_b_frontier_to_edges (const b_frontier_t &b_frontier)
 
void to_json (nlohmann::json &j, const RoutingMethod &rm)
 
void from_json (const nlohmann::json &, RoutingMethod &rm)
 
void to_json (nlohmann::json &j, const std::vector< RoutingMethodPtr > &rmp_v)
 
void from_json (const nlohmann::json &j, std::vector< RoutingMethodPtr > &rmp_v)
 
bool respects_connectivity_constraints (const Circuit &circ, const Architecture &arch, bool directed, bool bridge_allowed=false)
 Check that the circuit respects architectural constraints.
 
MeasurementSetup measurement_reduction (const std::list< SpPauliString > &strings, PauliPartitionStrat strat, GraphColourMethod method=GraphColourMethod::Lazy, CXConfigType cx_config=CXConfigType::Snake)
 A tool for reducing the number of measurements required for variational quantum algorithms by partitioning Pauli strings into mutually commuting sets.
 
void to_json (nlohmann::json &j, const MeasurementSetup::MeasurementBitMap &result)
 
void from_json (const nlohmann::json &j, MeasurementSetup::MeasurementBitMap &result)
 
void to_json (nlohmann::json &j, const MeasurementSetup &setup)
 
void from_json (const nlohmann::json &j, MeasurementSetup &setup)
 
std::shared_ptr< ClassicalTransformOpClassicalX ()
 Classical NOT transform.
 
std::shared_ptr< ClassicalTransformOpClassicalCX ()
 Classical CNOT transform.
 
std::shared_ptr< ExplicitPredicateOpNotOp ()
 Unary NOT operator.
 
std::shared_ptr< ExplicitPredicateOpAndOp ()
 Binary AND operator.
 
std::shared_ptr< ExplicitPredicateOpOrOp ()
 Binary OR operator.
 
std::shared_ptr< ExplicitPredicateOpXorOp ()
 Binary XOR operator.
 
std::shared_ptr< ExplicitModifierOpAndWithOp ()
 In-place AND with another input.
 
std::shared_ptr< ExplicitModifierOpOrWithOp ()
 In-place OR with another input.
 
std::shared_ptr< ExplicitModifierOpXorWithOp ()
 In-place XOR with another input.
 
std::ostream & operator<< (std::ostream &os, ClOp fn)
 
std::ostream & operator<< (std::ostream &os, const ClBitVar &var)
 
std::ostream & operator<< (std::ostream &os, const ClRegVar &var)
 
std::ostream & operator<< (std::ostream &os, const ClExprVar &var)
 
void to_json (nlohmann::json &j, const ClExprVar &var)
 
void from_json (const nlohmann::json &j, ClExprVar &var)
 
std::ostream & operator<< (std::ostream &os, const ClExprTerm &term)
 
void to_json (nlohmann::json &j, const ClExprTerm &term)
 
void from_json (const nlohmann::json &j, ClExprTerm &term)
 
std::ostream & operator<< (std::ostream &os, const ClExprArg &arg)
 
void to_json (nlohmann::json &j, const ClExprArg &arg)
 
void from_json (const nlohmann::json &j, ClExprArg &arg)
 
std::ostream & operator<< (std::ostream &os, const ClExpr &expr)
 
void to_json (nlohmann::json &j, const ClExpr &expr)
 
void from_json (const nlohmann::json &j, ClExpr &expr)
 
std::ostream & operator<< (std::ostream &os, const WiredClExpr &expr)
 
void to_json (nlohmann::json &j, const WiredClExpr &expr)
 
void from_json (const nlohmann::json &j, WiredClExpr &expr)
 
std::ostream & operator<< (std::ostream &os, Op const &operation)
 
void to_json (nlohmann::json &j, const Op_ptr &op)
 
bool find_in_set (const OpType &val, const OpTypeSet &set)
 Whether a given operation type belongs to a given set.
 
const OpTypeSetall_gate_types ()
 Set of all elementary gates.
 
const OpTypeSetall_multi_qubit_types ()
 Set of all gates over more than one qubit.
 
const OpTypeSetall_single_qubit_unitary_types ()
 Set of all single-qubit gates that can be expressed as TK1.
 
const OpTypeSetall_single_qubit_types ()
 Set of all gates over a single qubit.
 
const OpTypeSetall_classical_types ()
 Set of all classical gates.
 
const OpTypeSetall_projective_types ()
 Set of all measurement and reset gates.
 
const OpTypeSetall_controlled_gate_types ()
 Set of all controlled gates.
 
bool is_metaop_type (OpType optype)
 Test for initial and final "ops".
 
bool is_barrier_type (OpType optype)
 Test for Barrier "ops".
 
bool is_initial_q_type (OpType optype)
 Test for input or creation quantum "ops".
 
bool is_final_q_type (OpType optype)
 Test for output or discard quantum "ops".
 
bool is_initial_type (OpType optype)
 Test for input "ops".
 
bool is_final_type (OpType optype)
 Test for output "ops".
 
bool is_boundary_type (OpType optype)
 Test for input, creation, output or discard "ops".
 
bool is_boundary_q_type (OpType optype)
 Test for input, creation, output or discard quantum "ops".
 
bool is_boundary_c_type (OpType optype)
 Test for input or output for classical "ops".
 
bool is_boundary_w_type (OpType optype)
 Test for input or output for wasm "ops".
 
bool is_gate_type (OpType optype)
 Test for elementary gates.
 
bool is_box_type (OpType optype)
 Test for boxes (complex packaged operations)
 
bool is_flowop_type (OpType optype)
 Test for flowops (just for high-level control flow)
 
bool is_rotation_type (OpType optype)
 Test for rotations (including controlled rotations)
 
bool is_parameterised_pauli_rotation_type (OpType optype)
 Test for rotations around Pauli axes.
 
bool is_multi_qubit_type (OpType optype)
 Test for gates over more than one qubit.
 
bool is_single_qubit_type (OpType optype)
 Test for gates over a single qubit.
 
bool is_single_qubit_unitary_type (OpType optype)
 Test for single-qubit gates that can be expressed as TK1.
 
bool is_oneway_type (OpType optype)
 Test for non-invertible operations.
 
bool is_clifford_type (OpType optype)
 Test for Clifford operations.
 
bool is_projective_type (OpType optype)
 Test for measurement and reset gates.
 
bool is_classical_type (OpType optype)
 Test for purely classical gates.
 
bool is_controlled_gate_type (OpType optype)
 Test for controlled gates.
 
const std::map< OpType, OpTypeInfo > & optypeinfo ()
 Information including name and shape of each operation type.
 
const std::map< std::string, OpType > & name_to_optype ()
 
void to_json (nlohmann::json &j, const OpType &type)
 
void from_json (const nlohmann::json &j, OpType &type)
 
std::pair< Pauli, bool > conjugate_Pauli (OpType op, Pauli p, bool reverse=false)
 Captures rules for conjugating a pauli-gadget with single-qubit Clifford gates Maps gate and pauli to the new pauli after the conjugation and whether or not a phase-flip is induced.
 
void conjugate_PauliTensor (SpPauliStabiliser &qpt, OpType op, const Qubit &q, bool reverse=false)
 Methods to conjugate a SpPauliStabiliser with Clifford gates to change basis Transforms P to P' such that reverse = false : –P'– = –op–P–opdg– reverse = true : –P'– = –opdg–P–op–.
 
void conjugate_PauliTensor (SpPauliStabiliser &qpt, OpType op, const Qubit &q0, const Qubit &q1)
 
void conjugate_PauliTensor (SpPauliStabiliser &qpt, OpType op, const Qubit &q0, const Qubit &q1, const Qubit &q2)
 
bool operator< (const PauliGadgetProperties &pgp1, const PauliGadgetProperties &pgp2)
 
void fill_partial_mapping (const qubit_vector_t &current_qubits, std::map< Qubit, Node > &partial_mapping)
 
void to_json (nlohmann::json &j, const Placement::Ptr &placement_ptr)
 
void from_json (const nlohmann::json &j, Placement::Ptr &placement_ptr)
 
void trivial_callback (const CompilationUnit &, const nlohmann::json &)
 Default callback when applying a pass (does nothing)
 
PassPtr operator>> (const PassPtr &lhs, const PassPtr &rhs)
 
nlohmann::json serialise (const BasePass &bp)
 
nlohmann::json serialise (const PassPtr &pp)
 
nlohmann::json serialise (const std::vector< PassPtr > &pp)
 
PassPtr deserialise (const nlohmann::json &j, const std::map< std::string, std::function< Circuit(const Circuit &)> > &custom_deserialise, const std::map< std::string, std::function< std::pair< Circuit, std::pair< unit_map_t, unit_map_t > >(const Circuit &)> > &custom_map_deserialise)
 
PassPtr gen_rebase_pass (const OpTypeSet &allowed_gates, const Circuit &cx_replacement, const std::function< Circuit(const Expr &, const Expr &, const Expr &)> &tk1_replacement)
 
PassPtr gen_rebase_pass_via_tk2 (const OpTypeSet &allowed_gates, const std::function< Circuit(const Expr &, const Expr &, const Expr &)> &tk2_replacement, const std::function< Circuit(const Expr &, const Expr &, const Expr &)> &tk1_replacement)
 Generate a rebase pass give standard replacements for TK1 and TK2 gates.
 
PassPtr gen_squash_pass (const OpTypeSet &singleqs, const std::function< Circuit(const Expr &, const Expr &, const Expr &)> &tk1_replacement, bool always_squash_symbols)
 
PassPtr gen_auto_rebase_pass (const OpTypeSet &allowed_gates, bool allow_swaps=false)
 Attempt to generate a rebase pass automatically for the given target gateset.
 
PassPtr gen_auto_squash_pass (const OpTypeSet &singleqs)
 Attempt to generate a squash pass automatically for the given target single qubit gateset.
 
PassPtr gen_euler_pass (const OpType &q, const OpType &p, bool strict)
 
PassPtr gen_clifford_simp_pass (bool allow_swaps, OpType target_2qb_gate)
 
PassPtr gen_clifford_resynthesis_pass (std::optional< std::function< Circuit(const Circuit &)> > transform=std::nullopt, bool allow_swaps=true)
 Pass to resynthesise Clifford subcircuits and simplify using Clifford rules.
 
PassPtr gen_clifford_push_through_pass ()
 Pass that simplifies circuits by resynthesising Clifford subcircuits before end of circuit measurements as a mutual diagonalisation circuit and classical postprocessing.
 
PassPtr gen_flatten_relabel_registers_pass (const std::string &label)
 Pass to remove empty Quantum edges from a Circuit and then relabel all Qubit to some new register defined by a passed label.
 
PassPtr gen_rename_qubits_pass (const std::map< Qubit, Qubit > &qm)
 Pass to rename some or all qubits according to the given map.
 
PassPtr gen_placement_pass (const Placement::Ptr &placement_ptr)
 
PassPtr gen_naive_placement_pass (const Architecture &arc)
 
PassPtr gen_full_mapping_pass (const Architecture &arc, const Placement::Ptr &placement_ptr, const std::vector< RoutingMethodPtr > &config)
 
PassPtr gen_default_mapping_pass (const Architecture &arc, bool delay_measures)
 
PassPtr gen_cx_mapping_pass (const Architecture &arc, const Placement::Ptr &placement_ptr, const std::vector< RoutingMethodPtr > &config, bool directed_cx, bool delay_measures)
 
PassPtr gen_routing_pass (const Architecture &arc, const std::vector< RoutingMethodPtr > &config)
 
PassPtr gen_placement_pass_phase_poly (const Architecture &arc, unsigned _maximum_matches=2000, unsigned _timeout=100, unsigned _maximum_pattern_gates=100, unsigned _maximum_pattern_depth=100)
 pass to place all not yet placed qubits of the circuit to the given architecture for the architecture aware synthesis.
 
PassPtr aas_routing_pass (const Architecture &arc, const unsigned lookahead=1, const aas::CNotSynthType cnotsynthtype=aas::CNotSynthType::Rec)
 execute architecture aware synthesis on a given architecture for an allready place circuit, only for circuit which contains Cx+Rz+H gates this pass is not able to handle implicit wire swaps
 
PassPtr gen_full_mapping_pass_phase_poly (const Architecture &arc, const unsigned lookahead=1, const aas::CNotSynthType cnotsynthtype=aas::CNotSynthType::Rec, unsigned graph_placement_maximum_matches=2000, unsigned graph_placement_timeout=100, unsigned graph_placement_maximum_pattern_gates=2000, unsigned graph_placement_maximum_pattern_depth=2000)
 execute architecture aware synthesis on a given architecture for any circuit.
 
PassPtr gen_directed_cx_routing_pass (const Architecture &arc, const std::vector< RoutingMethodPtr > &config)
 
PassPtr gen_decompose_routing_gates_to_cxs_pass (const Architecture &arc, bool directed)
 
PassPtr gen_user_defined_swap_decomp_pass (const Circuit &replacement_circ)
 
PassPtr KAKDecomposition (OpType target_2qb_gate=OpType::CX, double cx_fidelity=1., bool allow_swaps=true)
 Squash sequences of two-qubit operations into minimal form.
 
PassPtr DecomposeTK2 (bool allow_swaps)
 
PassPtr DecomposeTK2 (const Transforms::TwoQbFidelities &fid, bool allow_swaps=true)
 Decomposes each TK2 gate into two-qubit gates.
 
PassPtr ThreeQubitSquash (bool allow_swaps=true)
 Resynthesize and squash three-qubit interactions.
 
PassPtr PeepholeOptimise2Q (bool allow_swaps=true)
 Performs peephole optimisation including resynthesis of 2-qubit gate sequences, and converts to a circuit containing CX and TK1 gates.
 
PassPtr FullPeepholeOptimise (bool allow_swaps=true, OpType target_2qb_gate=OpType::CX)
 Performs peephole optimisation including resynthesis of 2- and 3-qubit gate sequences, and converts to a circuit containing a given 2-qubit gate and TK1 gates.
 
PassPtr gen_optimise_phase_gadgets (CXConfigType cx_config)
 
PassPtr gen_pairwise_pauli_gadgets (CXConfigType cx_config)
 
PassPtr gen_pauli_exponentials (Transforms::PauliSynthStrat strat, CXConfigType cx_config)
 
PassPtr gen_synthesise_pauli_graph (Transforms::PauliSynthStrat strat, CXConfigType cx_config)
 
PassPtr gen_greedy_pauli_simp (double discount_rate=0.7, double depth_weight=0.3, unsigned max_lookahead=500, unsigned max_tqe_candidates=500, unsigned seed=0, bool allow_zzphase=false, unsigned thread_timeout=100, bool only_reduce=false, unsigned trials=1)
 Greedy synthesis for Pauli graphs.
 
PassPtr gen_special_UCC_synthesis (Transforms::PauliSynthStrat strat, CXConfigType cx_config)
 
PassPtr gen_simplify_initial (Transforms::AllowClassical allow_classical=Transforms::AllowClassical::Yes, Transforms::CreateAllQubits create_all_qubits=Transforms::CreateAllQubits::No, std::shared_ptr< const Circuit > xcirc=0)
 Generate a pass to simplify the circuit where it acts on known basis states.
 
PassPtr gen_contextual_pass (Transforms::AllowClassical allow_classical=Transforms::AllowClassical::Yes, std::shared_ptr< const Circuit > xcirc=0)
 Generate a pass to perform simplifications dependent on qubit state.
 
PassPtr PauliSquash (Transforms::PauliSynthStrat strat, CXConfigType cx_config)
 Builds a sequence of PauliSimp (gen_synthesise_pauli_graph) and FullPeepholeOptimise.
 
PassPtr RoundAngles (unsigned n, bool only_zeros=false)
 Generate a pass that rounds all angles to the nearest \( \pi / 2^n \).
 
PassPtr CustomPass (std::function< Circuit(const Circuit &)> transform, const std::string &label="")
 Generate a custom pass.
 
PassPtr CustomPassMap (std::function< std::pair< Circuit, std::pair< unit_map_t, unit_map_t > >(const Circuit &)> transform, const std::string &label="")
 Generate a custom pass that tracks map.
 
const PassPtrSynthesiseTK ()
 
const PassPtrSynthesiseTket ()
 
const PassPtrRebaseTket ()
 
const PassPtrRebaseUFR ()
 
const PassPtrRemoveRedundancies ()
 
const PassPtrCommuteThroughMultis ()
 
const PassPtrDecomposeArbitrarilyControlledGates ()
 
const PassPtrDecomposeMultiQubitsCX ()
 
const PassPtrDecomposeSingleQubitsTK1 ()
 
PassPtr ComposePhasePolyBoxes (unsigned min_size=0)
 converts a circuit containing all possible gates to a circuit containing only phase poly boxes + H gates (and measure + reset + collapse + barrier)
 
PassPtr DecomposeBoxes (const std::unordered_set< OpType > &excluded_types={}, const std::unordered_set< std::string > &excluded_opgroups={}, const std::optional< std::unordered_set< OpType > > &included_types=std::nullopt, const std::optional< std::unordered_set< std::string > > &included_opgroups=std::nullopt)
 Recursively replaces all boxes by their decomposition using Box::to_circuit.
 
const PassPtrSquashTK1 ()
 Squash sequences of single-qubit gates to TK1 gates.
 
const PassPtrDecomposeBridges ()
 
const PassPtrFlattenRegisters ()
 
const PassPtrRemoveBarriers ()
 Remove all& OpType::Barrier from the circuit.
 
const PassPtrDelayMeasures (bool allow_partial=false)
 Commutes measurements to the end of the circuit.
 
const PassPtrRemoveDiscarded ()
 Remove all operations that have no OpType::Output or OpType::ClOutput in their causal future.
 
const PassPtrSimplifyMeasured ()
 Replace all measured classical maps that are followed by Measure operations whose quantum output is discarded with classical operations following the Measure.
 
const PassPtrNormaliseTK2 ()
 Normalises all TK2 gates.
 
const PassPtrZZPhaseToRz ()
 Converts ZZPhase with angle 1 or -1 to two Rz(1) gates.
 
const PassPtrSquashRzPhasedX ()
 Squash single qubit gates into PhasedX and Rz gates.
 
const PassPtrCnXPairwiseDecomposition ()
 Decompose CnX gates to 2-qubit gates and single qubit gates.
 
const PassPtrRemoveImplicitQubitPermutation ()
 Remove any implicit qubit permutation by appending SWAP gates.
 
const PassPtrZXGraphlikeOptimisation (bool allow_swaps=true)
 Attempt to optimise the circuit by simplifying in ZX calculus and extracting a circuit back out.
 
const PassPtrRemovePhaseOps ()
 Remove all OpType::Phase (including conditionals) from the circuit.
 
const std::string & predicate_name (std::type_index idx)
 
void to_json (nlohmann::json &j, const PredicatePtr &pred_ptr)
 
void from_json (const nlohmann::json &j, PredicatePtr &pred_ptr)
 
Transform operator>> (const Transform &lhs, const Transform &rhs)
 
Circuit multi_controlled_to_2q (const Op_ptr op, const std::optional< OpType > &two_q_type=std::nullopt)
 Replace CnRy, CnRx, CnRz, CnX, CnZ, CnY with 2-qubit gates and single qubit gates.
 
Circuit TK2_circ_from_multiq (const Op_ptr op)
 Replace a multi-qubit operation with an equivalent circuit using TK2 gates.
 
Circuit CX_circ_from_multiq (const Op_ptr op)
 Replace a multi-qubit operation with an equivalent circuit using CX gates.
 
Circuit CX_ZX_circ_from_op (const Op_ptr op)
 Replace an operation with an equivalent circuit using CX, Rx and Rz.
 
csd_t CS_decomp (const Eigen::MatrixXcd &u)
 Compute a cosine-sine decomposition of a unitary matrix.
 
bool approx_0 (const Expr &e, double tol=EPS)
 Test if an expression is approximately zero.
 
double fmodn (double x, unsigned n)
 Evaluate modulo n in the range [0,n)
 
bool approx_eq (double x, double y, unsigned mod=2, double tol=EPS)
 Test approximate equality of two values modulo n.
 
SymSet expr_free_symbols (const Expr &e)
 Set of all free symbols contained in the expression.
 
SymSet expr_free_symbols (const std::vector< Expr > &es)
 Set of all free symbols contained in the expressions in the vector.
 
std::optional< double > eval_expr (const Expr &e)
 
std::optional< Complexeval_expr_c (const Expr &e)
 
std::optional< double > eval_expr_mod (const Expr &e, unsigned n=2)
 Evaluate an expression modulo n.
 
Expr cos_halfpi_times (const Expr &e)
 Return cos(e*pi/2)
 
Expr sin_halfpi_times (const Expr &e)
 Return sin(e*pi/2)
 
Expr minus_times (const Expr &e)
 Return -e.
 
bool equiv_expr (const Expr &e0, const Expr &e1, unsigned n=2, double tol=EPS)
 Test approximate equality of expressions modulo n.
 
bool equiv_val (const Expr &e, double x, unsigned n=2, double tol=EPS)
 Test approximate value of an expression modulo n.
 
bool equiv_0 (const Expr &e, unsigned n=2, double tol=EPS)
 Test whether a expression is approximately 0 modulo n.
 
std::optional< unsigned > equiv_Clifford (const Expr &e, unsigned n=2, double tol=EPS)
 Test whether an expression is approximately a Clifford angle (some multiple of 0.5 modulo n)
 
GrayCode gen_graycode (unsigned n)
 Construct a GrayCode over n bits.
 
uint64_t reverse_bits (uint64_t v, unsigned w)
 Reverse bits 0,1,...,w-1 of the number v, assuming v < 2^w and w <= 64.
 
std::vector< bool > dec_to_bin (unsigned long long dec, unsigned width)
 convert an unsigned to its binary representation big-endian
 
unsigned long long bin_to_dec (const std::vector< bool > &bin)
 convert an bit vector to its decimal representation big-endian
 
bool is_unitary (const Eigen::MatrixXcd &U, double tol=EPS)
 Test matrix for unitarity.
 
bool is_projector (const Eigen::MatrixXcd &P, double tol)
 
std::pair< MatrixXb, MatrixXbbinary_LLT_decomposition (const MatrixXb &a)
 
std::vector< std::pair< unsigned, unsigned > > gaussian_elimination_col_ops (const MatrixXb &a, unsigned blocksize)
 
std::vector< std::pair< unsigned, unsigned > > gaussian_elimination_row_ops (const MatrixXb &a, unsigned blocksize)
 
Eigen::PermutationMatrix< Eigen::Dynamic > lift_perm (const std::map< unsigned, unsigned > &p)
 Lift a permutation of \( [0,n) \) to a permutation of \( [0,2^n) \) as a matrix.
 
Eigen::Matrix4cd reverse_indexing (const Eigen::Matrix4cd &m)
 
Matrix8cd reverse_indexing (const Matrix8cd &m)
 
Eigen::MatrixXcd reverse_indexing (const Eigen::MatrixXcd &m)
 
Eigen::VectorXcd reverse_indexing (const Eigen::VectorXcd &v)
 
Eigen::MatrixXcd apply_qubit_permutation (const Eigen::MatrixXcd &m, const qubit_map_t &perm)
 
Eigen::VectorXcd apply_qubit_permutation (const Eigen::VectorXcd &v, const qubit_map_t &perm)
 
double trace_fidelity (double a, double b, double c)
 Similarity measure of TK2(a, b, c) to SU(4) identity.
 
double mod (double d, double max)
 
std::tuple< Eigen::Matrix4cd, std::array< double, 3 >, Eigen::Matrix4cd > get_information_content (const Eigen::Matrix4cd &X)
 Performs KAK decomposition.
 
std::pair< Eigen::Matrix2cd, Eigen::Matrix2cd > kronecker_decomposition (Eigen::Matrix4cd &U)
 
unsigned get_matrix_size (unsigned number_of_qubits)
 Returns 2^n, but throws if n is too large (causes overflow).
 
unsigned get_number_of_qubits (unsigned matrix_size)
 We have a matrix size, which should be 2^n.
 
SparseMatrixXcd get_sparse_matrix (const std::vector< TripletCd > &triplets, unsigned rows, unsigned cols)
 
SparseMatrixXcd get_sparse_square_matrix (const std::vector< TripletCd > &triplets, unsigned rows)
 
std::vector< TripletCdget_triplets (const SparseMatrixXcd &matr, double abs_epsilon=EPS)
 abs_epsilon is used to decide if a near-zero entry should be set to zero exactly.
 
std::vector< TripletCdget_triplets (const Eigen::MatrixXcd &matr, double abs_epsilon=EPS)
 Convert a matrix M into a list of tuples (i,j,z), meaning that M(i,j)=z, used in sparse representations of M.
 
bool in_weyl_chamber (const std::array< Expr, 3 > &k)
 Whether a triplet of TK2 angles are normalised.
 
Eigen::Matrix2cd nth_root (const Eigen::Matrix2cd &u, unsigned long long n)
 Get an nth root of a 2x2 unitary matrix.
 
void to_json (nlohmann::json &, const no_coeff_t &)
 
void from_json (const nlohmann::json &, no_coeff_t &)
 
template<>
no_coeff_t default_coeff< no_coeff_t > ()
 
template<>
quarter_turns_t default_coeff< quarter_turns_t > ()
 
template<>
Complex default_coeff< Complex > ()
 
template<>
Expr default_coeff< Expr > ()
 
template<>
QubitPauliMap cast_container< QubitPauliMap, QubitPauliMap > (const QubitPauliMap &cont)
 
template<>
QubitPauliMap cast_container< DensePauliMap, QubitPauliMap > (const DensePauliMap &cont)
 
template<>
DensePauliMap cast_container< QubitPauliMap, DensePauliMap > (const QubitPauliMap &cont)
 
template<>
DensePauliMap cast_container< DensePauliMap, DensePauliMap > (const DensePauliMap &cont)
 
template<>
no_coeff_t cast_coeff< no_coeff_t, no_coeff_t > (const no_coeff_t &)
 
template<>
quarter_turns_t cast_coeff< no_coeff_t, quarter_turns_t > (const no_coeff_t &)
 
template<>
Complex cast_coeff< no_coeff_t, Complex > (const no_coeff_t &)
 
template<>
Expr cast_coeff< no_coeff_t, Expr > (const no_coeff_t &)
 
template<>
no_coeff_t cast_coeff< quarter_turns_t, no_coeff_t > (const quarter_turns_t &)
 
template<>
quarter_turns_t cast_coeff< quarter_turns_t, quarter_turns_t > (const quarter_turns_t &coeff)
 
template<>
Complex cast_coeff< quarter_turns_t, Complex > (const quarter_turns_t &coeff)
 
template<>
Expr cast_coeff< quarter_turns_t, Expr > (const quarter_turns_t &coeff)
 
template<>
no_coeff_t cast_coeff< Complex, no_coeff_t > (const Complex &)
 
template<>
quarter_turns_t cast_coeff< Complex, quarter_turns_t > (const Complex &coeff)
 
template<>
Complex cast_coeff< Complex, Complex > (const Complex &coeff)
 
template<>
Expr cast_coeff< Complex, Expr > (const Complex &coeff)
 
template<>
no_coeff_t cast_coeff< Expr, no_coeff_t > (const Expr &)
 
template<>
quarter_turns_t cast_coeff< Expr, quarter_turns_t > (const Expr &coeff)
 
template<>
Complex cast_coeff< Expr, Complex > (const Expr &coeff)
 
template<>
Expr cast_coeff< Expr, Expr > (const Expr &coeff)
 
template<>
int compare_containers< QubitPauliMap > (const QubitPauliMap &first, const QubitPauliMap &second)
 
template<>
int compare_containers< DensePauliMap > (const DensePauliMap &first, const DensePauliMap &second)
 
template<>
int compare_coeffs< no_coeff_t > (const no_coeff_t &, const no_coeff_t &)
 
template<>
int compare_coeffs< quarter_turns_t > (const quarter_turns_t &first, const quarter_turns_t &second)
 
template<>
int compare_coeffs< Complex > (const Complex &first, const Complex &second)
 
template<>
int compare_coeffs< Expr > (const Expr &first, const Expr &second)
 
std::set< Qubitcommon_qubits (const QubitPauliMap &first, const QubitPauliMap &second)
 Find the set of Qubits on which first and second have the same non-trivial Pauli (X, Y, Z).
 
std::set< unsigned > common_indices (const DensePauliMap &first, const DensePauliMap &second)
 Find the set of qubits (as unsigned integer indices) on which first and second have the same non-trivial Pauli (X, Y, Z).
 
std::set< Qubitown_qubits (const QubitPauliMap &first, const QubitPauliMap &second)
 Find the set of Qubits on which first has a non-trivial Pauli (X, Y, Z) but second either doesn't contain or maps to I.
 
std::set< unsigned > own_indices (const DensePauliMap &first, const DensePauliMap &second)
 Find the set of qubits (as unsigned integer indices) on which first has a non-trivial Pauli (X, Y, Z) but second either doesn't contain (>= size) or maps to I.
 
std::set< Qubitconflicting_qubits (const QubitPauliMap &first, const QubitPauliMap &second)
 Find the set of Qubits on which first and second have distinct non-trivial Paulis (X, Y, Z).
 
std::set< unsigned > conflicting_indices (const DensePauliMap &first, const DensePauliMap &second)
 Find the set of qubits (as unsigned integer indices) on which first and second have distinct non-trivial Paulis (X, Y, Z).
 
template<>
bool commuting_containers< QubitPauliMap > (const QubitPauliMap &first, const QubitPauliMap &second)
 
template<>
bool commuting_containers< DensePauliMap > (const DensePauliMap &first, const DensePauliMap &second)
 
template<>
void print_paulis< QubitPauliMap > (std::ostream &os, const QubitPauliMap &paulis)
 
template<>
void print_paulis< DensePauliMap > (std::ostream &os, const DensePauliMap &paulis)
 
template<>
void print_coeff< no_coeff_t > (std::ostream &, const no_coeff_t &)
 Generates the coefficient prefix for PauliTensor::to_str()
 
template<>
void print_coeff< quarter_turns_t > (std::ostream &os, const quarter_turns_t &coeff)
 
template<>
void print_coeff< Complex > (std::ostream &os, const Complex &coeff)
 
template<>
void print_coeff< Expr > (std::ostream &os, const Expr &coeff)
 
template<>
void hash_combine_paulis< QubitPauliMap > (std::size_t &seed, const QubitPauliMap &paulis)
 
template<>
void hash_combine_paulis< DensePauliMap > (std::size_t &seed, const DensePauliMap &paulis)
 
template<>
void hash_combine_coeff< no_coeff_t > (std::size_t &, const no_coeff_t &)
 
template<>
void hash_combine_coeff< quarter_turns_t > (std::size_t &seed, const quarter_turns_t &coeff)
 
template<>
void hash_combine_coeff< Complex > (std::size_t &seed, const Complex &coeff)
 
template<>
void hash_combine_coeff< Expr > (std::size_t &seed, const Expr &coeff)
 
template<>
unsigned n_ys< QubitPauliMap > (const QubitPauliMap &paulis)
 
template<>
unsigned n_ys< DensePauliMap > (const DensePauliMap &paulis)
 
const std::map< std::pair< Pauli, Pauli >, std::pair< quarter_turns_t, Pauli > > & get_mult_matrix ()
 Returns a const reference to a lookup table for multiplying individual Paulis.
 
template<>
std::pair< quarter_turns_t, QubitPauliMapmultiply_strings< QubitPauliMap > (const QubitPauliMap &first, const QubitPauliMap &second)
 
template<>
std::pair< quarter_turns_t, DensePauliMapmultiply_strings< DensePauliMap > (const DensePauliMap &first, const DensePauliMap &second)
 
template<>
no_coeff_t multiply_coeffs< no_coeff_t > (const no_coeff_t &, const no_coeff_t &)
 
template<>
quarter_turns_t multiply_coeffs< quarter_turns_t > (const quarter_turns_t &first, const quarter_turns_t &second)
 
template<>
Complex multiply_coeffs< Complex > (const Complex &first, const Complex &second)
 
template<>
Expr multiply_coeffs< Expr > (const Expr &first, const Expr &second)
 
template<>
CmplxSpMat to_sparse_matrix< QubitPauliMap > (const QubitPauliMap &paulis)
 
template<>
CmplxSpMat to_sparse_matrix< DensePauliMap > (const DensePauliMap &paulis)
 
template<>
CmplxSpMat to_sparse_matrix< QubitPauliMap > (const QubitPauliMap &paulis, unsigned n_qubits)
 
template<>
CmplxSpMat to_sparse_matrix< DensePauliMap > (const DensePauliMap &paulis, unsigned n_qubits)
 
template<>
CmplxSpMat to_sparse_matrix< QubitPauliMap > (const QubitPauliMap &paulis, const qubit_vector_t &qubits)
 
template<>
CmplxSpMat to_sparse_matrix< DensePauliMap > (const DensePauliMap &paulis, const qubit_vector_t &qubits)
 
void to_json (nlohmann::json &j, const Qubit &qb)
 
void from_json (const nlohmann::json &j, Qubit &qb)
 
void to_json (nlohmann::json &j, const Bit &cb)
 
void from_json (const nlohmann::json &j, Bit &cb)
 
void to_json (nlohmann::json &j, const WasmState &wb)
 
void from_json (const nlohmann::json &j, WasmState &wb)
 
void to_json (nlohmann::json &j, const Node &node)
 
void from_json (const nlohmann::json &j, Node &node)
 
void to_json (nlohmann::json &j, const qubit_map_t &qm)
 
void from_json (const nlohmann::json &j, qubit_map_t &qm)
 
const std::string & q_default_reg ()
 
const std::string & q_routing_ancilla_reg ()
 
const std::string & c_default_reg ()
 
const std::string & w_default_reg ()
 
const std::string & node_default_reg ()
 
const std::string & c_debug_zero_prefix ()
 
const std::string & c_debug_one_prefix ()
 
const std::string & c_debug_default_name ()
 
const std::string & c_permutation_scratch_name ()
 
int tri_lexicographical_comparison (const dist_vec &dist1, const dist_vec &dist2)
 
template<typename BoxT >
Op_ptr set_box_id (BoxT &b, boost::uuids::uuid newid)
 Set explicit ID on a box.
 
template<arithmetic T>
void to_json (nlohmann::json &j, const ResourceBounds< T > &bounds)
 
template<arithmetic T>
void from_json (const nlohmann::json &j, ResourceBounds< T > &bounds)
 
 NLOHMANN_JSON_SERIALIZE_ENUM (ToffoliBoxSynthStrat, {{ToffoliBoxSynthStrat::Matching, "Matching"}, {ToffoliBoxSynthStrat::Cycle, "Cycle"}})
 
 JSON_DECL (LexiRouteRoutingMethod)
 
 JSON_DECL (RoutingMethod)
 
 JSON_DECL (std::vector< RoutingMethodPtr >)
 
 NLOHMANN_JSON_SERIALIZE_ENUM (ClOp, { {ClOp::INVALID, "INVALID"}, {ClOp::BitAnd, "BitAnd"}, {ClOp::BitOr, "BitOr"}, {ClOp::BitXor, "BitXor"}, {ClOp::BitEq, "BitEq"}, {ClOp::BitNeq, "BitNeq"}, {ClOp::BitNot, "BitNot"}, {ClOp::BitZero, "BitZero"}, {ClOp::BitOne, "BitOne"}, {ClOp::RegAnd, "RegAnd"}, {ClOp::RegOr, "RegOr"}, {ClOp::RegXor, "RegXor"}, {ClOp::RegEq, "RegEq"}, {ClOp::RegNeq, "RegNeq"}, {ClOp::RegNot, "RegNot"}, {ClOp::RegZero, "RegZero"}, {ClOp::RegOne, "RegOne"}, {ClOp::RegLt, "RegLt"}, {ClOp::RegGt, "RegGt"}, {ClOp::RegLeq, "RegLeq"}, {ClOp::RegGeq, "RegGeq"}, {ClOp::RegAdd, "RegAdd"}, {ClOp::RegSub, "RegSub"}, {ClOp::RegMul, "RegMul"}, {ClOp::RegDiv, "RegDiv"}, {ClOp::RegPow, "RegPow"}, {ClOp::RegLsh, "RegLsh"}, {ClOp::RegRsh, "RegRsh"}, {ClOp::RegNeg, "RegNeg"}, }) typedef struct ClBitVar
 A bit variable within an expression.
 
 NLOHMANN_JSON_SERIALIZE_ENUM (EdgeType, { {EdgeType::Quantum, "Q"}, {EdgeType::Classical, "C"}, {EdgeType::Boolean, "B"}, {EdgeType::WASM, "W"}, })
 
 JSON_DECL (Placement::Ptr)
 
std::vector< boost::bimap< Qubit, Node > > get_weighted_subgraph_monomorphisms (QubitGraph::UndirectedConnGraph &pattern_graph, Architecture::UndirectedConnGraph &target_graph, unsigned max_matches, unsigned timeout_ms, bool return_best)
 Solves the pure unweighted subgraph monomorphism problem, trying to embed the pattern graph into the target graph.
 
constexpr Complex i_ (0, 1)
 A fixed square root of -1.
 
constexpr Complex czero (0, 0)
 Complex zero.
 
template<typename T >
bool check_iterators_equality (const T &first, const T &second)
 Check equality of each element of first and second when first and second can provide begin, end iterators.
 
template<class MatrixT >
MatrixT unitary_product2 (const MatrixT &U, const MatrixT &V)
 Compute the product of two unitary matrices, with error correction.
 
template<class MatrixT >
MatrixT unitary_product3 (const MatrixT &U, const MatrixT &V, const MatrixT &W)
 Compute the product of three unitary matrices, with error correction.
 
 NLOHMANN_JSON_SERIALIZE_ENUM (Pauli, { {Pauli::I, "I"}, {Pauli::X, "X"}, {Pauli::Y, "Y"}, {Pauli::Z, "Z"}, })
 
 NLOHMANN_JSON_SERIALIZE_ENUM (CXConfigType, {{CXConfigType::Snake, "Snake"}, {CXConfigType::Tree, "Tree"}, {CXConfigType::Star, "Star"}, {CXConfigType::MultiQGate, "MultiQGate"}})
 
template<typename CoeffType >
CoeffType default_coeff ()=delete
 Other options for scalar coefficients include:
 
template<>
no_coeff_t default_coeff< no_coeff_t > ()
 
template<>
quarter_turns_t default_coeff< quarter_turns_t > ()
 
template<>
Complex default_coeff< Complex > ()
 
template<>
Expr default_coeff< Expr > ()
 
template<typename OriginalCoeff , typename NewCoeff >
NewCoeff cast_coeff (const OriginalCoeff &coeff)=delete
 Cast a coefficient to a different type.
 
template<>
no_coeff_t cast_coeff< no_coeff_t, no_coeff_t > (const no_coeff_t &)
 
template<>
quarter_turns_t cast_coeff< no_coeff_t, quarter_turns_t > (const no_coeff_t &)
 
template<>
Complex cast_coeff< no_coeff_t, Complex > (const no_coeff_t &)
 
template<>
Expr cast_coeff< no_coeff_t, Expr > (const no_coeff_t &)
 
template<>
no_coeff_t cast_coeff< quarter_turns_t, no_coeff_t > (const quarter_turns_t &)
 
template<>
quarter_turns_t cast_coeff< quarter_turns_t, quarter_turns_t > (const quarter_turns_t &coeff)
 
template<>
Complex cast_coeff< quarter_turns_t, Complex > (const quarter_turns_t &coeff)
 
template<>
Expr cast_coeff< quarter_turns_t, Expr > (const quarter_turns_t &coeff)
 
template<>
no_coeff_t cast_coeff< Complex, no_coeff_t > (const Complex &)
 
template<>
quarter_turns_t cast_coeff< Complex, quarter_turns_t > (const Complex &coeff)
 
template<>
Complex cast_coeff< Complex, Complex > (const Complex &coeff)
 
template<>
Expr cast_coeff< Complex, Expr > (const Complex &coeff)
 
template<>
no_coeff_t cast_coeff< Expr, no_coeff_t > (const Expr &)
 
template<>
quarter_turns_t cast_coeff< Expr, quarter_turns_t > (const Expr &coeff)
 
template<>
Complex cast_coeff< Expr, Complex > (const Expr &coeff)
 
template<>
Expr cast_coeff< Expr, Expr > (const Expr &coeff)
 
template<typename CoeffType >
int compare_coeffs (const CoeffType &first, const CoeffType &second)=delete
 Compare two coefficients of the same type with respect to an ordering.
 
template<>
int compare_coeffs< no_coeff_t > (const no_coeff_t &, const no_coeff_t &)
 
template<>
int compare_coeffs< quarter_turns_t > (const quarter_turns_t &first, const quarter_turns_t &second)
 
template<>
int compare_coeffs< Complex > (const Complex &first, const Complex &second)
 
template<>
int compare_coeffs< Expr > (const Expr &first, const Expr &second)
 
template<typename CoeffType >
void print_coeff (std::ostream &os, const CoeffType &coeff)=delete
 
template<>
void print_coeff< no_coeff_t > (std::ostream &, const no_coeff_t &)
 Generates the coefficient prefix for PauliTensor::to_str()
 
template<>
void print_coeff< quarter_turns_t > (std::ostream &os, const quarter_turns_t &coeff)
 
template<>
void print_coeff< Complex > (std::ostream &os, const Complex &coeff)
 
template<>
void print_coeff< Expr > (std::ostream &os, const Expr &coeff)
 
template<typename CoeffType >
void hash_combine_coeff (std::size_t &seed, const CoeffType &coeff)=delete
 Hash a coefficient, combining it with an existing hash of another structure.
 
template<>
void hash_combine_coeff< no_coeff_t > (std::size_t &, const no_coeff_t &)
 
template<>
void hash_combine_coeff< quarter_turns_t > (std::size_t &seed, const quarter_turns_t &coeff)
 
template<>
void hash_combine_coeff< Complex > (std::size_t &seed, const Complex &coeff)
 
template<>
void hash_combine_coeff< Expr > (std::size_t &seed, const Expr &coeff)
 
template<typename CoeffType >
CoeffType multiply_coeffs (const CoeffType &first, const CoeffType &second)=delete
 Multiply together two coefficients of the same type.
 
template<>
no_coeff_t multiply_coeffs< no_coeff_t > (const no_coeff_t &, const no_coeff_t &)
 
template<>
quarter_turns_t multiply_coeffs< quarter_turns_t > (const quarter_turns_t &first, const quarter_turns_t &second)
 
template<>
Complex multiply_coeffs< Complex > (const Complex &first, const Complex &second)
 
template<>
Expr multiply_coeffs< Expr > (const Expr &first, const Expr &second)
 
template<typename OriginalContainer , typename NewContainer >
NewContainer cast_container (const OriginalContainer &cont)=delete
 Cast between two different Pauli container types.
 
template<>
QubitPauliMap cast_container< QubitPauliMap, QubitPauliMap > (const QubitPauliMap &cont)
 
template<>
QubitPauliMap cast_container< DensePauliMap, QubitPauliMap > (const DensePauliMap &cont)
 
template<>
DensePauliMap cast_container< QubitPauliMap, DensePauliMap > (const QubitPauliMap &cont)
 
template<>
DensePauliMap cast_container< DensePauliMap, DensePauliMap > (const DensePauliMap &cont)
 
template<typename PauliContainer >
int compare_containers (const PauliContainer &first, const PauliContainer &second)=delete
 Compare two Pauli containers of the same type for ordering.
 
template<>
int compare_containers< QubitPauliMap > (const QubitPauliMap &first, const QubitPauliMap &second)
 
template<>
int compare_containers< DensePauliMap > (const DensePauliMap &first, const DensePauliMap &second)
 
template<typename PauliContainer >
bool commuting_containers (const PauliContainer &first, const PauliContainer &second)=delete
 Return whether two Pauli containers commute as Pauli strings (there are an even number of qubits on which they have distinct non-trivial Paulis).
 
template<>
bool commuting_containers< QubitPauliMap > (const QubitPauliMap &first, const QubitPauliMap &second)
 
template<>
bool commuting_containers< DensePauliMap > (const DensePauliMap &first, const DensePauliMap &second)
 
template<typename PauliContainer >
void print_paulis (std::ostream &os, const PauliContainer &paulis)=delete
 Generates the readable Pauli string portion of PauliTensor::to_str().
 
template<>
void print_paulis< QubitPauliMap > (std::ostream &os, const QubitPauliMap &paulis)
 
template<>
void print_paulis< DensePauliMap > (std::ostream &os, const DensePauliMap &paulis)
 
template<typename PauliContainer >
void hash_combine_paulis (std::size_t &seed, const PauliContainer &paulis)=delete
 Hash a Pauli container, combining it with an existing hash of another structure.
 
template<>
void hash_combine_paulis< QubitPauliMap > (std::size_t &seed, const QubitPauliMap &paulis)
 
template<>
void hash_combine_paulis< DensePauliMap > (std::size_t &seed, const DensePauliMap &paulis)
 
template<typename PauliContainer >
unsigned n_ys (const PauliContainer &paulis)=delete
 Return the number of Pauli::Ys in the container.
 
template<>
unsigned n_ys< QubitPauliMap > (const QubitPauliMap &paulis)
 
template<>
unsigned n_ys< DensePauliMap > (const DensePauliMap &paulis)
 
template<typename PauliContainer >
std::pair< quarter_turns_t, PauliContainer > multiply_strings (const PauliContainer &first, const PauliContainer &second)=delete
 Multiplies two Pauli containers component-wise, returning both the resulting phase and string.
 
template<>
std::pair< quarter_turns_t, QubitPauliMapmultiply_strings< QubitPauliMap > (const QubitPauliMap &first, const QubitPauliMap &second)
 
template<>
std::pair< quarter_turns_t, DensePauliMapmultiply_strings< DensePauliMap > (const DensePauliMap &first, const DensePauliMap &second)
 
template<typename PauliContainer >
CmplxSpMat to_sparse_matrix (const PauliContainer &paulis)=delete
 Evaluates a Pauli container to a sparse matrix describing the tensor product of each Pauli in the string.
 
template<>
CmplxSpMat to_sparse_matrix< QubitPauliMap > (const QubitPauliMap &paulis)
 
template<>
CmplxSpMat to_sparse_matrix< DensePauliMap > (const DensePauliMap &paulis)
 
template<typename PauliContainer >
CmplxSpMat to_sparse_matrix (const PauliContainer &paulis, unsigned n_qubits)=delete
 Evaluates a Pauli container to a sparse matrix describing the tensor product of each Pauli in the string.
 
template<>
CmplxSpMat to_sparse_matrix< QubitPauliMap > (const QubitPauliMap &paulis, unsigned n_qubits)
 
template<>
CmplxSpMat to_sparse_matrix< DensePauliMap > (const DensePauliMap &paulis, unsigned n_qubits)
 
template<typename PauliContainer >
CmplxSpMat to_sparse_matrix (const PauliContainer &paulis, const qubit_vector_t &qubits)=delete
 Evaluates a Pauli container to a sparse matrix describing the tensor product of each Pauli in the string.
 
template<>
CmplxSpMat to_sparse_matrix< QubitPauliMap > (const QubitPauliMap &paulis, const qubit_vector_t &qubits)
 
template<>
CmplxSpMat to_sparse_matrix< DensePauliMap > (const DensePauliMap &paulis, const qubit_vector_t &qubits)
 
template<typename PauliContainer , typename CoeffType >
void to_json (nlohmann::json &j, const PauliTensor< PauliContainer, CoeffType > &tensor)
 
template<typename PauliContainer , typename CoeffType >
void from_json (const nlohmann::json &j, PauliTensor< PauliContainer, CoeffType > &tensor)
 
template<class Unit_T >
void unitid_to_json (nlohmann::json &j, const Unit_T &unit)
 
template<class T >
void json_to_unitid (const nlohmann::json &j, T &unit)
 
template<typename UnitA , typename UnitB >
bool update_maps (std::shared_ptr< unit_bimaps_t > maps, const std::map< UnitA, UnitB > &um_initial, const std::map< UnitA, UnitB > &um_final)
 Update a pair of "initial" and "final" correspondences.
 

Variables

 ClBitVar
 
const OptUInt any = std::nullopt
 Unspecified unsigned integer.
 
constexpr double EPS = 1e-11
 Default tolerance for floating-point comparisons.
 
constexpr double PI
 \( \pi \)
 

Detailed Description

Defines tket::DeviceCharacterisation, used in NoiseAwarePlacement and in commute_SQ_gates_through_SWAPS as a simple device noise model.

This header contains the implementation-specific type definitions for the ZXDiagram class.

This is just a container of errors.

This supports single-qubit errors, two-qubit errors and readout errors. Errors can either be OpType-specific, or a default value (average over all possible OpTypes) If an OpType-specific value is provided, this will be used. If not it will fallback to the default value for the given Node or Node pair, which itself falls back to zero error.

Currently, Boost is used for the underlying graph structure. The interface can be found in ZXDiagram.hpp.

A ZX diagram is implemented as a directed graph with labels for its vertices and edges. Although edges in a ZX diagram are ultimately undirected, some vertices are directed or otherwise non-commutative. That is, the permutation in which the edges are connected to the vertex matters, either to distinguish between inputs and outputs of the vertex or operands with different semantics. We refer to such vertices as "directed".

To represent these diagrams with undirected edges but some directed vertices we use a directed underlying graph.

Typedef Documentation

◆ ArchitecturePtr

typedef std::shared_ptr<Architecture> tket::ArchitecturePtr

Definition at line 211 of file Architecture.hpp.

◆ avg_link_errors_t

typedef std::map<std::pair<Node, Node>, gate_error_t> tket::avg_link_errors_t

Definition at line 30 of file ErrorTypes.hpp.

◆ avg_node_errors_t

Definition at line 28 of file ErrorTypes.hpp.

◆ avg_readout_errors_t

Definition at line 29 of file ErrorTypes.hpp.

◆ b_frontier_t

Definition at line 28 of file Slices.hpp.

◆ BimapValue

using tket::BimapValue = typedef boost::bimap<Qubit, Node>::value_type

Definition at line 28 of file MonomorphismCalculation.cpp.

◆ bit_map_t

typedef std::map<Bit, Bit> tket::bit_map_t

Definition at line 320 of file UnitID.hpp.

◆ bit_vector_t

typedef std::vector<Bit> tket::bit_vector_t

Definition at line 319 of file UnitID.hpp.

◆ boundary_t

typedef boost::multi_index::multi_index_container< BoundaryElement, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag<TagID>, boost::multi_index::member< BoundaryElement, UnitID, &BoundaryElement::id_> >, boost::multi_index::ordered_unique< boost::multi_index::tag<TagIn>, boost::multi_index::member< BoundaryElement, Vertex, &BoundaryElement::in_> >, boost::multi_index::ordered_unique< boost::multi_index::tag<TagOut>, boost::multi_index::member< BoundaryElement, Vertex, &BoundaryElement::out_> >, boost::multi_index::ordered_non_unique< boost::multi_index::tag<TagType>, boost::multi_index::const_mem_fun< BoundaryElement, UnitType, &BoundaryElement::type> >, boost::multi_index::ordered_non_unique< boost::multi_index::tag<TagReg>, boost::multi_index::const_mem_fun< BoundaryElement, std::string, &BoundaryElement::reg_name> > > > tket::boundary_t

Definition at line 109 of file Circuit.hpp.

◆ BoundaryVertMap

typedef boost::bimap<ZXVert, Vertex> tket::BoundaryVertMap

Definition at line 27 of file ZXConverters.cpp.

◆ BundleVec

typedef std::vector<EdgeVec> tket::BundleVec

Definition at line 57 of file Circuit.hpp.

◆ ClExprArg

typedef std::variant<ClExprTerm, ClExpr> tket::ClExprArg

An argument to a classical operation in an expression.

Definition at line 141 of file ClExpr.hpp.

◆ ClExprTerm

typedef std::variant<uint64_t, ClExprVar> tket::ClExprTerm

A term in a classical expression (either a constant or a variable)

Definition at line 128 of file ClExpr.hpp.

◆ ClExprVar

typedef std::variant<ClBitVar, ClRegVar> tket::ClExprVar

A (bit or register) variable within an expression.

Definition at line 117 of file ClExpr.hpp.

◆ ClRegVar

A register variable within an expression.

◆ CmplxSpMat

typedef Eigen::SparseMatrix<Complex, Eigen::ColMajor> tket::CmplxSpMat

Definition at line 49 of file PauliTensor.hpp.

◆ Complex

typedef std::complex<double> tket::Complex

Complex number.

Definition at line 29 of file Constants.hpp.

◆ composite_def_ptr_t

typedef std::shared_ptr<CompositeGateDef> tket::composite_def_ptr_t

Definition at line 438 of file Boxes.hpp.

◆ Conjugations

typedef std::list<std::pair<OpType, qubit_vector_t> > tket::Conjugations

Definition at line 51 of file PauliGraph.hpp.

◆ csd_t

typedef std::tuple< Eigen::MatrixXcd, Eigen::MatrixXcd, Eigen::MatrixXcd, Eigen::MatrixXcd, Eigen::MatrixXd, Eigen::MatrixXd> tket::csd_t

Cosine-sine decomposition.

The tuple (l0, l1, r0, r1, c, s) represents the decomposition [l0 ] [c -s] [r0 ] [ l1] [s c] [ r1] where l0, l1, r0 and r1 are unitaries of equal size, c and s are diagonal matrices with non-negative entries, the diagonal entries of c are in non-decreasimg order, and c^2 + s^2 = I

Definition at line 35 of file CosSinDecomposition.hpp.

◆ ctrl_op_map_t

typedef std::map<std::vector<bool>, Op_ptr> tket::ctrl_op_map_t

Map bitstrings to Ops.

Definition at line 25 of file Multiplexor.hpp.

◆ ctrl_tensored_op_map_t

typedef std::map<std::vector<bool>, std::vector<Op_ptr> > tket::ctrl_tensored_op_map_t

Map bitstrings to tensored Ops.

Definition at line 31 of file Multiplexor.hpp.

◆ cube_graph_t

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> tket::cube_graph_t

Definition at line 117 of file ToffoliBox.cpp.

◆ CxPauliTensor

Definition at line 1045 of file PauliTensor.hpp.

◆ cycle_permutation_t

typedef std::vector<std::vector<bool> > tket::cycle_permutation_t

Definition at line 388 of file ToffoliBox.cpp.

◆ cycle_transposition_t

typedef std::vector<transposition_t> tket::cycle_transposition_t

Definition at line 389 of file ToffoliBox.cpp.

◆ DAG

typedef boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, boost::property<boost::vertex_index_t, std::size_t, VertexProperties>, EdgeProperties> tket::DAG

Graph representing a circuit, with operations as nodes.

Definition at line 68 of file DAGDefs.hpp.

◆ DensePauliMap

typedef std::vector<Pauli> tket::DensePauliMap

A dense, unsigned-indexed Pauli container.

A DensePauliMap is generally treated the same regardless of any Pauli::Is padded at the end. Each qubit index is treated as the corresponding Qubit id from the default register.

In future work, it may be interesting to consider a symplectic representation (representing each Pauli by a pair of bits representing X and Z) for both speed and memory efficiency.

Definition at line 267 of file PauliTensor.hpp.

◆ dist_vec

Definition at line 34 of file Architecture.hpp.

◆ E_in_iterator

typedef DAG::in_edge_iterator tket::E_in_iterator

Definition at line 90 of file DAGDefs.hpp.

◆ E_iterator

typedef boost::graph_traits<DAG>::edge_iterator tket::E_iterator

Definition at line 89 of file DAGDefs.hpp.

◆ E_out_iterator

typedef DAG::out_edge_iterator tket::E_out_iterator

Definition at line 91 of file DAGDefs.hpp.

◆ Edge

typedef boost::graph_traits<DAG>::edge_descriptor tket::Edge

Definition at line 88 of file DAGDefs.hpp.

◆ edge_map_t

typedef std::map<Edge, Edge> tket::edge_map_t

Definition at line 65 of file Circuit.hpp.

◆ edge_pair_t

typedef std::pair<Edge, Edge> tket::edge_pair_t

Definition at line 21 of file Cycles.hpp.

◆ EdgeList

typedef std::list<Edge> tket::EdgeList

Definition at line 94 of file DAGDefs.hpp.

◆ EdgeSet

typedef std::set<Edge> tket::EdgeSet

Definition at line 92 of file DAGDefs.hpp.

◆ EdgeVec

typedef std::vector<Edge> tket::EdgeVec

Definition at line 93 of file DAGDefs.hpp.

◆ Expr

typedef SymEngine::Expression tket::Expr

Representation of a phase as a multiple of \( \pi \).

Definition at line 48 of file Expression.hpp.

◆ ExprPtr

typedef SymEngine::RCP<const SymEngine::Basic> tket::ExprPtr

Shared pointer to an Expr.

Definition at line 53 of file Expression.hpp.

◆ gate_error_t

typedef double tket::gate_error_t

Definition at line 24 of file ErrorTypes.hpp.

◆ Gate_ptr

typedef std::shared_ptr<const Gate> tket::Gate_ptr

Definition at line 24 of file GatePtr.hpp.

◆ gray_code_t

typedef std::vector<std::pair<std::vector<bool>, unsigned> > tket::gray_code_t

Definition at line 390 of file ToffoliBox.cpp.

◆ GrayCode

typedef std::vector<std::deque<bool> > tket::GrayCode

Definition at line 25 of file HelperFunctions.hpp.

◆ IndexMap

typedef std::unordered_map<Vertex, std::size_t> tket::IndexMap

Definition at line 75 of file DAGDefs.hpp.

◆ interacting_nodes_t

typedef std::map<Node, Node> tket::interacting_nodes_t

Definition at line 22 of file LexicographicalComparison.hpp.

◆ interaction_table_t

typedef boost::multi_index::multi_index_container< InteractionPoint, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::tag<TagKey>, boost::multi_index::const_mem_fun< InteractionPoint, std::pair<Edge, Vertex>, &InteractionPoint::key> >, boost::multi_index::hashed_non_unique< boost::multi_index::tag<TagEdge>, boost::multi_index::member< InteractionPoint, Edge, &InteractionPoint::e> >, boost::multi_index::hashed_non_unique< boost::multi_index::tag<TagSource>, boost::multi_index::member< InteractionPoint, Vertex, &InteractionPoint::source> > > > tket::interaction_table_t

Stores all current InteractionPoints encountered.

Each gadget can only commute to a given edge in a unique way. Searching by edge is needed to search for possible matches. Searching by vertex is needed to remove InteractionPoints when a pair merge.

Definition at line 104 of file CliffordReductionPass.hpp.

◆ IVertex

typedef std::pair<std::size_t, Vertex> tket::IVertex

A vertex with an index.

This can be used instead of a plain Vertex in associative containers where control over the order of iteration is required.

Definition at line 86 of file DAGDefs.hpp.

◆ lexicographical_distances_t

typedef std::vector<std::size_t> tket::lexicographical_distances_t

Definition at line 25 of file LexicographicalComparison.hpp.

◆ MappingFrontier_ptr

typedef std::shared_ptr<MappingFrontier> tket::MappingFrontier_ptr

Definition at line 216 of file MappingFrontier.hpp.

◆ Matrix8cd

typedef Eigen::Matrix<std::complex<double>, 8, 8> tket::Matrix8cd

Definition at line 32 of file MatrixAnalysis.hpp.

◆ MatrixXb

typedef Eigen::Matrix<bool, Eigen::Dynamic, Eigen::Dynamic> tket::MatrixXb

Definition at line 28 of file MatrixAnalysis.hpp.

◆ node_set_t

typedef std::set<Node> tket::node_set_t

Definition at line 322 of file UnitID.hpp.

◆ node_vector_t

typedef std::vector<Node> tket::node_vector_t

Definition at line 323 of file UnitID.hpp.

◆ op_errors_t

Definition at line 33 of file ErrorTypes.hpp.

◆ op_link_errors_t

typedef std::map<std::pair<Node, Node>, op_errors_t> tket::op_link_errors_t

Definition at line 35 of file ErrorTypes.hpp.

◆ op_node_errors_t

Definition at line 34 of file ErrorTypes.hpp.

◆ Op_ptr

typedef std::shared_ptr<const Op> tket::Op_ptr

Definition at line 24 of file OpPtr.hpp.

◆ op_signature_t

typedef std::vector<EdgeType> tket::op_signature_t

Definition at line 61 of file EdgeType.hpp.

◆ opt_reg_info_t

typedef std::optional<register_info_t> tket::opt_reg_info_t

Definition at line 43 of file UnitID.hpp.

◆ OptUInt

typedef std::optional<unsigned> tket::OptUInt

Optional unsigned integer.

Definition at line 26 of file OpDesc.hpp.

◆ OpTypeSet

typedef std::unordered_set<OpType> tket::OpTypeSet

Set of operation types.

Definition at line 25 of file OpTypeFunctions.hpp.

◆ OpTypeVector

typedef std::vector<OpType> tket::OpTypeVector

Vector of operation types.

Definition at line 28 of file OpTypeFunctions.hpp.

◆ PassCallback

typedef std::function<void(const CompilationUnit&, const nlohmann::json&)> tket::PassCallback

Definition at line 34 of file CompilerPass.hpp.

◆ PassConditions

Definition at line 32 of file CompilerPass.hpp.

◆ PassPtr

typedef std::shared_ptr<BasePass> tket::PassPtr

Definition at line 30 of file CompilerPass.hpp.

◆ PauliACGraph

typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, SpPauliString> tket::PauliACGraph

A PauliACGraph is a graph where each vertex is a Pauli tensor, and an edge corresponds to anticommuting tensors.

Definition at line 39 of file PauliPartition.hpp.

◆ PauliACVertex

typedef boost::graph_traits<PauliACGraph>::vertex_descriptor tket::PauliACVertex

Definition at line 41 of file PauliPartition.hpp.

◆ PauliDAG

typedef boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, boost::property<boost::vertex_index_t, int, PauliGadgetProperties>, DependencyEdgeProperties> tket::PauliDAG

Definition at line 40 of file PauliGraph.hpp.

◆ PauliEdge

typedef boost::graph_traits<PauliDAG>::edge_descriptor tket::PauliEdge

Definition at line 42 of file PauliGraph.hpp.

◆ PauliEdgeSet

Definition at line 45 of file PauliGraph.hpp.

◆ PauliStabiliser

Definition at line 1043 of file PauliTensor.hpp.

◆ PauliStabiliserVec

Definition at line 1049 of file PauliTensor.hpp.

◆ PauliString

Definition at line 1041 of file PauliTensor.hpp.

◆ PauliVert

typedef boost::graph_traits<PauliDAG>::vertex_descriptor tket::PauliVert

Definition at line 41 of file PauliGraph.hpp.

◆ PauliVertSet

Definition at line 44 of file PauliGraph.hpp.

◆ PauliVIndex

typedef boost::adj_list_vertex_property_map< PauliDAG, int, int &, boost::vertex_index_t> tket::PauliVIndex

Definition at line 49 of file PauliGraph.hpp.

◆ perm_vert_t

typedef boost::graph_traits<cube_graph_t>::vertex_descriptor tket::perm_vert_t

Definition at line 118 of file ToffoliBox.cpp.

◆ permutation_t

typedef std::unordered_map<unsigned, unsigned> tket::permutation_t

Definition at line 111 of file Circuit.hpp.

◆ phase_term_t

typedef std::pair<std::vector<bool>, Expr> tket::phase_term_t

Definition at line 29 of file PhasePoly.hpp.

◆ PhasePolynomial

typedef std::map<std::vector<bool>, Expr> tket::PhasePolynomial

PhasePolynomial is just a sequence of parities: that is, terms of the form \( e^{\alpha \bigotimes Z} \), where Z is a Pauli Z.

This is capable of representing a restricted set of circuits made up of CNOTs and Rzs: specifically, circuits where the output qubits have the same state as the inputs, modulo (local) phases. The vectors are always assumed to be the same size as the qubit count.

Definition at line 28 of file PhasePoly.hpp.

◆ port_t

typedef unsigned tket::port_t

A specific entry or exit port of a vertex.

Definition at line 48 of file Op.hpp.

◆ PredicateCache

typedef std::map<std::type_index, std::pair<PredicatePtr, bool> > tket::PredicateCache

Definition at line 27 of file CompilationUnit.hpp.

◆ PredicateClassGuarantees

typedef std::map<std::type_index, Guarantee> tket::PredicateClassGuarantees

Definition at line 31 of file CompilerPass.hpp.

◆ PredicatePtr

typedef std::shared_ptr<Predicate> tket::PredicatePtr

Definition at line 25 of file Predicates.hpp.

◆ PredicatePtrMap

typedef std::map<std::type_index, PredicatePtr> tket::PredicatePtrMap

Definition at line 25 of file CompilationUnit.hpp.

◆ QPathDetailed

typedef std::vector<VertPort> tket::QPathDetailed

Definition at line 61 of file Circuit.hpp.

◆ quarter_turns_t

typedef unsigned tket::quarter_turns_t

A fourth root of unity {1, i, -1, -i}, represented as an unsigned integer giving the power of i.

E.g. val % 4: 0: +1 1: +i 2: -1 3: -i

These are the phase coefficients generated in the Pauli group. Whilst stabilisers are restricted to {1, -1}, the imaginary numbers are required for closure under multiplication. For settings where a real value is needed, use PauliTensor::is_real_negative() which asserts the value is real (throws an exception otherwise) and returns a bool value to distinguish.

Definition at line 81 of file PauliTensor.hpp.

◆ qubit_map_t

typedef std::map<Qubit, Qubit> tket::qubit_map_t

Definition at line 316 of file UnitID.hpp.

◆ qubit_vector_t

typedef std::vector<Qubit> tket::qubit_vector_t

Definition at line 315 of file UnitID.hpp.

◆ QubitOperator

QubitOperator, defined to be useful for diagonalisation and partitioning.

Definition at line 25 of file DiagUtils.hpp.

◆ QubitPauliMap

typedef std::map<Qubit, Pauli> tket::QubitPauliMap

A sparse, Qubit-indexed Pauli container.

A QubitPauliMap is generally treated the same as if all Pauli::I entries were removed.

Definition at line 254 of file PauliTensor.hpp.

◆ readout_error_t

typedef double tket::readout_error_t

Definition at line 25 of file ErrorTypes.hpp.

◆ register_info_t

typedef std::pair<UnitType, unsigned> tket::register_info_t

The type and dimension of a register.

Definition at line 41 of file UnitID.hpp.

◆ register_t

typedef std::map<unsigned, UnitID> tket::register_t

A register of locations sharing the same name.

Definition at line 326 of file UnitID.hpp.

◆ RelabelledPatternGraph

Definition at line 24 of file MonomorphismCalculation.cpp.

◆ RelabelledTargetGraph

Definition at line 26 of file MonomorphismCalculation.cpp.

◆ RoutingMethodPtr

typedef std::shared_ptr<const RoutingMethod> tket::RoutingMethodPtr

Definition at line 57 of file RoutingMethod.hpp.

◆ sequence_set_t

template<typename T >
using tket::sequence_set_t = typedef boost::multi_index::multi_index_container< T, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag<TagKey>, boost::multi_index::identity<T> >, boost::multi_index::sequenced<boost::multi_index::tag<TagSeq> >> >

Definition at line 54 of file SequencedContainers.hpp.

◆ sequenced_bimap_t

template<typename A , typename B >
using tket::sequenced_bimap_t = typedef boost::multi_index::multi_index_container< std::pair<A, B>, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag<TagKey>, boost::multi_index::member< std::pair<A, B>, A, &std::pair<A, B>::first> >, boost::multi_index::ordered_unique< boost::multi_index::tag<TagValue>, boost::multi_index::member< std::pair<A, B>, B, &std::pair<A, B>::second> >, boost::multi_index::sequenced<boost::multi_index::tag<TagSeq> >> >

Definition at line 30 of file SequencedContainers.hpp.

◆ sequenced_map_t

template<typename A , typename B >
using tket::sequenced_map_t = typedef boost::multi_index::multi_index_container< std::pair<A, B>, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag<TagKey>, boost::multi_index::member< std::pair<A, B>, A, &std::pair<A, B>::first> >, boost::multi_index::sequenced<boost::multi_index::tag<TagSeq> >> >

Definition at line 44 of file SequencedContainers.hpp.

◆ Slice

Definition at line 24 of file Slices.hpp.

◆ SliceVec

typedef std::vector<Slice> tket::SliceVec

Definition at line 59 of file Circuit.hpp.

◆ SparseMatrixXcd

typedef Eigen::SparseMatrix<std::complex<double> > tket::SparseMatrixXcd

Definition at line 121 of file MatrixAnalysis.hpp.

◆ SpCxPauliTensor

Definition at line 1044 of file PauliTensor.hpp.

◆ SpPauliStabiliser

Definition at line 1042 of file PauliTensor.hpp.

◆ SpPauliString

Definition at line 1040 of file PauliTensor.hpp.

◆ SpSymPauliTensor

Definition at line 1046 of file PauliTensor.hpp.

◆ state_perm_t

typedef std::map<std::vector<bool>, std::vector<bool> > tket::state_perm_t

Map bitstrings to bitstrings.

Definition at line 38 of file ToffoliBox.hpp.

◆ StateVector

typedef Eigen::VectorXcd tket::StateVector

Definition at line 22 of file CircuitSimulator.hpp.

◆ swap_set_t

typedef std::set<swap_t> tket::swap_set_t

Definition at line 24 of file LexicographicalComparison.hpp.

◆ swap_t

typedef std::pair<Node, Node> tket::swap_t

Definition at line 23 of file LexicographicalComparison.hpp.

◆ Sym

typedef SymEngine::RCP<const SymEngine::Symbol> tket::Sym

Shared pointer to a free symbol.

Definition at line 56 of file Expression.hpp.

◆ symbol_map_t

typedef std::map<Sym, Expr, SymEngine::RCPBasicKeyLess> tket::symbol_map_t

Map from symbols to expressions.

Definition at line 99 of file Expression.hpp.

◆ SymPauliTensor

Definition at line 1047 of file PauliTensor.hpp.

◆ SymSet

typedef std::set<Sym, SymCompareLess> tket::SymSet

Definition at line 96 of file Expression.hpp.

◆ TripletCd

typedef Eigen::Triplet<std::complex<double> > tket::TripletCd

It is sometimes more convenient to deal with Triplets directly, rather than sparse matrices.

Definition at line 119 of file MatrixAnalysis.hpp.

◆ TypedVertPort

Definition at line 24 of file ZXConverters.cpp.

◆ TypePredicatePair

typedef std::pair<const std::type_index, PredicatePtr> tket::TypePredicatePair

Definition at line 26 of file CompilationUnit.hpp.

◆ unit_bimap_t

typedef boost::bimap<UnitID, UnitID> tket::unit_bimap_t

A correspondence between two sets of unit IDs.

Definition at line 303 of file UnitID.hpp.

◆ unit_frontier_t

Definition at line 26 of file Slices.hpp.

◆ unit_map_t

typedef std::map<UnitID, UnitID> tket::unit_map_t

Definition at line 312 of file UnitID.hpp.

◆ unit_set_t

typedef std::set<UnitID> tket::unit_set_t

Definition at line 313 of file UnitID.hpp.

◆ unit_vector_t

typedef std::vector<UnitID> tket::unit_vector_t

Definition at line 311 of file UnitID.hpp.

◆ unit_vertport_frontier_t

Definition at line 23 of file MappingFrontier.hpp.

◆ V_iterator

typedef boost::graph_traits<DAG>::vertex_iterator tket::V_iterator

Definition at line 71 of file DAGDefs.hpp.

◆ Vector2b

typedef Eigen::Matrix<bool, 2, 1> tket::Vector2b

Definition at line 30 of file MatrixAnalysis.hpp.

◆ VectorXb

typedef Eigen::Matrix<bool, Eigen::Dynamic, 1> tket::VectorXb

Definition at line 29 of file MatrixAnalysis.hpp.

◆ Vertex

typedef boost::graph_traits<DAG>::vertex_descriptor tket::Vertex

Definition at line 70 of file DAGDefs.hpp.

◆ vertex_map_t

typedef std::unordered_map<Vertex, Vertex> tket::vertex_map_t

Definition at line 62 of file Circuit.hpp.

◆ VertexList

typedef std::list<Vertex> tket::VertexList

Definition at line 74 of file DAGDefs.hpp.

◆ VertexSet

typedef std::unordered_set<Vertex> tket::VertexSet

Definition at line 72 of file DAGDefs.hpp.

◆ VertexVec

typedef std::vector<Vertex> tket::VertexVec

Definition at line 73 of file DAGDefs.hpp.

◆ VertPort

typedef std::pair<Vertex, port_t> tket::VertPort

Definition at line 96 of file DAGDefs.hpp.

◆ VIndex

typedef boost::adj_list_vertex_property_map< DAG, std::size_t, std::size_t&, boost::vertex_index_t> tket::VIndex

Definition at line 78 of file DAGDefs.hpp.

◆ ZXVertPort

typedef std::pair<ZXVert, std::optional<unsigned> > tket::ZXVertPort

Definition at line 25 of file ZXConverters.cpp.

◆ ZXVertPortVec

typedef std::vector<ZXVertPort> tket::ZXVertPortVec

Definition at line 26 of file ZXConverters.cpp.

Enumeration Type Documentation

◆ BasisOrder

enum class tket::BasisOrder
strong

Enum for readout basis and ordering.

Readouts are viewed in increasing lexicographic order (ILO) of the bit's UnitID. This is our default convention for column indexing for ALL readout forms (shots, counts, statevector, and unitaries). e.g. |abc> corresponds to the readout: ('c', 0) --> a, ('c', 1) --> b, ('d', 0) --> c

For statevector and unitaries, the string abc is interpreted as an index in a big-endian (BE) fashion. e.g. the statevector (a_{00}, a_{01}, a_{10}, a_{11})

Some backends (Qiskit, ProjectQ, Quest, etc.) use a DLO-BE (decreasing lexicographic order, big-endian) convention. This is the same as ILO-LE (little-endian) for statevectors and unitaries, but gives shot tables/readouts in a counter-intuitive manner.

Every backend and matrix-based box should have a BasisOrder option which can toggle between ILO-BE (ilo) and DLO-BE (dlo).

Enumerator
ilo 

increasing lexicographic order (big-endian)

dlo 

decreasing lexicographic order (big-endian)

Definition at line 64 of file Constants.hpp.

◆ ClOp

enum class tket::ClOp
strong

An function acting on bits or bit registers.

Enumerator
INVALID 
BitAnd 

Invalid.

BitOr 

Bitwise AND.

BitXor 

Bitwise OR.

BitEq 

Bitwise XOR.

BitNeq 

Bitwise equality.

BitNot 

Bitwise inequality.

BitZero 

Bitwise NOT.

BitOne 

Constant zero bit.

RegAnd 

Constant one bit.

RegOr 

Registerwise AND.

RegXor 

Registerwise OR.

RegEq 

Registerwise XOR.

RegNeq 

Registerwise equality.

RegNot 

Registerwise inequality.

RegZero 

Registerwise NOT.

RegOne 

Constant all-zeros register.

RegLt 

Constant all-ones register.

RegGt 

Integer less-than comparison.

RegLeq 

Integer greater-than comparison.

RegGeq 

Integer less-than-or-equal comparison.

RegAdd 

Integer greater-than-or-equal comparison.

RegSub 

Integer addition.

RegMul 

Integer subtraction.

RegDiv 

Integer multiplication.

RegPow 

Integer division.

RegLsh 

Integer exponentiation.

RegRsh 

Left shift.

RegNeg 

Right shift.

Integer negation

Definition at line 39 of file ClExpr.hpp.

◆ CXConfigType

enum class tket::CXConfigType
strong

Whenever a decomposition choice of Pauli gadgets is presented, users may use either Snake (a.k.a.

cascade, ladder), Tree (i.e. CX balanced tree) or Star (i.e. CXs target a common qubit).

Enumerator
Snake 
Tree 
Star 
MultiQGate 

Definition at line 41 of file PauliTensor.hpp.

◆ EdgeType

enum class tket::EdgeType
strong

Type of a wire in a circuit or input to an op.

Enumerator
Quantum 

A wire carrying quantum information, corresponding to some allocated Qubit.

Since these are persistent, every node in the DAG (except for an input or output) has the same number of Quantum input and output wires.

Classical 

A wire carrying classical information, corresponding to some allocated Bit.

Since these are persistent, every node in the DAG (except for an input or output) has the same number of Classical input and output wires.

Boolean 

A wire carrying a bit of classical information from a classical output port of one op to a classical input port of another, not corresponding to any allocated Bit.

WASM 

A wire to connect the wasm ops in the order they should be executed in.

Corresponding to some allocated WasmState.

Definition at line 23 of file EdgeType.hpp.

◆ GraphColourMethod

enum class tket::GraphColourMethod
strong

A choice of methods to perform graph colouring for Pauli partitioning.

Enumerator
Lazy 

Lazy: does not build the graph before performing the colouring; partitions while iterating through the Pauli tensors in the input order.

LargestFirst 

Builds the graph and then greedily colours by iterating through the vertices, with the highest degree first.

Exhaustive 

Builds the graph, then colours it using the minimum possible number of colours.

Exponential time in the worst case, but usually returns a result in reasonable time.

Definition at line 62 of file PauliPartition.hpp.

◆ Guarantee

enum class tket::Guarantee
strong
Enumerator
Clear 
Preserve 

Definition at line 54 of file CompilerPass.hpp.

◆ OpType

enum class tket::OpType
strong

Named operation types.

When a unitary matrix is specified in the descriptions below, the order of rows and columns follows the BasisOrder::ilo convention.

Operations have defined phase.

Enumerator
Input 

Quantum input node of the circuit.

Output 

Quantum output node of the circuit.

Create 

Quantum node with no predecessors, implicitly in zero state.

Discard 

Quantum node with no successors, not composable with input nodes of other circuits.

ClInput 

Classical input node of the circuit.

ClOutput 

Classical output node of the circuit.

WASMInput 

WASM input node of the circuit.

WASMOutput 

WASM output node of the circuit.

Barrier 

No-op that must be preserved by compilation.

Label 

FlowOp introducing a target for Branch or Goto commands.

Branch 

Execution jumps to a label if a condition bit is true (1), otherwise continues to next command.

Goto 

Execution jumps to a label unconditionally.

Stop 

Execution halts and the program terminates.

ClassicalTransform 

A general classical operation where all inputs are also outputs.

WASM 

Op containing a classical wasm function call.

SetBits 

An operation to set some bits to specified values.

CopyBits 

An operation to copy some bit values.

RangePredicate 

A classical predicate defined by a range of values in binary encoding.

ExplicitPredicate 

A classical predicate defined by a truth table.

ExplicitModifier 

An operation defined by a truth table that modifies one bit.

MultiBit 

A classical operation applied to multiple bits simultaneously.

Phase 

\( \mathrm{Phase}(\alpha) = \left[ \begin{array}{c} e^{i \pi \alpha} \end{array} \right] \)

\( \left[ \begin{array}{cc} 1 & 0 \\ 0 & -1 \end{array} \right] \)

\( \left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right] \)

\( \left[ \begin{array}{cc} 0 & -i \\ i & 0 \end{array} \right] \)

\( \left[ \begin{array}{cc} 1 & 0 \\ 0 & i \end{array} \right] = \mathrm{U1}(\frac12) \)

Sdg 

\( \left[ \begin{array}{cc} 1 & 0 \\ 0 & -i \end{array} \right] = \mathrm{U1}(-\frac12) \)

\( \left[ \begin{array}{cc} 1 & 0 \\ 0 & e^{i\pi/4} \end{array} \right] = \mathrm{U1}(\frac14) \)

Tdg 

\( \left[ \begin{array}{cc} 1 & 0 \\ 0 & e^{-i\pi/4} \end{array} \right] \equiv \mathrm{U1}(-\frac14) \)

\( \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & -i \\ -i & 1 \end{array} \right] = \mathrm{Rx}(\frac12) \)

Vdg 

\( \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & i \\ i & 1 \end{array} \right] = \mathrm{Rx}(-\frac12) \)

SX 

\( \frac{1}{2} \left[ \begin{array}{cc} 1+i & 1-i \\ 1-i & 1+i \end{array} \right] = e^{\frac{i\pi}{4}}\mathrm{Rx}(\frac12) \)

SXdg 

\( \frac{1}{2} \left[ \begin{array}{cc} 1-i & 1+i \\ 1+i & 1-i \end{array} \right] = e^{\frac{-i\pi}{4}}\mathrm{Rx}(-\frac12) \)

\( \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right] \)

Rx 

\( \mathrm{Rx}(\alpha) = e^{-\frac12 i \pi \alpha X} = \left[ \begin{array}{cc} \cos\frac{\pi\alpha}{2} & -i\sin\frac{\pi\alpha}{2} \\ -i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} \end{array} \right] \)

Ry 

\( \mathrm{Ry}(\alpha) = e^{-\frac12 i \pi \alpha Y} = \left[ \begin{array}{cc} \cos\frac{\pi\alpha}{2} & -\sin\frac{\pi\alpha}{2} \\ \sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} \end{array} \right] \)

Rz 

\( \mathrm{Rz}(\alpha) = e^{-\frac12 i \pi \alpha Z} = \left[ \begin{array}{cc} e^{-\frac12 i \pi\alpha} & 0 \\ 0 & e^{\frac12 i \pi\alpha} \end{array} \right] \)

U3 

\( \mathrm{U3}(\theta, \phi, \lambda) = \left[ \begin{array}{cc} \cos\frac{\pi\theta}{2} & -e^{i\pi\lambda} \sin\frac{\pi\theta}{2} \\ e^{i\pi\phi} \sin\frac{\pi\theta}{2} & e^{i\pi(\lambda+\phi)} \cos\frac{\pi\theta}{2} \end{array} \right] = e^{\frac12 i\pi(\lambda+\phi)} \mathrm{Rz}(\phi) \mathrm{Ry}(\theta) \mathrm{Rz}(\lambda) \)

U2 

\( \mathrm{U2}(\phi, \lambda) = \mathrm{U3}(\frac12, \phi, \lambda) = e^{\frac12 i\pi(\lambda+\phi)} \mathrm{Rz}(\phi) \mathrm{Ry}(\frac12) \mathrm{Rz}(\lambda) \)

U1 

\( \mathrm{U1}(\lambda) = \mathrm{U3}(0, 0, \lambda) = e^{\frac12 i\pi\lambda} \mathrm{Rz}(\lambda) \)

GPI 

\( \mathrm{GPI}(\phi) = \left[ \begin{array}{cc} 0 & e^{-i\pi\phi} \\ e^{i\pi\phi} & 0 \end{array} \right] \)

GPI2 

\( \mathrm{GPI2}(\phi) = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & -ie^{-i\pi\phi} \\ -ie^{i\pi\phi} & 1 \end{array} \right] \)

AAMS 

\( \mathrm{AAMS}(\theta, \phi_0, \phi_1) = \left[ \begin{array}{cccc} \cos\frac{\pi\theta}{2} & 0 & 0 & -ie^{-i\pi(\phi_0+\phi_1)}\sin\frac{\pi\theta}{2} \\ 0 & \cos\frac{\pi\theta}{2} & -ie^{i\pi(\phi_1-\phi_0)}\sin\frac{\pi\theta}{2} & 0 \\ 0 & -ie^{i\pi(\phi_0-\phi_1)}\sin\frac{\pi\theta}{2} & \cos\frac{\pi\theta}{2} & 0 \\ -ie^{i\pi(\phi_0+\phi_1)}\sin\frac{\pi\theta}{2} & 0 & 0 & \cos\frac{\pi\theta}{2} \end{array} \right] \)

TK1 

\( \mathrm{TK1}(\alpha, \beta, \gamma) = \mathrm{Rz}(\alpha) \mathrm{Rx}(\beta) \mathrm{Rz}(\gamma) \)

TK2 

\( \mathrm{TK2}(\alpha, \beta, \gamma) = \mathrm{XXPhase}(\alpha) \mathrm{YYPhase}(\beta) \mathrm{ZZPhase}(\gamma) \)

CX 

Controlled OpType::X.

CY 

Controlled OpType::Y.

CZ 

Controlled OpType::Z.

CH 

Controlled OpType::H.

CV 

Controlled OpType::V.

\( \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1}{\sqrt 2} & -i \frac{1}{\sqrt 2} \\ 0 & 0 & -i \frac{1}{\sqrt 2} & \frac{1}{\sqrt 2} \end{array} \right] \)

CVdg 

Controlled OpType::Vdg.

\( \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1}{\sqrt 2} & i \frac{1}{\sqrt 2} \\ 0 & 0 & i \frac{1}{\sqrt 2} & \frac{1}{\sqrt 2} \end{array} \right] \)

CSX 

Controlled OpType::SX.

\( \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1+i}{2} & \frac{1-i}{2} \\ 0 & 0 & \frac{1-i}{2} & \frac{1+i}{2} \end{array} \right] \)

CSXdg 

Controlled OpType::SXdg.

\( \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1-i}{2} & \frac{1+i}{2} \\ 0 & 0 & \frac{1+i}{2} & \frac{1-i}{2} \end{array} \right] \)

CS 

Controlled OpType::S.

\( \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & i \end{array} \right] = \mathrm{CU1}(\frac12) \)

CSdg 

Controlled OpType::Sdg.

\( \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -i \end{array} \right] = \mathrm{CU1}(-\frac12) \)

CRz 

Controlled OpType::Rz.

\( \mathrm{CRz}(\alpha) = \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{-\frac12 i \pi\alpha} & 0 \\ 0 & 0 & 0 & e^{\frac12 i \pi\alpha} \end{array} \right] \)

The phase parameter \( \alpha \) is defined modulo \( 4 \).

CRx 

Controlled OpType::Rx.

\( \mathrm{CRx}(\alpha) = \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos \frac{\pi \alpha}{2} & -i \sin \frac{\pi \alpha}{2} \\ 0 & 0 & -i \sin \frac{\pi \alpha}{2} & \cos \frac{\pi \alpha}{2} \end{array} \right] \)

The phase parameter \( \alpha \) is defined modulo \( 4 \).

CRy 

Controlled OpType::Ry.

\( \mathrm{CRy}(\alpha) = \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos \frac{\pi \alpha}{2} & -\sin \frac{\pi \alpha}{2} \\ 0 & 0 & \sin \frac{\pi \alpha}{2} & \cos \frac{\pi \alpha}{2} \end{array} \right] \)

The phase parameter \( \alpha \) is defined modulo \( 4 \).

CU1 

Controlled OpType::U1.

\( \mathrm{CU1}(\alpha) = \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\pi\alpha} \end{array} \right] \)

CU3 

Controlled OpType::U3.

PhaseGadget 

\( \alpha \mapsto e^{-\frac12 i \pi\alpha Z^{\otimes n}} \)

CCX 

Controlled OpType::CX.

SWAP 

Swap two qubits.

CSWAP 

Controlled OpType::SWAP.

BRIDGE 

Three-qubit gate that swaps the first and third qubits.

noop 

Identity.

Measure 

Measure a qubit, producing a classical output.

Collapse 

Measure a qubit producing no output.

Reset 

Reset a qubit to the zero state.

ECR 

\( \frac{1}{\sqrt 2} \left[ \begin{array}{cccc} 0 & 0 & 1 & i \\ 0 & 0 & i & 1 \\ 1 & -i & 0 & 0 \\ -i & 1 & 0 & 0 \end{array} \right] \)

ISWAP 

\( \alpha \mapsto e^{\frac14 i \pi\alpha (X \otimes X + Y \otimes Y)} = \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \cos\frac{\pi\alpha}{2} & i\sin\frac{\pi\alpha}{2} & 0 \\ 0 & i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] \)

Also known as an XY gate.

PhasedX 

\( (\alpha, \beta) \mapsto \mathrm{Rz}(\beta) \mathrm{Rx}(\alpha) \mathrm{Rz}(-\beta) \)

NPhasedX 

PhasedX gates on multiple qubits.

ZZMax 

\( \mathrm{ZZPhase}(\frac12) \)

XXPhase 

\( \alpha \mapsto e^{-\frac12 i \pi\alpha (X \otimes X)} = \left[ \begin{array}{cccc} \cos\frac{\pi\alpha}{2} & 0 & 0 & -i\sin\frac{\pi\alpha}{2} \\ 0 & \cos\frac{\pi\alpha}{2} & -i\sin\frac{\pi\alpha}{2} & 0 \\ 0 & -i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} & 0 \\ -i\sin\frac{\pi\alpha}{2} & 0 & 0 & \cos\frac{\pi\alpha}{2} \end{array} \right] \)

YYPhase 

\( \alpha \mapsto e^{-\frac12 i \pi\alpha (Y \otimes Y)} = \left[ \begin{array}{cccc} \cos\frac{\pi\alpha}{2} & 0 & 0 & i\sin\frac{\pi\alpha}{2} \\ 0 & \cos\frac{\pi\alpha}{2} & -i\sin\frac{\pi\alpha}{2} & 0 \\ 0 & -i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} & 0 \\ i\sin\frac{\pi\alpha}{2} & 0 & 0 & \cos\frac{\pi\alpha}{2} \end{array} \right] \)

ZZPhase 

\( \alpha \mapsto e^{-\frac12 i \pi\alpha (Z \otimes Z)} = \left[ \begin{array}{cccc} e^{-\frac12 i \pi\alpha} & 0 & 0 & 0 \\ 0 & e^{\frac12 i \pi\alpha} & 0 & 0 \\ 0 & 0 & e^{\frac12 i \pi\alpha} & 0 \\ 0 & 0 & 0 & e^{-\frac12 i \pi\alpha} \end{array} \right] \)

XXPhase3 

Three-qubit phase MSGate.

ESWAP 

\( \alpha \mapsto e^{-\frac12 i\pi\alpha \cdot \mathrm{SWAP}} = \left[ \begin{array}{cccc} e^{-\frac12 i \pi\alpha} & 0 & 0 & 0 \\ 0 & \cos\frac{\pi\alpha}{2} & -i\sin\frac{\pi\alpha}{2} & 0 \\ 0 & -i\sin\frac{\pi\alpha}{2} & \cos\frac{\pi\alpha}{2} & 0 \\ 0 & 0 & 0 & e^{-\frac12 i \pi\alpha} \end{array} \right] \)

FSim 

\( (\alpha, \beta) \mapsto \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \cos \pi\alpha & -i\sin \pi\alpha & 0 \\ 0 & -i\sin \pi\alpha & \cos \pi\alpha & 0 \\ 0 & 0 & 0 & e^{-i\pi\beta} \end{array} \right] \)

Sycamore 

Fixed instance of a OpType::FSim gate with parameters \( (\frac12, \frac16) \): \( \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 0 & -i & 0 \\ 0 & -i & 0 & 0 \\ 0 & 0 & 0 & e^{-i\pi/6} \end{array} \right] \).

ISWAPMax 

Fixed instance of a OpType::ISWAP gate with parameter \( 1.0 \): \( \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] \).

PhasedISWAP 

\( (p, t) \mapsto \left[ \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & \cos\frac{\pi t}{2} & i\sin\frac{\pi t}{2}e^{2i\pi p} & 0 \\ 0 & i\sin\frac{\pi t}{2}e^{-2i\pi p} & \cos\frac{\pi t}{2} & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] \)

This is equivalent to:

--Rz(+p)---\    /---Rz(-p)--
          ISWAP(t)
--Rz(-p)---/    \---Rz(+p)--
CnRy 

Multiply-controlled OpType::Ry.

The phase parameter is defined modulo \( 4 \).

CnRx 

Multiply-controlled OpType::Rx.

The phase parameter is defined modulo \( 4 \).

CnRz 

Multiply-controlled OpType::Rz.

The phase parameter is defined modulo \( 4 \).

CnX 

Multiply-controlled OpType::X.

CnZ 

Multiply-controlled OpType::Z.

CnY 

Multiply-controlled OpType::Y.

CircBox 

See CircBox.

Unitary1qBox 

See Unitary1qBox.

Unitary2qBox 

See Unitary2qBox.

Unitary3qBox 

See Unitary3qBox.

ExpBox 

See ExpBox.

PauliExpBox 

See PauliExpBox.

PauliExpPairBox 

See PauliExpPairBox.

PauliExpCommutingSetBox 

See PauliExpCommutingSetBox.

TermSequenceBox 

See TermSequenceBox.

CliffBox 

NYI.

CustomGate 

See CustomGate.

PhasePolyBox 

See PhasePolyBox.

QControlBox 

See QControlBox.

MultiplexorBox 

See MultiplexorBox.

MultiplexedRotationBox 

See MultiplexedRotationBox.

MultiplexedU2Box 

See MultiplexedU2Box.

MultiplexedTensoredU2Box 

See MultiplexedTensoredU2Box.

StatePreparationBox 

See StatePreparationBox.

DiagonalBox 

See DiagonalBox.

ConjugationBox 

See ConjugationBox.

Conditional 

See Conditional.

ProjectorAssertionBox 

See ProjectorAssertionBox.

StabiliserAssertionBox 

See StabiliserAssertionBox.

ToffoliBox 

See ToffoliBox.

UnitaryTableauBox 

See UnitaryTableauBox.

DummyBox 

See DummyBox.

ClExpr 

Function defined over bits and sequences of bits treated as integers.

Definition at line 29 of file OpType.hpp.

◆ Pauli

Symbols for the Pauli operators (and identity)

Enumerator

Definition at line 26 of file PauliTensor.hpp.

◆ PauliPartitionStrat

enum class tket::PauliPartitionStrat
strong

A choice of strategies to partition Pauli tensors into sets.

Enumerator
NonConflictingSets 

Sets of tensors with no conflicting Paulis; requires no CXs for diagonalisation.

CommutingSets 

Sets of mutually commuting tensors; requires O(n^2) CXs for diagonalisation.

Definition at line 46 of file PauliPartition.hpp.

◆ PortType

enum class tket::PortType
strong

Whether a vertex port is out-going (source) or in-coming (target)

Enumerator
Source 
Target 

Definition at line 44 of file DAGDefs.hpp.

◆ RecursionNodeType

enum class tket::RecursionNodeType
strong

Indicates whether a recursion step in recursive_demultiplex_rotation is either a left child, a right child, or the root.

Enumerator
Left 
Right 
Root 

Definition at line 69 of file Multiplexor.cpp.

◆ ReverseType

Enumerator
dagger 
transpose 

Definition at line 201 of file Circuit.hpp.

◆ SafetyMode

enum class tket::SafetyMode
strong
Enumerator
Audit 
Default 
Off 

Definition at line 56 of file CompilerPass.hpp.

◆ ToffoliBoxSynthStrat

enum class tket::ToffoliBoxSynthStrat
strong

Strategies for synthesising ToffoliBoxes Matching: use multiplexors to perform parallel swaps on hypercubes Cycle: use CnX gates to perform transpositions.

Enumerator
Matching 
Cycle 

Definition at line 28 of file ToffoliBox.hpp.

◆ UnitType

enum class tket::UnitType
strong

Type of information held.

Enumerator
Qubit 
Bit 
WasmState 

Definition at line 38 of file UnitID.hpp.

◆ VertexType

enum class tket::VertexType
strong
Enumerator
Quantum 
Classical 
Measure 

Definition at line 36 of file DAGProperties.cpp.

◆ ZXPortType

enum class tket::ZXPortType
strong
Enumerator
In 
Out 

Definition at line 23 of file ZXConverters.cpp.

Function Documentation

◆ aas_routing_pass()

PassPtr tket::aas_routing_pass ( const Architecture arc,
const unsigned  lookahead = 1,
const aas::CNotSynthType  cnotsynthtype = aas::CNotSynthType::Rec 
)

execute architecture aware synthesis on a given architecture for an allready place circuit, only for circuit which contains Cx+Rz+H gates this pass is not able to handle implicit wire swaps

Parameters
arcarchitecture to route on
lookaheadparameter for the recursion depth in the algorithm, the value should be > 0
cnotsynthtypeparameter for the type of cnot synth
Returns
passpointer to perform architecture aware synthesis

Definition at line 625 of file PassGenerators.cpp.

◆ add_conditional_zx()

std::pair< std::pair< ZXVertPort, ZXVertPort >, ZXVertPortVec > tket::add_conditional_zx ( ZXDiagram zxd,
const ZXVert left,
const ZXVert right,
const QuantumType qtype 
)

Definition at line 62 of file ZXConverters.cpp.

◆ add_cx_u1()

void tket::add_cx_u1 ( Circuit circ,
const std::vector< MultiplexedU2Commands > &  m_u2_decomps,
unsigned  n_controls_,
unsigned  n_targets_ 
)

Definition at line 917 of file Multiplexor.cpp.

◆ add_latex_for_command()

void tket::add_latex_for_command ( LatexContext &  context,
const Command command 
)

Definition at line 34 of file latex_drawing.cpp.

◆ add_multi_rz()

void tket::add_multi_rz ( Circuit circ,
const std::vector< ctrl_op_map_t > &  all_multiplexed_rz,
unsigned  n_controls_,
unsigned  n_targets_ 
)

Definition at line 992 of file Multiplexor.cpp.

◆ add_n_bit_and()

std::pair< ZXVertPortVec, ZXVertPort > tket::add_n_bit_and ( ZXDiagram zxd,
unsigned  n,
const QuantumType qtype 
)

Definition at line 89 of file ZXConverters.cpp.

◆ add_noop_frames()

void tket::add_noop_frames ( std::vector< Cycle > &  cycles,
Circuit circ 
)

Definition at line 47 of file FrameRandomisation.cpp.

◆ add_switch()

std::pair< ZXVertPort, ZXVertPort > tket::add_switch ( ZXDiagram zxd,
const bool &  on_value,
const QuantumType qtype 
)

Definition at line 36 of file ZXConverters.cpp.

◆ all_classical_types()

const OpTypeSet & tket::all_classical_types ( )

Set of all classical gates.

Definition at line 105 of file OpTypeFunctions.cpp.

◆ all_controlled_gate_types()

const OpTypeSet & tket::all_controlled_gate_types ( )

Set of all controlled gates.

Definition at line 130 of file OpTypeFunctions.cpp.

◆ all_gate_types()

const OpTypeSet & tket::all_gate_types ( )

Set of all elementary gates.

Definition at line 27 of file OpTypeFunctions.cpp.

◆ all_multi_qubit_types()

const OpTypeSet & tket::all_multi_qubit_types ( )

Set of all gates over more than one qubit.

Definition at line 57 of file OpTypeFunctions.cpp.

◆ all_projective_types()

const OpTypeSet & tket::all_projective_types ( )

Set of all measurement and reset gates.

Definition at line 122 of file OpTypeFunctions.cpp.

◆ all_single_qubit_types()

const OpTypeSet & tket::all_single_qubit_types ( )

Set of all gates over a single qubit.

Definition at line 91 of file OpTypeFunctions.cpp.

◆ all_single_qubit_unitary_types()

const OpTypeSet & tket::all_single_qubit_unitary_types ( )

Set of all single-qubit gates that can be expressed as TK1.

Definition at line 79 of file OpTypeFunctions.cpp.

◆ AndOp()

std::shared_ptr< ExplicitPredicateOp > tket::AndOp ( )

Binary AND operator.

Definition at line 442 of file ClassicalOps.cpp.

◆ AndWithOp()

std::shared_ptr< ExplicitModifierOp > tket::AndWithOp ( )

In-place AND with another input.

Definition at line 463 of file ClassicalOps.cpp.

◆ append_commuting_pauli_gadget_set_as_box()

void tket::append_commuting_pauli_gadget_set_as_box ( Circuit circ,
const std::list< SpSymPauliTensor > &  gadgets,
CXConfigType  cx_config 
)

Constructs a PauliExpCommutingSetBox for a set of mutually commuting pauli gadgets and appends it to a circuit.

As the pauli gadgets all commute, the ordering does not matter semantically, but may yield different synthesised circuits.

Parameters
circThe circuit to append the box to
gadgetsDescription of the pauli gadgets; coefficients give the rotation angles in half-turns
cx_configThe CX configuration to be used during synthesis

Definition at line 718 of file PauliExpBoxes.cpp.

◆ append_pauli_gadget_pair_as_box()

void tket::append_pauli_gadget_pair_as_box ( Circuit circ,
const SpSymPauliTensor pauli0,
const SpSymPauliTensor pauli1,
CXConfigType  cx_config 
)

Constructs a PauliExpPairBox for a pair of pauli gadgets and appends it to a circuit.

The pauli gadgets may or may not commute, so the ordering matters.

Parameters
circThe circuit to append the box to
pauli0The pauli operator of the first gadget; coefficient gives the rotation angle in half-turns
pauli1The pauli operator of the second gadget; coefficient gives the rotation angle in half-turns
cx_configThe CX configuration to be used during synthesis

Definition at line 686 of file PauliExpBoxes.cpp.

◆ append_single_pauli_gadget_as_pauli_exp_box()

void tket::append_single_pauli_gadget_as_pauli_exp_box ( Circuit circ,
const SpSymPauliTensor pauli,
CXConfigType  cx_config 
)

Constructs a PauliExpBox for a single pauli gadget and appends it to a circuit.

Parameters
circThe circuit to append the box to
pauliThe pauli operator of the gadget; coefficient gives the rotation angle in half-turns
cx_configThe CX configuration to be used during synthesis

Definition at line 674 of file PauliExpBoxes.cpp.

◆ apply_conjugations()

void tket::apply_conjugations ( SpSymPauliTensor qps,
const Conjugations conjugations 
)

Applies Clifford conjugations to a SpSymPauliTensor.

Definition at line 310 of file Diagonalisation.cpp.

◆ apply_qubit_permutation() [1/2]

Eigen::MatrixXcd tket::apply_qubit_permutation ( const Eigen::MatrixXcd &  m,
const qubit_map_t perm 
)

Definition at line 280 of file MatrixAnalysis.cpp.

◆ apply_qubit_permutation() [2/2]

Eigen::VectorXcd tket::apply_qubit_permutation ( const Eigen::VectorXcd &  v,
const qubit_map_t perm 
)

Definition at line 286 of file MatrixAnalysis.cpp.

◆ approx_0()

bool tket::approx_0 ( const Expr e,
double  tol = EPS 
)

Test if an expression is approximately zero.

Parameters
eexpression
toltolerance
Returns
whether e is within tol of zero

Definition at line 24 of file Expression.cpp.

◆ approx_eq()

bool tket::approx_eq ( double  x,
double  y,
unsigned  mod = 2,
double  tol = EPS 
)

Test approximate equality of two values modulo n.

Parameters
xfirst value
ysecond value
modmodulus
toltolerance
Returns
whether x is within tol of y modulo mod

Definition at line 35 of file Expression.cpp.

◆ as_gate_ptr()

Gate_ptr tket::as_gate_ptr ( Op_ptr  op)

Cast a general Op (of gate type) to a Gate.

Exceptions
BadOpTypeif op is not a gate.

Definition at line 25 of file GatePtr.cpp.

◆ bin_to_dec()

unsigned long long tket::bin_to_dec ( const std::vector< bool > &  bin)

convert an bit vector to its decimal representation big-endian

Definition at line 59 of file HelperFunctions.cpp.

◆ binary_LLT_decomposition()

std::pair< MatrixXb, MatrixXb > tket::binary_LLT_decomposition ( const MatrixXb a)

Definition at line 40 of file MatrixAnalysis.cpp.

◆ boundary_elem()

boundary_t::iterator tket::boundary_elem ( const Circuit circ,
const UnitID unit 
)

Definition at line 287 of file macro_circ_info.cpp.

◆ c_debug_default_name()

const std::string & tket::c_debug_default_name ( )

Definition at line 112 of file UnitID.cpp.

◆ c_debug_one_prefix()

const std::string & tket::c_debug_one_prefix ( )

Definition at line 106 of file UnitID.cpp.

◆ c_debug_zero_prefix()

const std::string & tket::c_debug_zero_prefix ( )

Definition at line 100 of file UnitID.cpp.

◆ c_default_reg()

const std::string & tket::c_default_reg ( )

Definition at line 82 of file UnitID.cpp.

◆ c_permutation_scratch_name()

const std::string & tket::c_permutation_scratch_name ( )

Definition at line 118 of file UnitID.cpp.

◆ cast_coeff()

template<typename OriginalCoeff , typename NewCoeff >
NewCoeff tket::cast_coeff ( const OriginalCoeff &  coeff)
delete

Cast a coefficient to a different type.

Casting to no_coeff_t just drops the coefficient to focus on the string. Casting from no_coeff_t treats it as the scalar 1.

Casting to quarter_turns_t throws an exception if value is not in the range {1, i, -1, -i}.

Casting from Expr throws an exception if the coefficient is symbolic.

Parameters
coeffThe coefficient to cast to another type.

◆ cast_coeff< Complex, Complex >() [1/2]

template<>
Complex tket::cast_coeff< Complex, Complex > ( const Complex coeff)

Definition at line 166 of file PauliTensor.cpp.

◆ cast_coeff< Complex, Complex >() [2/2]

template<>
Complex tket::cast_coeff< Complex, Complex > ( const Complex coeff)

Definition at line 166 of file PauliTensor.cpp.

◆ cast_coeff< Complex, Expr >() [1/2]

template<>
Expr tket::cast_coeff< Complex, Expr > ( const Complex coeff)

Definition at line 170 of file PauliTensor.cpp.

◆ cast_coeff< Complex, Expr >() [2/2]

template<>
Expr tket::cast_coeff< Complex, Expr > ( const Complex coeff)

Definition at line 170 of file PauliTensor.cpp.

◆ cast_coeff< Complex, no_coeff_t >() [1/2]

template<>
no_coeff_t tket::cast_coeff< Complex, no_coeff_t > ( const Complex )

Definition at line 147 of file PauliTensor.cpp.

◆ cast_coeff< Complex, no_coeff_t >() [2/2]

template<>
no_coeff_t tket::cast_coeff< Complex, no_coeff_t > ( const Complex )

Definition at line 147 of file PauliTensor.cpp.

◆ cast_coeff< Complex, quarter_turns_t >() [1/2]

template<>
quarter_turns_t tket::cast_coeff< Complex, quarter_turns_t > ( const Complex coeff)

Definition at line 151 of file PauliTensor.cpp.

◆ cast_coeff< Complex, quarter_turns_t >() [2/2]

template<>
quarter_turns_t tket::cast_coeff< Complex, quarter_turns_t > ( const Complex coeff)

Definition at line 151 of file PauliTensor.cpp.

◆ cast_coeff< Expr, Complex >() [1/2]

template<>
Complex tket::cast_coeff< Expr, Complex > ( const Expr coeff)

Definition at line 188 of file PauliTensor.cpp.

◆ cast_coeff< Expr, Complex >() [2/2]

template<>
Complex tket::cast_coeff< Expr, Complex > ( const Expr coeff)

Definition at line 188 of file PauliTensor.cpp.

◆ cast_coeff< Expr, Expr >() [1/2]

template<>
Expr tket::cast_coeff< Expr, Expr > ( const Expr coeff)

Definition at line 197 of file PauliTensor.cpp.

◆ cast_coeff< Expr, Expr >() [2/2]

template<>
Expr tket::cast_coeff< Expr, Expr > ( const Expr coeff)

Definition at line 197 of file PauliTensor.cpp.

◆ cast_coeff< Expr, no_coeff_t >() [1/2]

template<>
no_coeff_t tket::cast_coeff< Expr, no_coeff_t > ( const Expr )

Definition at line 175 of file PauliTensor.cpp.

◆ cast_coeff< Expr, no_coeff_t >() [2/2]

template<>
no_coeff_t tket::cast_coeff< Expr, no_coeff_t > ( const Expr )

Definition at line 175 of file PauliTensor.cpp.

◆ cast_coeff< Expr, quarter_turns_t >() [1/2]

template<>
quarter_turns_t tket::cast_coeff< Expr, quarter_turns_t > ( const Expr coeff)

Definition at line 179 of file PauliTensor.cpp.

◆ cast_coeff< Expr, quarter_turns_t >() [2/2]

template<>
quarter_turns_t tket::cast_coeff< Expr, quarter_turns_t > ( const Expr coeff)

Definition at line 179 of file PauliTensor.cpp.

◆ cast_coeff< no_coeff_t, Complex >() [1/2]

template<>
Complex tket::cast_coeff< no_coeff_t, Complex > ( const no_coeff_t )

Definition at line 94 of file PauliTensor.cpp.

◆ cast_coeff< no_coeff_t, Complex >() [2/2]

template<>
Complex tket::cast_coeff< no_coeff_t, Complex > ( const no_coeff_t )

Definition at line 94 of file PauliTensor.cpp.

◆ cast_coeff< no_coeff_t, Expr >() [1/2]

template<>
Expr tket::cast_coeff< no_coeff_t, Expr > ( const no_coeff_t )

Definition at line 98 of file PauliTensor.cpp.

◆ cast_coeff< no_coeff_t, Expr >() [2/2]

template<>
Expr tket::cast_coeff< no_coeff_t, Expr > ( const no_coeff_t )

Definition at line 98 of file PauliTensor.cpp.

◆ cast_coeff< no_coeff_t, no_coeff_t >() [1/2]

Definition at line 86 of file PauliTensor.cpp.

◆ cast_coeff< no_coeff_t, no_coeff_t >() [2/2]

Definition at line 86 of file PauliTensor.cpp.

◆ cast_coeff< no_coeff_t, quarter_turns_t >() [1/2]

Definition at line 90 of file PauliTensor.cpp.

◆ cast_coeff< no_coeff_t, quarter_turns_t >() [2/2]

Definition at line 90 of file PauliTensor.cpp.

◆ cast_coeff< quarter_turns_t, Complex >() [1/2]

template<>
Complex tket::cast_coeff< quarter_turns_t, Complex > ( const quarter_turns_t coeff)

Definition at line 112 of file PauliTensor.cpp.

◆ cast_coeff< quarter_turns_t, Complex >() [2/2]

template<>
Complex tket::cast_coeff< quarter_turns_t, Complex > ( const quarter_turns_t coeff)

Definition at line 112 of file PauliTensor.cpp.

◆ cast_coeff< quarter_turns_t, Expr >() [1/2]

template<>
Expr tket::cast_coeff< quarter_turns_t, Expr > ( const quarter_turns_t coeff)

Definition at line 129 of file PauliTensor.cpp.

◆ cast_coeff< quarter_turns_t, Expr >() [2/2]

template<>
Expr tket::cast_coeff< quarter_turns_t, Expr > ( const quarter_turns_t coeff)

Definition at line 129 of file PauliTensor.cpp.

◆ cast_coeff< quarter_turns_t, no_coeff_t >() [1/2]

Definition at line 103 of file PauliTensor.cpp.

◆ cast_coeff< quarter_turns_t, no_coeff_t >() [2/2]

Definition at line 103 of file PauliTensor.cpp.

◆ cast_coeff< quarter_turns_t, quarter_turns_t >() [1/2]

Definition at line 107 of file PauliTensor.cpp.

◆ cast_coeff< quarter_turns_t, quarter_turns_t >() [2/2]

Definition at line 107 of file PauliTensor.cpp.

◆ cast_container()

template<typename OriginalContainer , typename NewContainer >
NewContainer tket::cast_container ( const OriginalContainer &  cont)
delete

Cast between two different Pauli container types.

Casting into a type with restricted indices (e.g. DensePauliMap expecting default register qubits) may throw an exception.

Parameters
contThe Pauli container to convert to another type.

◆ cast_container< DensePauliMap, DensePauliMap >() [1/2]

Definition at line 80 of file PauliTensor.cpp.

◆ cast_container< DensePauliMap, DensePauliMap >() [2/2]

Definition at line 80 of file PauliTensor.cpp.

◆ cast_container< DensePauliMap, QubitPauliMap >() [1/2]

Definition at line 48 of file PauliTensor.cpp.

◆ cast_container< DensePauliMap, QubitPauliMap >() [2/2]

Definition at line 48 of file PauliTensor.cpp.

◆ cast_container< QubitPauliMap, DensePauliMap >() [1/2]

Definition at line 59 of file PauliTensor.cpp.

◆ cast_container< QubitPauliMap, DensePauliMap >() [2/2]

Definition at line 59 of file PauliTensor.cpp.

◆ cast_container< QubitPauliMap, QubitPauliMap >() [1/2]

Definition at line 42 of file PauliTensor.cpp.

◆ cast_container< QubitPauliMap, QubitPauliMap >() [2/2]

Definition at line 42 of file PauliTensor.cpp.

◆ check_easy_diagonalise()

void tket::check_easy_diagonalise ( std::list< SpSymPauliTensor > &  gadgets,
std::set< Qubit > &  qubits,
Circuit circ 
)

Check whether there are any qubits which only requires a single qubit Clifford to make all Paulis I or Z.

Definition at line 24 of file Diagonalisation.cpp.

◆ check_iterators_equality()

template<typename T >
bool tket::check_iterators_equality ( const T first,
const T second 
)

Check equality of each element of first and second when first and second can provide begin, end iterators.

Definition at line 37 of file HelperFunctions.hpp.

◆ check_pair_compatibility()

std::optional< std::pair< Pauli, Pauli > > tket::check_pair_compatibility ( const Qubit qb1,
const Qubit qb2,
const std::list< SpSymPauliTensor > &  gadgets 
)

Given two qubits, attempt to find a basis in which a single CX will make the Paulis on one of qubits fully diagonal.

Definition at line 70 of file Diagonalisation.cpp.

◆ circuit_to_cm_tableau()

ChoiMixTableau tket::circuit_to_cm_tableau ( const Circuit circ)

Construct a ChoiMixTableau for a given circuit.

Will incorporate qubit initialisations and discarding into the circuit. Will throw an exception if it contains non-Clifford gates.

Definition at line 23 of file ChoiMixTableauConverters.cpp.

◆ circuit_to_pauli_graph()

PauliGraph tket::circuit_to_pauli_graph ( const Circuit circ)

Definition at line 23 of file PauliGraphConverters.cpp.

◆ circuit_to_unitary_rev_tableau()

UnitaryRevTableau tket::circuit_to_unitary_rev_tableau ( const Circuit circ)

Definition at line 249 of file UnitaryTableauConverters.cpp.

◆ circuit_to_unitary_tableau()

UnitaryTableau tket::circuit_to_unitary_tableau ( const Circuit circ)

Construct the tableau for a given circuit.

Will throw an exception if it contains non-Clifford gates.

Definition at line 21 of file UnitaryTableauConverters.cpp.

◆ circuit_to_zx()

std::pair< zx::ZXDiagram, boost::bimap< zx::ZXVert, Vertex > > tket::circuit_to_zx ( const Circuit circuit)

Construct a zx diagram from a given circuit.

Return the zx diagram and a map between the zx boundary vertices and the circuit boundary vertices.

Definition at line 558 of file ZXConverters.cpp.

◆ circuit_to_zx_recursive()

BoundaryVertMap tket::circuit_to_zx_recursive ( const Circuit circ,
ZXDiagram zxd,
bool  add_boundary 
)

Definition at line 111 of file ZXConverters.cpp.

◆ ClassicalCX()

std::shared_ptr< ClassicalTransformOp > tket::ClassicalCX ( )

Classical CNOT transform.

Definition at line 428 of file ClassicalOps.cpp.

◆ ClassicalX()

std::shared_ptr< ClassicalTransformOp > tket::ClassicalX ( )

Classical NOT transform.

Definition at line 421 of file ClassicalOps.cpp.

◆ clean_frontier()

void tket::clean_frontier ( ZXDiagram diag,
ZXVertVec frontier,
Circuit circ,
std::map< ZXVert, unsigned > &  qubit_map,
std::map< ZXVert, ZXVert > &  input_qubits 
)

Definition at line 586 of file ZXConverters.cpp.

◆ cm_tableau_to_exact_circuit()

std::pair< Circuit, qubit_map_t > tket::cm_tableau_to_exact_circuit ( const ChoiMixTableau tab,
CXConfigType  cx_config = CXConfigType::Snake 
)

Constructs a circuit producing the same effect as a ChoiMixTableau.

Since Circuit does not support distinct qubit addresses for inputs and outputs, also returns a map from the output qubit IDs in the tableau to their corresponding outputs in the circuit.

The circuit produced will be the (possibly non-unitary) channel whose stabilisers are exactly those of the tableau and no more, using initialisations, post-selections, discards, resets, and collapses to ensure this. It will automatically reuse qubits so no more qubits will be needed than max(tab.get_n_inputs(), tab.get_n_outputs()).

Example 1: ZXI -> () YYZ -> () This becomes a diagonalisation circuit followed by post-selections.

Example 2: Z -> ZZ X -> IY Z -> -XX Combining the first and last rows reveals an initialisation is required for I -> YY. Since there are two output qubits, at least one of them does not already exist in the input fragment so we can freely add an extra qubit on the input side, initialise it and apply a unitary mapping IZ -> YY.

Example 3: ZX -> IZ II -> ZI We require an initialised qubit for the final row, but both input and output spaces only have q[0] and q[1], of which both inputs need to be open for the first row. We can obtain an initialised qubit by resetting a qubit after reducing the first row to only a single qubit.

Definition at line 149 of file ChoiMixTableauConverters.cpp.

◆ cm_tableau_to_unitary_extension_circuit()

std::pair< Circuit, qubit_map_t > tket::cm_tableau_to_unitary_extension_circuit ( const ChoiMixTableau tab,
const std::vector< Qubit > &  init_names = {},
const std::vector< Qubit > &  post_names = {},
CXConfigType  cx_config = CXConfigType::Snake 
)

We define a unitary extension of a ChoiMixTableau to be a unitary circuit whose stabilizer group contain all the rows of the ChoiMixTableau and possibly more.

This is useful when we are treating the ChoiMixTableau as a means to encode a diagonalisation problem, since we are generally looking for a unitary as we may wish to apply the inverse afterwards (e.g. conjugating some rotations to implement a set of Pauli gadgets).

Not every ChoiMixTableau can be extended to a unitary by just adding rows, e.g. if it requires any initialisation or post-selections. In this case, the unitary circuit is extended with additional input qubits which are assumed to be zero-initialised, and additional output qubits which are assumed to be post-selected. The synthesis guarantees that, if we take the unitary, initialise all designated inputs, and post-select on all designated outputs, every row from the original tableau is a stabiliser for the remaining projector. When not enough additional qubit names are provided, an error is thrown.

Example 1: ZXI -> () YYZ -> () Since, in exact synthesis, at least two post-selections would be required, we pick two names from post_names. This is then a diagonalisation circuit which maps each row to an arbitrary diagonal string over post_names.

Example 2: Z -> ZZ X -> IY Z -> -XX Combining the first and last rows reveals an initialisation is required for I -> YY. We extend the inputs with a qubit from init_names. The initialisation can manifest as either altering the first row to ZZ -> ZZ or the last row to ZZ -> -XX.

Example 3: ZX -> IZ II -> ZI We require an initialised qubit for the final row, but both input and output spaces only have q[0] and q[1], of which both inputs need to be open for the first row. Unlike exact synthesis, we cannot reuse qubits, so the returned circuit will be over 3 qubits, extending with a name from init_names.

Definition at line 163 of file ChoiMixTableauConverters.cpp.

◆ CnXPairwiseDecomposition()

const PassPtr & tket::CnXPairwiseDecomposition ( )

Decompose CnX gates to 2-qubit gates and single qubit gates.

For every two CnX gates, reorder their control qubits to improve the chance of gate cancellation

Returns
compilation pass to perform this transformation

Definition at line 437 of file PassLibrary.cpp.

◆ combine_diagonals()

Eigen::VectorXcd tket::combine_diagonals ( const std::vector< Eigen::VectorXcd > &  all_diags,
unsigned  n_controls_,
unsigned  n_targets_ 
)

Definition at line 1050 of file Multiplexor.cpp.

◆ combine_vectors()

std::vector< std::vector< OpTypeVector > > tket::combine_vectors ( const std::vector< std::vector< OpTypeVector > > &  vec_0,
const std::vector< OpTypeVector > &  vec_1 
)

Definition at line 147 of file FrameRandomisation.cpp.

◆ common_indices()

std::set< unsigned > tket::common_indices ( const DensePauliMap first,
const DensePauliMap second 
)

Find the set of qubits (as unsigned integer indices) on which first and second have the same non-trivial Pauli (X, Y, Z).

Definition at line 296 of file PauliTensor.cpp.

◆ common_qubits()

std::set< Qubit > tket::common_qubits ( const QubitPauliMap first,
const QubitPauliMap second 
)

Find the set of Qubits on which first and second have the same non-trivial Pauli (X, Y, Z).

Definition at line 284 of file PauliTensor.cpp.

◆ CommuteThroughMultis()

const PassPtr & tket::CommuteThroughMultis ( )

Definition at line 102 of file PassLibrary.cpp.

◆ commuting_containers()

template<typename PauliContainer >
bool tket::commuting_containers ( const PauliContainer &  first,
const PauliContainer &  second 
)
delete

Return whether two Pauli containers commute as Pauli strings (there are an even number of qubits on which they have distinct non-trivial Paulis).

◆ commuting_containers< DensePauliMap >() [1/2]

template<>
bool tket::commuting_containers< DensePauliMap > ( const DensePauliMap first,
const DensePauliMap second 
)

Definition at line 363 of file PauliTensor.cpp.

◆ commuting_containers< DensePauliMap >() [2/2]

template<>
bool tket::commuting_containers< DensePauliMap > ( const DensePauliMap first,
const DensePauliMap second 
)

Definition at line 363 of file PauliTensor.cpp.

◆ commuting_containers< QubitPauliMap >() [1/2]

template<>
bool tket::commuting_containers< QubitPauliMap > ( const QubitPauliMap first,
const QubitPauliMap second 
)

Definition at line 357 of file PauliTensor.cpp.

◆ commuting_containers< QubitPauliMap >() [2/2]

template<>
bool tket::commuting_containers< QubitPauliMap > ( const QubitPauliMap first,
const QubitPauliMap second 
)

Definition at line 357 of file PauliTensor.cpp.

◆ compare_coeffs()

template<typename CoeffType >
int tket::compare_coeffs ( const CoeffType &  first,
const CoeffType &  second 
)
delete

Compare two coefficients of the same type with respect to an ordering.

All values of no_coeff_t are equal. Values of quarter_turns_t are compared modulo 4. Values of Complex are compared lexicographically by the real part and then imaginary. Non-symbolic values of Expr are compared as Complex, symbolic values are compared by the canonical form of SymEngine expressions.

Parameters
firstA coefficient.
secondAnother coefficient of the same type.
Return values
-1first < second
0first == second
1first > second

◆ compare_coeffs< Complex >() [1/2]

template<>
int tket::compare_coeffs< Complex > ( const Complex first,
const Complex second 
)

Definition at line 266 of file PauliTensor.cpp.

◆ compare_coeffs< Complex >() [2/2]

template<>
int tket::compare_coeffs< Complex > ( const Complex first,
const Complex second 
)

Definition at line 266 of file PauliTensor.cpp.

◆ compare_coeffs< Expr >() [1/2]

template<>
int tket::compare_coeffs< Expr > ( const Expr first,
const Expr second 
)

Definition at line 273 of file PauliTensor.cpp.

◆ compare_coeffs< Expr >() [2/2]

template<>
int tket::compare_coeffs< Expr > ( const Expr first,
const Expr second 
)

Definition at line 273 of file PauliTensor.cpp.

◆ compare_coeffs< no_coeff_t >() [1/2]

template<>
int tket::compare_coeffs< no_coeff_t > ( const no_coeff_t ,
const no_coeff_t  
)

Definition at line 256 of file PauliTensor.cpp.

◆ compare_coeffs< no_coeff_t >() [2/2]

template<>
int tket::compare_coeffs< no_coeff_t > ( const no_coeff_t ,
const no_coeff_t  
)

Definition at line 256 of file PauliTensor.cpp.

◆ compare_coeffs< quarter_turns_t >() [1/2]

template<>
int tket::compare_coeffs< quarter_turns_t > ( const quarter_turns_t first,
const quarter_turns_t second 
)

Definition at line 260 of file PauliTensor.cpp.

◆ compare_coeffs< quarter_turns_t >() [2/2]

template<>
int tket::compare_coeffs< quarter_turns_t > ( const quarter_turns_t first,
const quarter_turns_t second 
)

Definition at line 260 of file PauliTensor.cpp.

◆ compare_containers()

template<typename PauliContainer >
int tket::compare_containers ( const PauliContainer &  first,
const PauliContainer &  second 
)
delete

Compare two Pauli containers of the same type for ordering.

Individual Paulis are ordered alphabetically as I < X < Y < Z. Strings are ordered lexicographically, IZ < ZI (Zq[1] < Zq[0]).

Parameters
firstA Pauli container
secondAnother Pauli container of the same type.
Return values
-1first < second
0first == second
1first > second

◆ compare_containers< DensePauliMap >() [1/2]

template<>
int tket::compare_containers< DensePauliMap > ( const DensePauliMap first,
const DensePauliMap second 
)

Definition at line 233 of file PauliTensor.cpp.

◆ compare_containers< DensePauliMap >() [2/2]

template<>
int tket::compare_containers< DensePauliMap > ( const DensePauliMap first,
const DensePauliMap second 
)

Definition at line 233 of file PauliTensor.cpp.

◆ compare_containers< QubitPauliMap >() [1/2]

template<>
int tket::compare_containers< QubitPauliMap > ( const QubitPauliMap first,
const QubitPauliMap second 
)

Definition at line 202 of file PauliTensor.cpp.

◆ compare_containers< QubitPauliMap >() [2/2]

template<>
int tket::compare_containers< QubitPauliMap > ( const QubitPauliMap first,
const QubitPauliMap second 
)

Definition at line 202 of file PauliTensor.cpp.

◆ ComposePhasePolyBoxes()

PassPtr tket::ComposePhasePolyBoxes ( unsigned  min_size = 0)

converts a circuit containing all possible gates to a circuit containing only phase poly boxes + H gates (and measure + reset + collapse + barrier)

Parameters
min_sizevalue for the minimal number of CX in each box, groups with less than min_size CX gates are not converted to a PhasePolyBox, default value is 0
Returns
PassPtr to perform the conversion

converts a circuit containing all possible gates to a circuit containing only phase poly boxes + H gates (and measure + reset + collapse

  • barrier) this pass will replace all wire swaps in the given circuit and they will be included in the last or an additional phase poly boxes

Definition at line 184 of file PassLibrary.cpp.

◆ conflicting_indices()

std::set< unsigned > tket::conflicting_indices ( const DensePauliMap first,
const DensePauliMap second 
)

Find the set of qubits (as unsigned integer indices) on which first and second have distinct non-trivial Paulis (X, Y, Z).

Definition at line 344 of file PauliTensor.cpp.

◆ conflicting_qubits()

std::set< Qubit > tket::conflicting_qubits ( const QubitPauliMap first,
const QubitPauliMap second 
)

Find the set of Qubits on which first and second have distinct non-trivial Paulis (X, Y, Z).

Definition at line 331 of file PauliTensor.cpp.

◆ conjugate_Pauli()

std::pair< Pauli, bool > tket::conjugate_Pauli ( OpType  op,
Pauli  p,
bool  reverse 
)

Captures rules for conjugating a pauli-gadget with single-qubit Clifford gates Maps gate and pauli to the new pauli after the conjugation and whether or not a phase-flip is induced.

Definition at line 23 of file ConjugatePauliFunctions.cpp.

◆ conjugate_PauliTensor() [1/3]

void tket::conjugate_PauliTensor ( SpPauliStabiliser qpt,
OpType  op,
const Qubit q,
bool  reverse 
)

Methods to conjugate a SpPauliStabiliser with Clifford gates to change basis Transforms P to P' such that reverse = false : –P'– = –op–P–opdg– reverse = true : –P'– = –opdg–P–op–.

Definition at line 100 of file ConjugatePauliFunctions.cpp.

◆ conjugate_PauliTensor() [2/3]

void tket::conjugate_PauliTensor ( SpPauliStabiliser qpt,
OpType  op,
const Qubit q0,
const Qubit q1 
)

Definition at line 113 of file ConjugatePauliFunctions.cpp.

◆ conjugate_PauliTensor() [3/3]

void tket::conjugate_PauliTensor ( SpPauliStabiliser qpt,
OpType  op,
const Qubit q0,
const Qubit q1,
const Qubit q2 
)

Definition at line 147 of file ConjugatePauliFunctions.cpp.

◆ convert_b_frontier_to_edges()

EdgeVec tket::convert_b_frontier_to_edges ( const b_frontier_t b_frontier)

Definition at line 501 of file MappingFrontier.cpp.

◆ convert_u_frontier_to_edges()

EdgeVec tket::convert_u_frontier_to_edges ( const unit_frontier_t u_frontier)

convert_u_frontier_to_edges Subcircuit requires EdgeVec, not unit_frontier_t as boundary information Helper Functions to convert types

Definition at line 493 of file MappingFrontier.cpp.

◆ core_box_json()

nlohmann::json tket::core_box_json ( const Box box)

Definition at line 595 of file Boxes.cpp.

◆ cos_halfpi_times()

Expr tket::cos_halfpi_times ( const Expr e)

Return cos(e*pi/2)

If e is within EPS of an integer then it is rounded so that the result can be evaluated.

Definition at line 106 of file Expression.cpp.

◆ CS_decomp()

csd_t tket::CS_decomp ( const Eigen::MatrixXcd &  u)

Compute a cosine-sine decomposition of a unitary matrix.

Parameters
uunitary matrix to be decomposed
Returns
cosine-sine decomposition
Precondition
u has even dimensions

Definition at line 25 of file CosSinDecomposition.cpp.

◆ CustomPass()

PassPtr tket::CustomPass ( std::function< Circuit(const Circuit &)>  transform,
const std::string &  label = "" 
)

Generate a custom pass.

Parameters
transformcircuit transformation function
labeloptional user-defined label for the pass

It is the caller's responsibility to provide a valid transform: there are no checks on this.

Returns
compilation pass that applies the supplied transform

Definition at line 1171 of file PassGenerators.cpp.

◆ CustomPassMap()

PassPtr tket::CustomPassMap ( std::function< std::pair< Circuit, std::pair< unit_map_t, unit_map_t > >(const Circuit &)>  transform,
const std::string &  label = "" 
)

Generate a custom pass that tracks map.

Parameters
transformcircuit transformation function and modified intial and final maps
labeloptional user-defined label for the pass

It is the caller's responsibility to provide a valid transform: there are no checks on this.

Returns
compilation pass that applies the supplied transform

Definition at line 1189 of file PassGenerators.cpp.

◆ CX_circ_from_multiq()

Circuit tket::CX_circ_from_multiq ( const Op_ptr  op)

Replace a multi-qubit operation with an equivalent circuit using CX gates.

Parameters
opoperation
Returns
equivalent circuit
Precondition
op is a multi-qubit operation
Postcondition
The only multi-qubit gates in the replacement circuit are CX

Definition at line 114 of file Replacement.cpp.

◆ CX_ZX_circ_from_op()

Circuit tket::CX_ZX_circ_from_op ( const Op_ptr  op)

Replace an operation with an equivalent circuit using CX, Rx and Rz.

Parameters
opoperation
Returns
equivalent circuit

Definition at line 132 of file Replacement.cpp.

◆ czero()

constexpr Complex tket::czero ( ,
 
)
constexpr

Complex zero.

◆ dec_to_bin()

std::vector< bool > tket::dec_to_bin ( unsigned long long  dec,
unsigned  width 
)

convert an unsigned to its binary representation big-endian

Definition at line 49 of file HelperFunctions.cpp.

◆ decompose_2cx_DV()

std::pair< Circuit, Complex > tket::decompose_2cx_DV ( const Eigen::Matrix4cd &  U)

Decompose a unitary matrix into a 2-CXs preceding a diagonal operator.

Given an arbitrary unitary 4x4 matrix, this method returns a circuit C and a complex number z such that |z|=1 and U = DV where V is the unitary implemented by the circuit and D = diag(z, z*, z*, z). The circuit C consists of CX and single-qubit gates and has at most 2 CX gates.

Parameters
Uunitary matrix
Returns
circuit and parameter defining diagonal operator

Definition at line 262 of file CircUtils.cpp.

◆ decompose_2cx_VD()

std::pair< Circuit, Complex > tket::decompose_2cx_VD ( const Eigen::Matrix4cd &  U)

Decompose a unitary matrix into a 2-CX circuit following a diagonal operator.

Given an arbitrary unitary 4x4 matrix, this method returns a circuit C and a complex number z such that |z|=1 and U = VD where V is the unitary implemented by the circuit and D = diag(z, z*, z*, z). The circuit C consists of CX and single-qubit gates and has at most 2 CX gates.

Parameters
Uunitary matrix
Returns
circuit and parameter defining diagonal operator

Definition at line 255 of file CircUtils.cpp.

◆ DecomposeArbitrarilyControlledGates()

const PassPtr & tket::DecomposeArbitrarilyControlledGates ( )

Definition at line 115 of file PassLibrary.cpp.

◆ DecomposeBoxes()

PassPtr tket::DecomposeBoxes ( const std::unordered_set< OpType > &  excluded_types = {},
const std::unordered_set< std::string > &  excluded_opgroups = {},
const std::optional< std::unordered_set< OpType > > &  included_types = std::nullopt,
const std::optional< std::unordered_set< std::string > > &  included_opgroups = std::nullopt 
)

Recursively replaces all boxes by their decomposition using Box::to_circuit.

Parameters
excluded_typesbox types excluded from decomposition
excluded_opgroupsopgroups excluded from decomposition
included_typesoptional, only decompose these box types
included_opgroupsoptional, only decompose these opgroups

Preserves Max2QubitGatesPredicate since any box with >2 qubits is already invalid. Preserves ConnectivityPredicate (and DirectednessPredicate) since the verification looks inside CircBoxes and any other boxes with >2 qubits are already invalid. Most others are preserved since the predicates look within CircBoxes.

Invalidates GateSetPredicate because it doesn't look inside boxes or account for the gate set of their decomposition.

Definition at line 215 of file PassLibrary.cpp.

◆ DecomposeBridges()

const PassPtr & tket::DecomposeBridges ( )

Definition at line 263 of file PassLibrary.cpp.

◆ DecomposeMultiQubitsCX()

const PassPtr & tket::DecomposeMultiQubitsCX ( )

Definition at line 130 of file PassLibrary.cpp.

◆ DecomposeSingleQubitsTK1()

const PassPtr & tket::DecomposeSingleQubitsTK1 ( )

Definition at line 159 of file PassLibrary.cpp.

◆ DecomposeTK2() [1/2]

PassPtr tket::DecomposeTK2 ( bool  allow_swaps)

Definition at line 830 of file PassGenerators.cpp.

◆ DecomposeTK2() [2/2]

PassPtr tket::DecomposeTK2 ( const Transforms::TwoQbFidelities fid,
bool  allow_swaps = true 
)

Decomposes each TK2 gate into two-qubit gates.

We currently support CX, ZZMax and ZZPhase.

If one or more gate fidelities are provided, the two-qubit gate type achieving the highest fidelity will be chosen for the decomposition, as measured using squared trace fidelity. If no fidelities are provided, the TK2 gates will be decomposed exactly using CX gates.

All TK2(α, β, γ) gates must be normalised to the Weyl chamber, i.e. 0.5 ≥ 𝛼 ≥ 𝛽 ≥ |𝛾|.

Gate fidelities are passed as keyword arguments to perform noise-aware decompositions. We currently support CX_fidelity, ZZMax_fidelity and ZZPhase_fidelity. If provided, the CX and ZZMax fidelities must be given by a single floating point fidelity. The ZZPhase fidelity is given as a lambda float -> float, mapping a ZZPhase angle parameter to its fidelity. These parameters will be used to return the optimal decomposition of each TK2 gate, taking noise into consideration.

Using the allow_swaps=true (default) option, qubits will be swapped when convenient to reduce the two-qubit gate count of the decomposed TK2.

If the TK2 angles are symbolic values, the decomposition will be exact (i.e. not noise-aware). It is not possible in general to obtain optimal decompositions for arbitrary symbolic parameters, so consider substituting for concrete values if possible.

Parameters
fidThe two-qubit gate fidelities (optional).
allow_swapsAllow implicit swaps (default = true).
Returns
PassPtr

Definition at line 831 of file PassGenerators.cpp.

◆ default_coeff()

template<typename CoeffType >
CoeffType tket::default_coeff ( )
delete

Other options for scalar coefficients include:

Complex; floating-point complex number. Mostly used by the python binder to present a phaseful interface with guaranteed success on converting to a sparse matrix.

Expr; a symbolic expression for a (possibly complex) coefficient. This tends to be used in the context of Pauli exponentials of tracking the rotation angle (along with its phase), where such synthesis functions map cP to exp(i*cP*pi/2) (i.e. the coefficient is the angle of rotation in half-turns). Returns the default coefficient value (scalar 1) for each coefficient type.

Return values
{}(no_coeff_t)
0(quarter_turns_t)
1.(Complex)
1(Expr)

◆ default_coeff< Complex >() [1/2]

template<>
Complex tket::default_coeff< Complex > ( )

Definition at line 33 of file PauliTensor.cpp.

◆ default_coeff< Complex >() [2/2]

template<>
Complex tket::default_coeff< Complex > ( )

Definition at line 33 of file PauliTensor.cpp.

◆ default_coeff< Expr >() [1/2]

template<>
Expr tket::default_coeff< Expr > ( )

Definition at line 37 of file PauliTensor.cpp.

◆ default_coeff< Expr >() [2/2]

template<>
Expr tket::default_coeff< Expr > ( )

Definition at line 37 of file PauliTensor.cpp.

◆ default_coeff< no_coeff_t >() [1/2]

Definition at line 25 of file PauliTensor.cpp.

◆ default_coeff< no_coeff_t >() [2/2]

Definition at line 25 of file PauliTensor.cpp.

◆ default_coeff< quarter_turns_t >() [1/2]

Definition at line 29 of file PauliTensor.cpp.

◆ default_coeff< quarter_turns_t >() [2/2]

Definition at line 29 of file PauliTensor.cpp.

◆ DelayMeasures()

const PassPtr & tket::DelayMeasures ( bool  allow_partial = false)

Commutes measurements to the end of the circuit.

Parameters
allow_partialWhether to allow measurements that cannot be commuted to the end, and delay them as much as possible instead. If false, the pass includes a CommutableMeasuresPredicate precondition.

Definition at line 328 of file PassLibrary.cpp.

◆ deserialise()

PassPtr tket::deserialise ( const nlohmann::json &  j,
const std::map< std::string, std::function< Circuit(const Circuit &)> > &  custom_deserialise,
const std::map< std::string, std::function< std::pair< Circuit, std::pair< unit_map_t, unit_map_t > >(const Circuit &)> > &  custom_map_deserialise 
)

Definition at line 365 of file CompilerPass.cpp.

◆ disentangle_final_qubit_from_diagonal()

std::pair< ctrl_op_map_t, Eigen::VectorXcd > tket::disentangle_final_qubit_from_diagonal ( const Eigen::VectorXcd &  full_diag,
unsigned  n_controls_ 
)

Definition at line 961 of file Multiplexor.cpp.

◆ equiv_0()

bool tket::equiv_0 ( const Expr e,
unsigned  n = 2,
double  tol = EPS 
)

Test whether a expression is approximately 0 modulo n.

Parameters
eexpression
nmodulus
toltolerance
Return values
truee is within tol of 0 modulo n
falseexpression is not within tolerance or could not be evaluated

Definition at line 142 of file Expression.cpp.

◆ equiv_Clifford()

std::optional< unsigned > tket::equiv_Clifford ( const Expr e,
unsigned  n = 2,
double  tol = EPS 
)

Test whether an expression is approximately a Clifford angle (some multiple of 0.5 modulo n)

Parameters
eexpression
nmodulus
toltolerance
Return values
nulloptexpression is not within tolerance or could not be evaluated
u\( e \approx \frac12 u \pmod n \) where \( 0 \leq u < 2n \} \).

Definition at line 146 of file Expression.cpp.

◆ equiv_expr()

bool tket::equiv_expr ( const Expr e0,
const Expr e1,
unsigned  n = 2,
double  tol = EPS 
)

Test approximate equality of expressions modulo n.

Parameters
e0expression
e1expression
nmodulus
toltolerance
Return values
truee0 and e1 are within tol of each other modulo n
falseexpressions are not within tolerance or could not ve evaluated

Definition at line 129 of file Expression.cpp.

◆ equiv_val()

bool tket::equiv_val ( const Expr e,
double  x,
unsigned  n = 2,
double  tol = EPS 
)

Test approximate value of an expression modulo n.

Parameters
eexpression
xtest value
nmodulus
toltolerance
Return values
truee is within tol of x modulo n
falseexpression is not within tolerance or could not be evaluated

Definition at line 136 of file Expression.cpp.

◆ eval_expr()

std::optional< double > tket::eval_expr ( const Expr e)

Definition at line 58 of file Expression.cpp.

◆ eval_expr_c()

std::optional< Complex > tket::eval_expr_c ( const Expr e)

Definition at line 70 of file Expression.cpp.

◆ eval_expr_mod()

std::optional< double > tket::eval_expr_mod ( const Expr e,
unsigned  n = 2 
)

Evaluate an expression modulo n.

The result will be in the half-interval [0,n). If it is within EPS of a multiple of 0.25 the result is clamped to an exact multiple.

Parameters
eexpression to evaluate
nmodulus
Returns
value of expression modulo n, iff it has no free symbols

Definition at line 78 of file Expression.cpp.

◆ expr_free_symbols() [1/2]

SymSet tket::expr_free_symbols ( const Expr e)

Set of all free symbols contained in the expression.

Definition at line 40 of file Expression.cpp.

◆ expr_free_symbols() [2/2]

SymSet tket::expr_free_symbols ( const std::vector< Expr > &  es)

Set of all free symbols contained in the expressions in the vector.

Definition at line 48 of file Expression.cpp.

◆ extend_if_input()

void tket::extend_if_input ( ZXDiagram diag,
const ZXVert v,
std::map< ZXVert, ZXVert > &  input_qubits 
)

Definition at line 697 of file ZXConverters.cpp.

◆ fill_partial_mapping()

void tket::fill_partial_mapping ( const qubit_vector_t current_qubits,
std::map< Qubit, Node > &  partial_mapping 
)

Definition at line 25 of file Placement.cpp.

◆ find_in_set()

bool tket::find_in_set ( const OpType val,
const OpTypeSet set 
)

Whether a given operation type belongs to a given set.

Definition at line 23 of file OpTypeFunctions.cpp.

◆ FlattenRegisters()

const PassPtr & tket::FlattenRegisters ( )

Definition at line 278 of file PassLibrary.cpp.

◆ fmodn()

double tket::fmodn ( double  x,
unsigned  n 
)

Evaluate modulo n in the range [0,n)

Parameters
xvalue to be reduced
nmodulus
Returns
y s.t. y == x (mod n) and 0 <= y < n

Definition at line 29 of file Expression.cpp.

◆ from_json() [1/34]

void tket::from_json ( const nlohmann::json &  ,
no_coeff_t  
)

Definition at line 22 of file PauliTensor.cpp.

◆ from_json() [2/34]

void tket::from_json ( const nlohmann::json &  ,
RoutingMethod rm 
)

Definition at line 28 of file RoutingMethodJson.cpp.

◆ from_json() [3/34]

void tket::from_json ( const nlohmann::json &  j,
Architecture ar 
)

Definition at line 231 of file Architecture.cpp.

◆ from_json() [4/34]

void tket::from_json ( const nlohmann::json &  j,
Architecture::Connection link 
)

Definition at line 209 of file Architecture.cpp.

◆ from_json() [5/34]

void tket::from_json ( const nlohmann::json &  j,
Bit cb 
)

Definition at line 38 of file UnitID.cpp.

◆ from_json() [6/34]

void tket::from_json ( const nlohmann::json &  j,
ChoiMixTableau tab 
)

Definition at line 709 of file ChoiMixTableau.cpp.

◆ from_json() [7/34]

void tket::from_json ( const nlohmann::json &  j,
ChoiMixTableau::TableauSegment seg 
)

Definition at line 694 of file ChoiMixTableau.cpp.

◆ from_json() [8/34]

void tket::from_json ( const nlohmann::json &  j,
Circuit circ 
)

Definition at line 46 of file CircuitJson.cpp.

◆ from_json() [9/34]

void tket::from_json ( const nlohmann::json &  j,
ClExpr expr 
)

Definition at line 260 of file ClExpr.cpp.

◆ from_json() [10/34]

void tket::from_json ( const nlohmann::json &  j,
ClExprArg arg 
)

Definition at line 188 of file ClExpr.cpp.

◆ from_json() [11/34]

void tket::from_json ( const nlohmann::json &  j,
ClExprTerm term 
)

Definition at line 156 of file ClExpr.cpp.

◆ from_json() [12/34]

void tket::from_json ( const nlohmann::json &  j,
ClExprVar var 
)

Definition at line 124 of file ClExpr.cpp.

◆ from_json() [13/34]

void tket::from_json ( const nlohmann::json &  j,
Command com 
)

Definition at line 65 of file CommandJson.cpp.

◆ from_json() [14/34]

void tket::from_json ( const nlohmann::json &  j,
composite_def_ptr_t cdef 
)

Definition at line 680 of file Boxes.cpp.

◆ from_json() [15/34]

void tket::from_json ( const nlohmann::json &  j,
DeviceCharacterisation dc 
)

Definition at line 105 of file DeviceCharacterisation.cpp.

◆ from_json() [16/34]

void tket::from_json ( const nlohmann::json &  j,
FullyConnected ar 
)

Definition at line 249 of file Architecture.cpp.

◆ from_json() [17/34]

void tket::from_json ( const nlohmann::json &  j,
MeasurementSetup setup 
)

Definition at line 147 of file MeasurementSetup.cpp.

◆ from_json() [18/34]

void tket::from_json ( const nlohmann::json &  j,
MeasurementSetup::MeasurementBitMap result 
)

Definition at line 112 of file MeasurementSetup.cpp.

◆ from_json() [19/34]

void tket::from_json ( const nlohmann::json &  j,
Node node 
)

Definition at line 46 of file UnitID.cpp.

◆ from_json() [20/34]

void tket::from_json ( const nlohmann::json &  j,
Op_ptr op 
)

Definition at line 28 of file OpJson.cpp.

◆ from_json() [21/34]

void tket::from_json ( const nlohmann::json &  j,
OpType type 
)

Definition at line 42 of file OpTypeJson.cpp.

◆ from_json() [22/34]

template<typename PauliContainer , typename CoeffType >
void tket::from_json ( const nlohmann::json &  j,
PauliTensor< PauliContainer, CoeffType > &  tensor 
)

Definition at line 1030 of file PauliTensor.hpp.

◆ from_json() [23/34]

void tket::from_json ( const nlohmann::json &  j,
Placement::Ptr placement_ptr 
)

Definition at line 155 of file Placement.cpp.

◆ from_json() [24/34]

void tket::from_json ( const nlohmann::json &  j,
PredicatePtr pred_ptr 
)

Definition at line 769 of file Predicates.cpp.

◆ from_json() [25/34]

void tket::from_json ( const nlohmann::json &  j,
Qubit qb 
)

Definition at line 35 of file UnitID.cpp.

◆ from_json() [26/34]

void tket::from_json ( const nlohmann::json &  j,
qubit_map_t qm 
)

Definition at line 56 of file UnitID.cpp.

◆ from_json() [27/34]

template<arithmetic T>
void tket::from_json ( const nlohmann::json &  j,
ResourceBounds< T > &  bounds 
)

Definition at line 53 of file ResourceData.hpp.

◆ from_json() [28/34]

void tket::from_json ( const nlohmann::json &  j,
ResourceData data 
)

Definition at line 32 of file ResourceData.cpp.

◆ from_json() [29/34]

void tket::from_json ( const nlohmann::json &  j,
std::vector< RoutingMethodPtr > &  rmp_v 
)

Definition at line 38 of file RoutingMethodJson.cpp.

◆ from_json() [30/34]

void tket::from_json ( const nlohmann::json &  j,
SymplecticTableau tab 
)

Definition at line 429 of file SymplecticTableau.cpp.

◆ from_json() [31/34]

void tket::from_json ( const nlohmann::json &  j,
UnitaryRevTableau tab 
)

Definition at line 739 of file UnitaryTableau.cpp.

◆ from_json() [32/34]

void tket::from_json ( const nlohmann::json &  j,
UnitaryTableau tab 
)

Definition at line 521 of file UnitaryTableau.cpp.

◆ from_json() [33/34]

void tket::from_json ( const nlohmann::json &  j,
WasmState wb 
)

Definition at line 41 of file UnitID.cpp.

◆ from_json() [34/34]

void tket::from_json ( const nlohmann::json &  j,
WiredClExpr expr 
)

Definition at line 409 of file ClExpr.cpp.

◆ frontier_convert_vertport_to_edge()

std::shared_ptr< unit_frontier_t > tket::frontier_convert_vertport_to_edge ( const Circuit circuit,
const std::shared_ptr< unit_vertport_frontier_t > &  u_frontier 
)

linear_boundary stored as vertport so that correct edge can be recovered after subcircuit substitution method uses Vertex and port_t and Circuit::get_nth_out_edge to generate unit_frontier_t object

Definition at line 87 of file MappingFrontier.cpp.

◆ FullPeepholeOptimise()

PassPtr tket::FullPeepholeOptimise ( bool  allow_swaps = true,
OpType  target_2qb_gate = OpType::CX 
)

Performs peephole optimisation including resynthesis of 2- and 3-qubit gate sequences, and converts to a circuit containing a given 2-qubit gate and TK1 gates.

Parameters
target_2qb_gatetarget 2-qubit gate (CX or TK2)
allow_swapswhether to allow introduction of implicit swaps

Definition at line 905 of file PassGenerators.cpp.

◆ gaussian_elimination_col_ops()

std::vector< std::pair< unsigned, unsigned > > tket::gaussian_elimination_col_ops ( const MatrixXb a,
unsigned  blocksize 
)

Definition at line 69 of file MatrixAnalysis.cpp.

◆ gaussian_elimination_row_ops()

std::vector< std::pair< unsigned, unsigned > > tket::gaussian_elimination_row_ops ( const MatrixXb a,
unsigned  blocksize 
)

Definition at line 93 of file MatrixAnalysis.cpp.

◆ gen_auto_rebase_pass()

PassPtr tket::gen_auto_rebase_pass ( const OpTypeSet allowed_gates,
bool  allow_swaps = false 
)

Attempt to generate a rebase pass automatically for the given target gateset.

Parameters
allowed_gatestarget gateset
allow_swapswhether to allow implicit wire swaps
Returns
PassPtr

Definition at line 220 of file PassGenerators.cpp.

◆ gen_auto_squash_pass()

PassPtr tket::gen_auto_squash_pass ( const OpTypeSet singleqs)

Attempt to generate a squash pass automatically for the given target single qubit gateset.

Parameters
singleqs
Returns
PassPtr

Definition at line 267 of file PassGenerators.cpp.

◆ gen_clifford_push_through_pass()

PassPtr tket::gen_clifford_push_through_pass ( )

Pass that simplifies circuits by resynthesising Clifford subcircuits before end of circuit measurements as a mutual diagonalisation circuit and classical postprocessing.

Returns
pass to resynthesise pre end of circuit measure Clifford subcircuits

Definition at line 339 of file PassGenerators.cpp.

◆ gen_clifford_resynthesis_pass()

PassPtr tket::gen_clifford_resynthesis_pass ( std::optional< std::function< Circuit(const Circuit &)> >  transform = std::nullopt,
bool  allow_swaps = true 
)

Pass to resynthesise Clifford subcircuits and simplify using Clifford rules.

Parameters
transformoptional user-provided resynthesis method to apply to all Clifford subcircuits (a function taking a Clifford circuit as an argument and returning an equivalent circuit); if not provided, a default resynthesis method is applied
allow_swapswhether the rewriting may introduce wire swaps (only relevant to the default resynthesis method used when the transform argument is not provided)
Returns
pass to perform Clifford resynthesis

Definition at line 328 of file PassGenerators.cpp.

◆ gen_clifford_simp_pass()

PassPtr tket::gen_clifford_simp_pass ( bool  allow_swaps,
OpType  target_2qb_gate 
)

Definition at line 307 of file PassGenerators.cpp.

◆ gen_contextual_pass()

PassPtr tket::gen_contextual_pass ( Transforms::AllowClassical  allow_classical = Transforms::AllowClassical::Yes,
std::shared_ptr< const Circuit xcirc = 0 
)

Generate a pass to perform simplifications dependent on qubit state.

Parameters
allow_classicalallow insertion of classical operations
xcirc1-qubit circuit implementing an X gate (if null, an X gate is used)

Definition at line 1143 of file PassGenerators.cpp.

◆ gen_cx_mapping_pass()

PassPtr tket::gen_cx_mapping_pass ( const Architecture arc,
const Placement::Ptr placement_ptr,
const std::vector< RoutingMethodPtr > &  config,
bool  directed_cx,
bool  delay_measures 
)

Definition at line 479 of file PassGenerators.cpp.

◆ gen_decompose_routing_gates_to_cxs_pass()

PassPtr tket::gen_decompose_routing_gates_to_cxs_pass ( const Architecture arc,
bool  directed 
)

Definition at line 767 of file PassGenerators.cpp.

◆ gen_default_mapping_pass()

PassPtr tket::gen_default_mapping_pass ( const Architecture arc,
bool  delay_measures 
)

Definition at line 468 of file PassGenerators.cpp.

◆ gen_directed_cx_routing_pass()

PassPtr tket::gen_directed_cx_routing_pass ( const Architecture arc,
const std::vector< RoutingMethodPtr > &  config 
)

Definition at line 756 of file PassGenerators.cpp.

◆ gen_euler_pass()

PassPtr tket::gen_euler_pass ( const OpType q,
const OpType p,
bool  strict 
)

Definition at line 293 of file PassGenerators.cpp.

◆ gen_flatten_relabel_registers_pass()

PassPtr tket::gen_flatten_relabel_registers_pass ( const std::string &  label)

Pass to remove empty Quantum edges from a Circuit and then relabel all Qubit to some new register defined by a passed label.

Qubits removed from the Circuit are preserved in the bimap, but not updated to a new labelling.

Definition at line 356 of file PassGenerators.cpp.

◆ gen_full_mapping_pass()

PassPtr tket::gen_full_mapping_pass ( const Architecture arc,
const Placement::Ptr placement_ptr,
const std::vector< RoutingMethodPtr > &  config 
)

Definition at line 459 of file PassGenerators.cpp.

◆ gen_full_mapping_pass_phase_poly()

PassPtr tket::gen_full_mapping_pass_phase_poly ( const Architecture arc,
const unsigned  lookahead = 1,
const aas::CNotSynthType  cnotsynthtype = aas::CNotSynthType::Rec,
unsigned  graph_placement_maximum_matches = 2000,
unsigned  graph_placement_timeout = 100,
unsigned  graph_placement_maximum_pattern_gates = 2000,
unsigned  graph_placement_maximum_pattern_depth = 2000 
)

execute architecture aware synthesis on a given architecture for any circuit.

all unplaced qubits will be placed in this pass

Parameters
arcarchitecture to route on
lookaheadparameter for the recursion depth in the algorithm, the value should be > 0
cnotsynthtypeparameter for the type of cnot synth
graph_placement_maximum_matchesparameter effecting the number of matches found during the GraphPlacement substep
graph_placement_timeouttimeout (ms) for finding subgraph monomorphisms during the GraphPlacement substep
graph_placement_maximum_pattern_gatesparameter affecting the size of the target graph, constructed from a phase polynomial, during the GraphPlacement substep, by restricting the number of gates in the phase polynomial used
graph_placement_maximum_pattern_depthparameter affecting the size of the target graph, constructed from a phase polynomial, during the GraphPlacement substep, by restricting the depth of gates in the phase polynomial that are added to the target graph
Returns
passpointer to perform architecture aware synthesis

Definition at line 742 of file PassGenerators.cpp.

◆ gen_graycode()

GrayCode tket::gen_graycode ( unsigned  n)

Construct a GrayCode over n bits.

Parameters
nbits

Definition at line 21 of file HelperFunctions.cpp.

◆ gen_greedy_pauli_simp()

PassPtr tket::gen_greedy_pauli_simp ( double  discount_rate = 0.7,
double  depth_weight = 0.3,
unsigned  max_lookahead = 500,
unsigned  max_tqe_candidates = 500,
unsigned  seed = 0,
bool  allow_zzphase = false,
unsigned  thread_timeout = 100,
bool  only_reduce = false,
unsigned  trials = 1 
)

Greedy synthesis for Pauli graphs.

Parameters
discount_rate
depth_weight
max_lookahead
max_tqe_candidates
seed
allow_zzphase
thread_timeout
only_reduce
trials
Returns
PassPtr

Definition at line 1014 of file PassGenerators.cpp.

◆ gen_naive_placement_pass()

PassPtr tket::gen_naive_placement_pass ( const Architecture arc)

Definition at line 438 of file PassGenerators.cpp.

◆ gen_optimise_phase_gadgets()

PassPtr tket::gen_optimise_phase_gadgets ( CXConfigType  cx_config)

Definition at line 929 of file PassGenerators.cpp.

◆ gen_pairwise_pauli_gadgets()

PassPtr tket::gen_pairwise_pauli_gadgets ( CXConfigType  cx_config)

Definition at line 952 of file PassGenerators.cpp.

◆ gen_pauli_exponentials()

PassPtr tket::gen_pauli_exponentials ( Transforms::PauliSynthStrat  strat,
CXConfigType  cx_config 
)

Definition at line 974 of file PassGenerators.cpp.

◆ gen_placement_pass()

PassPtr tket::gen_placement_pass ( const Placement::Ptr placement_ptr)

Definition at line 401 of file PassGenerators.cpp.

◆ gen_placement_pass_phase_poly()

PassPtr tket::gen_placement_pass_phase_poly ( const Architecture arc,
unsigned  _maximum_matches = 2000,
unsigned  _timeout = 100,
unsigned  _maximum_pattern_gates = 100,
unsigned  _maximum_pattern_depth = 100 
)

pass to place all not yet placed qubits of the circuit to the given architecture for the architecture aware synthesis.

Parameters
arcachitecture to place the circuit on
_maximum_matchesparameter effecting the number of matches found during the GraphPlacement substep
_timeouttimeout (ms) for finding subgraph monomorphisms during the GraphPlacement substep
_maximum_pattern_gatesparameter effecting the size of the target graph, constructed from a phase polynomial, during the GraphPlacement substep, by restricting the number of gates in the phase polynomial used
_maximum_pattern_depthparameter effecting the size of the target graph, constructed from a phase polynomial, during the GraphPlacement substep, by restricting the depth of gates in the phase polynomial that are added to the target graph
Returns
passpointer to perfomr the mapping

Definition at line 574 of file PassGenerators.cpp.

◆ gen_rebase_pass()

PassPtr tket::gen_rebase_pass ( const OpTypeSet allowed_gates,
const Circuit cx_replacement,
const std::function< Circuit(const Expr &, const Expr &, const Expr &)> &  tk1_replacement 
)

Definition at line 51 of file PassGenerators.cpp.

◆ gen_rebase_pass_via_tk2()

PassPtr tket::gen_rebase_pass_via_tk2 ( const OpTypeSet allowed_gates,
const std::function< Circuit(const Expr &, const Expr &, const Expr &)> &  tk2_replacement,
const std::function< Circuit(const Expr &, const Expr &, const Expr &)> &  tk1_replacement 
)

Generate a rebase pass give standard replacements for TK1 and TK2 gates.

Parameters
[in]allowed_gatesset of target gates
[in]tk2_replacementcircuit to replace a given TK2 gate
[in]tk1_replacementcircuit to replace a given TK1 gate
Returns
rebase pass

Definition at line 81 of file PassGenerators.cpp.

◆ gen_rename_qubits_pass()

PassPtr tket::gen_rename_qubits_pass ( const std::map< Qubit, Qubit > &  qm)

Pass to rename some or all qubits according to the given map.

Qubits in the map that do not occur in the circuit are ignored.

Definition at line 381 of file PassGenerators.cpp.

◆ gen_routing_pass()

PassPtr tket::gen_routing_pass ( const Architecture arc,
const std::vector< RoutingMethodPtr > &  config 
)

Definition at line 535 of file PassGenerators.cpp.

◆ gen_simplify_initial()

PassPtr tket::gen_simplify_initial ( Transforms::AllowClassical  allow_classical = Transforms::AllowClassical::Yes,
Transforms::CreateAllQubits  create_all_qubits = Transforms::CreateAllQubits::No,
std::shared_ptr< const Circuit xcirc = 0 
)

Generate a pass to simplify the circuit where it acts on known basis states.

Parameters
allow_classicalallow replacement of measures by pure classical set- bit operations when the measure acts on a known state
create_all_qubitsif enabled, annotate all qubits as initialized to zero as part of the transform, before applying simplification
xcirc1-qubit circuit implementing an X gate (if null, an X gate is used)

Definition at line 1119 of file PassGenerators.cpp.

◆ gen_special_UCC_synthesis()

PassPtr tket::gen_special_UCC_synthesis ( Transforms::PauliSynthStrat  strat,
CXConfigType  cx_config 
)

Definition at line 1100 of file PassGenerators.cpp.

◆ gen_squash_pass()

PassPtr tket::gen_squash_pass ( const OpTypeSet singleqs,
const std::function< Circuit(const Expr &, const Expr &, const Expr &)> &  tk1_replacement,
bool  always_squash_symbols 
)

Definition at line 114 of file PassGenerators.cpp.

◆ gen_synthesise_pauli_graph()

PassPtr tket::gen_synthesise_pauli_graph ( Transforms::PauliSynthStrat  strat,
CXConfigType  cx_config 
)

Definition at line 1007 of file PassGenerators.cpp.

◆ gen_user_defined_swap_decomp_pass()

PassPtr tket::gen_user_defined_swap_decomp_pass ( const Circuit replacement_circ)

Definition at line 796 of file PassGenerators.cpp.

◆ get_3q_unitary()

Eigen::MatrixXcd tket::get_3q_unitary ( const Circuit c)

Convert a 3-qubit circuit to its corresponding unitary matrix.

Parameters
cpure quantum circuit with 3 qubits
Precondition
c is composed of 1- and 2-qubit gates only
c has no symbolic parameters
Returns
8x8 unitary matrix in BasisOrder::ilo

Definition at line 491 of file ThreeQubitConversion.cpp.

◆ get_all_frame_permutations()

std::vector< std::vector< OpTypeVector > > tket::get_all_frame_permutations ( const unsigned &  max_frame_size,
const OpTypeSet frame_types 
)

Definition at line 121 of file FrameRandomisation.cpp.

◆ get_all_permutation_combinations()

std::vector< std::vector< OpTypeVector > > tket::get_all_permutation_combinations ( const std::vector< unsigned > &  frame_sizes,
const std::vector< std::vector< OpTypeVector > > &  frame_permutations 
)

Definition at line 162 of file FrameRandomisation.cpp.

◆ get_bitstring_circuit()

Circuit tket::get_bitstring_circuit ( const std::vector< bool > &  bitstring,
const unsigned &  target,
const unsigned &  n_qubits 
)

Definition at line 590 of file ToffoliBox.cpp.

◆ get_bloch_coordinate_from_state()

std::tuple< double, double, double > tket::get_bloch_coordinate_from_state ( const Complex a,
const Complex b 
)

Get the bloch sphere coordinate of a 1-qubit state.

|psi> = a|0> + b|1> = e^(i phase pi)(cos(theta pi/2)|0> + e^(i phi pi)sin(theta pi/2)|1>)

Parameters
a
b
Returns
[theta, phi, phase]

Definition at line 484 of file Rotation.cpp.

◆ get_frame_sizes()

std::pair< std::vector< unsigned >, unsigned > tket::get_frame_sizes ( const std::vector< Cycle > &  cycles)

Definition at line 394 of file FrameRandomisation.cpp.

◆ get_information_content()

std::tuple< Eigen::Matrix4cd, std::array< double, 3 >, Eigen::Matrix4cd > tket::get_information_content ( const Eigen::Matrix4cd &  X)

Performs KAK decomposition.

Given a unitary \( X \), returns \( (K_1, (k_\mathrm{XX},k_\mathrm{YY},k_\mathrm{ZZ}, K_2) \) such that \( X = K_1 \cdot \exp(-\frac12 i \pi \sum_{w \in \{\mathrm{XX}, \mathrm{YY}, \mathrm{ZZ}\}} k_w \sigma_w) \cdot K_2 \). The \( k_w \) are called information content and partition \( \mathrm{SU}(4) \) into equivalence classes modulo local transformations.

See arXiv quant-ph/0507171 for details

Parameters
Xunitary 4x4 matrix
Returns
KAK decomposition

Definition at line 305 of file MatrixAnalysis.cpp.

◆ get_matrix()

Eigen::Matrix2cd tket::get_matrix ( const Circuit circ,
const Vertex vert 
)

Convert a vertex holding a TK1 operation to its corresponding matrix.

Parameters
circcircuit
vertvertex in circuit
Precondition
vert is an operation of OpType::TK1
operation has no symbolic parameters
Returns
corresponding unitary matrix

Definition at line 37 of file CircUtils.cpp.

◆ get_matrix_from_2qb_circ()

Eigen::Matrix4cd tket::get_matrix_from_2qb_circ ( const Circuit circ)

Convert a two-qubit circuit to its corresponding matrix.

Parameters
circcircuit
Precondition
circ is composed of CX, TK2 and single-qubit gates only
circuit has no symbolic parameters
Postcondition
matrix is in BasisOrder::ilo
Returns
corresponding unitary matrix

Definition at line 63 of file CircUtils.cpp.

◆ get_matrix_from_circ()

Eigen::Matrix2cd tket::get_matrix_from_circ ( const Circuit circ)

Convert a one-qubit circuit of TK1 operations to its corresponding matrix.

Parameters
circcircuit
Precondition
all vertices are operations of OpType::TK1
circuit has no symbolic parameters
Returns
corresponding unitary matrix

Definition at line 47 of file CircUtils.cpp.

◆ get_matrix_from_tk1_angles()

Eigen::Matrix2cd tket::get_matrix_from_tk1_angles ( std::vector< Expr params)

Construct matrix from TK1 angles and phase.

Parameters
params[a,b,c,t] where a,b,c are the TK1 angles and t is the phase
Returns
2x2 unitary matrix
Precondition
no symbolic parameters

Definition at line 504 of file Rotation.cpp.

◆ get_matrix_size()

unsigned tket::get_matrix_size ( unsigned  number_of_qubits)

Returns 2^n, but throws if n is too large (causes overflow).

(Warning: simply taking 1<<n and testing against zero can give incorrect results with large n).

Definition at line 438 of file MatrixAnalysis.cpp.

◆ get_mult_matrix()

const std::map< std::pair< Pauli, Pauli >, std::pair< quarter_turns_t, Pauli > > & tket::get_mult_matrix ( )

Returns a const reference to a lookup table for multiplying individual Paulis.

Maps {p0, p1} -> {k, p2} where p0*p1 = e^{i*k*pi/2}*p2, e.g. {Pauli::X, Pauli::Y} -> {1, Pauli::Z} (X*Y = iZ).

Definition at line 530 of file PauliTensor.cpp.

◆ get_number_of_qubits()

unsigned tket::get_number_of_qubits ( unsigned  matrix_size)

We have a matrix size, which should be 2^n.

Return n, or throw if invalid.

Definition at line 452 of file MatrixAnalysis.cpp.

◆ get_op_ptr() [1/2]

Op_ptr tket::get_op_ptr ( OpType  chosen_type,
const Expr param,
unsigned  n_qubits = 0 
)

Get an operation with a given type, single parameter and qubit count.

Parameters
chosen_typeoperation type
paramoperation parameter
n_qubitsnumber of qubits (only necessary for gates, barrier and metaops with variable quantum arity)

Definition at line 25 of file OpPtrFunctions.cpp.

◆ get_op_ptr() [2/2]

Op_ptr tket::get_op_ptr ( OpType  chosen_type,
const std::vector< Expr > &  params = {},
unsigned  n_qubits = 0 
)

Get an operation from a type, vector of parameters and qubit count.

Parameters
chosen_typeoperation type
paramsoperation parameters
n_qubitsnumber of qubits (only necessary for gates, barrier and metaops with variable quantum arity)

Definition at line 29 of file OpPtrFunctions.cpp.

◆ get_sparse_matrix()

SparseMatrixXcd tket::get_sparse_matrix ( const std::vector< TripletCd > &  triplets,
unsigned  rows,
unsigned  cols 
)

Definition at line 463 of file MatrixAnalysis.cpp.

◆ get_sparse_square_matrix()

SparseMatrixXcd tket::get_sparse_square_matrix ( const std::vector< TripletCd > &  triplets,
unsigned  rows 
)

Definition at line 470 of file MatrixAnalysis.cpp.

◆ get_triplets() [1/2]

std::vector< TripletCd > tket::get_triplets ( const Eigen::MatrixXcd &  matr,
double  abs_epsilon = EPS 
)

Convert a matrix M into a list of tuples (i,j,z), meaning that M(i,j)=z, used in sparse representations of M.

Parameters
matrThe dense matrix.
abs_epsilonIf std::abs(z) <= abs_epsilon, then z is so small that it is treated as zero exactly and hence not added to the list of triplets.
Returns
A vector of (i,j,z) tuples, meaning that M(i,j)=z.

Definition at line 490 of file MatrixAnalysis.cpp.

◆ get_triplets() [2/2]

std::vector< TripletCd > tket::get_triplets ( const SparseMatrixXcd matr,
double  abs_epsilon = EPS 
)

abs_epsilon is used to decide if a near-zero entry should be set to zero exactly.

Thus, if std::abs(z) <= abs_epsilon, then z is treated as zero.

Definition at line 475 of file MatrixAnalysis.cpp.

◆ get_unitid_from_unit_frontier()

UnitID tket::get_unitid_from_unit_frontier ( const std::shared_ptr< unit_vertport_frontier_t > &  u_frontier,
const VertPort vp 
)

unit_vertport_frontier_t is <UnitID, VertPort>, helper function returns UnitID corresponding to given VertPort

Definition at line 51 of file MappingFrontier.cpp.

◆ get_weighted_subgraph_monomorphisms()

std::vector< boost::bimap< Qubit, Node > > tket::get_weighted_subgraph_monomorphisms ( QubitGraph::UndirectedConnGraph pattern_graph,
Architecture::UndirectedConnGraph target_graph,
unsigned  max_matches,
unsigned  timeout_ms,
bool  return_best 
)

Solves the pure unweighted subgraph monomorphism problem, trying to embed the pattern graph into the target graph.

Note that graph edge weights are IGNORED by this function.

◆ gray_synth()

Circuit tket::gray_synth ( unsigned  n_qubits,
const std::list< phase_term_t > &  parities,
const MatrixXb linear_transformation 
)

Definition at line 90 of file PhasePoly.cpp.

◆ greedy_diagonalise()

void tket::greedy_diagonalise ( const std::list< SpSymPauliTensor > &  gadgets,
std::set< Qubit > &  qubits,
Conjugations conjugations,
Circuit circ,
CXConfigType  cx_config 
)

Diagonalise a qubit greedily by finding the Pauli Gadget with the lowest residual support over the non-diagonal qubits, and apply single qubit Cliffords and CXs to make it a ZIII...I string.

Definition at line 106 of file Diagonalisation.cpp.

◆ hash_combine_coeff()

template<typename CoeffType >
void tket::hash_combine_coeff ( std::size_t &  seed,
const CoeffType &  coeff 
)
delete

Hash a coefficient, combining it with an existing hash of another structure.

◆ hash_combine_coeff< Complex >() [1/2]

template<>
void tket::hash_combine_coeff< Complex > ( std::size_t &  seed,
const Complex coeff 
)

Definition at line 502 of file PauliTensor.cpp.

◆ hash_combine_coeff< Complex >() [2/2]

template<>
void tket::hash_combine_coeff< Complex > ( std::size_t &  seed,
const Complex coeff 
)

Definition at line 502 of file PauliTensor.cpp.

◆ hash_combine_coeff< Expr >() [1/2]

template<>
void tket::hash_combine_coeff< Expr > ( std::size_t &  seed,
const Expr coeff 
)

Definition at line 507 of file PauliTensor.cpp.

◆ hash_combine_coeff< Expr >() [2/2]

template<>
void tket::hash_combine_coeff< Expr > ( std::size_t &  seed,
const Expr coeff 
)

Definition at line 507 of file PauliTensor.cpp.

◆ hash_combine_coeff< no_coeff_t >() [1/2]

template<>
void tket::hash_combine_coeff< no_coeff_t > ( std::size_t &  ,
const no_coeff_t  
)

Definition at line 493 of file PauliTensor.cpp.

◆ hash_combine_coeff< no_coeff_t >() [2/2]

template<>
void tket::hash_combine_coeff< no_coeff_t > ( std::size_t &  ,
const no_coeff_t  
)

Definition at line 493 of file PauliTensor.cpp.

◆ hash_combine_coeff< quarter_turns_t >() [1/2]

template<>
void tket::hash_combine_coeff< quarter_turns_t > ( std::size_t &  seed,
const quarter_turns_t coeff 
)

Definition at line 496 of file PauliTensor.cpp.

◆ hash_combine_coeff< quarter_turns_t >() [2/2]

template<>
void tket::hash_combine_coeff< quarter_turns_t > ( std::size_t &  seed,
const quarter_turns_t coeff 
)

Definition at line 496 of file PauliTensor.cpp.

◆ hash_combine_paulis()

template<typename PauliContainer >
void tket::hash_combine_paulis ( std::size_t &  seed,
const PauliContainer &  paulis 
)
delete

Hash a Pauli container, combining it with an existing hash of another structure.

◆ hash_combine_paulis< DensePauliMap >() [1/2]

template<>
void tket::hash_combine_paulis< DensePauliMap > ( std::size_t &  seed,
const DensePauliMap paulis 
)

Definition at line 480 of file PauliTensor.cpp.

◆ hash_combine_paulis< DensePauliMap >() [2/2]

template<>
void tket::hash_combine_paulis< DensePauliMap > ( std::size_t &  seed,
const DensePauliMap paulis 
)

Definition at line 480 of file PauliTensor.cpp.

◆ hash_combine_paulis< QubitPauliMap >() [1/2]

template<>
void tket::hash_combine_paulis< QubitPauliMap > ( std::size_t &  seed,
const QubitPauliMap paulis 
)

Definition at line 469 of file PauliTensor.cpp.

◆ hash_combine_paulis< QubitPauliMap >() [2/2]

template<>
void tket::hash_combine_paulis< QubitPauliMap > ( std::size_t &  seed,
const QubitPauliMap paulis 
)

Definition at line 469 of file PauliTensor.cpp.

◆ i_()

constexpr Complex tket::i_ ( ,
 
)
constexpr

A fixed square root of -1.

◆ in_weyl_chamber()

bool tket::in_weyl_chamber ( const std::array< Expr, 3 > &  k)

Whether a triplet of TK2 angles are normalised.

Numerical values must be in the Weyl chamber, ie 1/2 >= k_x >= k_y >= |k_z|. Symbolic values must come before any numerical value in the array.

Definition at line 503 of file MatrixAnalysis.cpp.

◆ insert_into_gadget_map()

void tket::insert_into_gadget_map ( QubitOperator gadget_map,
const PauliGadgetProperties pgp 
)

Definition at line 19 of file DiagUtils.cpp.

◆ is_barrier_type()

bool tket::is_barrier_type ( OpType  optype)

Test for Barrier "ops".

Definition at line 149 of file OpTypeFunctions.cpp.

◆ is_boundary_c_type()

bool tket::is_boundary_c_type ( OpType  optype)

Test for input or output for classical "ops".

Definition at line 178 of file OpTypeFunctions.cpp.

◆ is_boundary_q_type()

bool tket::is_boundary_q_type ( OpType  optype)

Test for input, creation, output or discard quantum "ops".

Definition at line 174 of file OpTypeFunctions.cpp.

◆ is_boundary_type()

bool tket::is_boundary_type ( OpType  optype)

Test for input, creation, output or discard "ops".

Definition at line 169 of file OpTypeFunctions.cpp.

◆ is_boundary_w_type()

bool tket::is_boundary_w_type ( OpType  optype)

Test for input or output for wasm "ops".

Definition at line 182 of file OpTypeFunctions.cpp.

◆ is_box_type()

bool tket::is_box_type ( OpType  optype)

Test for boxes (complex packaged operations)

Definition at line 190 of file OpTypeFunctions.cpp.

◆ is_classical_type()

bool tket::is_classical_type ( OpType  optype)

Test for purely classical gates.

Definition at line 281 of file OpTypeFunctions.cpp.

◆ is_clifford_type()

bool tket::is_clifford_type ( OpType  optype)

Test for Clifford operations.

Definition at line 266 of file OpTypeFunctions.cpp.

◆ is_controlled_gate_type()

bool tket::is_controlled_gate_type ( OpType  optype)

Test for controlled gates.

Definition at line 285 of file OpTypeFunctions.cpp.

◆ is_final_q_type()

bool tket::is_final_q_type ( OpType  optype)

Test for output or discard quantum "ops".

Definition at line 155 of file OpTypeFunctions.cpp.

◆ is_final_type()

bool tket::is_final_type ( OpType  optype)

Test for output "ops".

Definition at line 164 of file OpTypeFunctions.cpp.

◆ is_flowop_type()

bool tket::is_flowop_type ( OpType  optype)

Test for flowops (just for high-level control flow)

Definition at line 220 of file OpTypeFunctions.cpp.

◆ is_gate_type()

bool tket::is_gate_type ( OpType  optype)

Test for elementary gates.

Definition at line 186 of file OpTypeFunctions.cpp.

◆ is_initial_q_type()

bool tket::is_initial_q_type ( OpType  optype)

Test for input or creation quantum "ops".

Definition at line 151 of file OpTypeFunctions.cpp.

◆ is_initial_type()

bool tket::is_initial_type ( OpType  optype)

Test for input "ops".

Definition at line 159 of file OpTypeFunctions.cpp.

◆ is_metaop_type()

bool tket::is_metaop_type ( OpType  optype)

Test for initial and final "ops".

Definition at line 142 of file OpTypeFunctions.cpp.

◆ is_multi_qubit_type()

bool tket::is_multi_qubit_type ( OpType  optype)

Test for gates over more than one qubit.

Definition at line 242 of file OpTypeFunctions.cpp.

◆ is_oneway_type()

bool tket::is_oneway_type ( OpType  optype)

Test for non-invertible operations.

Definition at line 255 of file OpTypeFunctions.cpp.

◆ is_parameterised_pauli_rotation_type()

bool tket::is_parameterised_pauli_rotation_type ( OpType  optype)

Test for rotations around Pauli axes.

Definition at line 236 of file OpTypeFunctions.cpp.

◆ is_projective_type()

bool tket::is_projective_type ( OpType  optype)

Test for measurement and reset gates.

Definition at line 277 of file OpTypeFunctions.cpp.

◆ is_projector()

bool tket::is_projector ( const Eigen::MatrixXcd &  P,
double  tol 
)

Definition at line 34 of file MatrixAnalysis.cpp.

◆ is_rotation_type()

bool tket::is_rotation_type ( OpType  optype)

Test for rotations (including controlled rotations)

Definition at line 226 of file OpTypeFunctions.cpp.

◆ is_single_qubit_type()

bool tket::is_single_qubit_type ( OpType  optype)

Test for gates over a single qubit.

Definition at line 246 of file OpTypeFunctions.cpp.

◆ is_single_qubit_unitary_type()

bool tket::is_single_qubit_unitary_type ( OpType  optype)

Test for single-qubit gates that can be expressed as TK1.

Definition at line 251 of file OpTypeFunctions.cpp.

◆ is_spiderless_optype()

bool tket::is_spiderless_optype ( const OpType optype)

Definition at line 29 of file ZXConverters.cpp.

◆ is_unitary()

bool tket::is_unitary ( const Eigen::MatrixXcd &  U,
double  tol = EPS 
)

Test matrix for unitarity.

The tolerance refers to the l2 (Frobenius) norm of I - U*U.

Parameters
Umatrix
toltolerance
Return values
whetherthe matrix is unitary to within some tolerance

Definition at line 28 of file MatrixAnalysis.cpp.

◆ is_valid()

bool tket::is_valid ( const DAG G)

Check that the DAG satisfies the requirements of the Circuit class.

These requirements are described below.

Definition: call a DAG balanced if every vertex is either an initial vertex (with out-degree 1), a final vertex (with in-degree 1), or an internal vertex with its inbound edges in a defined bijection with its outbound edges. The balanced degree of an internal vertex of a balanced DAG is the common value of its in-degree and out-degree.

The edges of G are partitioned into three types: Quantum, Classical, and Boolean.

Let G_Q be the subgraph consisting of Quantum edges and their incident vertices. Let G_C be the subgraph consisting of Classical edges and their incident vertices.

From these we define the following classes of vertex:

We check the following properties:

  • V(G) = V(G_Q)V(G_C).
  • G_Q and G_C are balanced DAGs, with the bijections defined by the port numbers on the edges.
  • Every Measure vertex has balanced degree 1 in G_Q and in G_C.
  • A Quantum vertex has no Boolean out-edges.
  • Every source port number on a Boolean edge matches a source port number on a Classical edge outgoing from the same vertex.
  • All port numbers on inbound edges to a vertex are distinct.
Parameters
GDAG to check
Returns
whether the DAG has the required properties

Definition at line 38 of file DAGProperties.cpp.

◆ is_vertex_CX()

bool tket::is_vertex_CX ( const Circuit circ_,
const Vertex v 
)

Definition at line 624 of file LexiRoute.cpp.

◆ JSON_DECL() [1/4]

tket::JSON_DECL ( LexiRouteRoutingMethod  )

◆ JSON_DECL() [2/4]

tket::JSON_DECL ( Placement::Ptr  )

◆ JSON_DECL() [3/4]

tket::JSON_DECL ( RoutingMethod  )

◆ JSON_DECL() [4/4]

tket::JSON_DECL ( std::vector< RoutingMethodPtr )

◆ json_to_unitid()

template<class T >
void tket::json_to_unitid ( const nlohmann::json &  j,
T unit 
)

Definition at line 149 of file UnitID.hpp.

◆ KAKDecomposition()

PassPtr tket::KAKDecomposition ( OpType  target_2qb_gate = OpType::CX,
double  cx_fidelity = 1.,
bool  allow_swaps = true 
)

Squash sequences of two-qubit operations into minimal form.

A pass that squashes together sequences of single- and two-qubit gates into minimal form. Can decompose to TK2 or CX gates.

Two-qubit operations can always be expressed in a minimal form of maximum three CXs, or as a single TK2 gate (a result also known as the KAK or Cartan decomposition).

It is in general recommended to squash to TK2 gates, and to then use the DecomposeTK2 pass for noise-aware decompositions to other gatesets. For backward compatibility, decompositions to CX are also supported. In this case, cx_fidelity can be provided to perform approximate decompositions to CX.

When decomposing to TK2 gates, any sequence of two or more two-qubit gates on the same set of qubits are replaced by a single TK2 gate. When decomposing to CX, the substitution is only performed if it results in a reduction of the number of CX gates, or if at least one of the two-qubit gates is not a CX.

Using the allow_swaps=true (default) option, qubits will be swapped when convenient to further reduce the two-qubit gate count (only applicable when decomposing to CX gates).

Parameters
target_2qb_gateOpType to decompose to. Either TK2 or CX.
cx_fidelityEstimated CX gate fidelity, used when target_2qb_gate=CX.
allow_swapsWhether to allow implicit wire swaps.
Returns
PassPtr

Definition at line 810 of file PassGenerators.cpp.

◆ kronecker_decomposition()

std::pair< Eigen::Matrix2cd, Eigen::Matrix2cd > tket::kronecker_decomposition ( Eigen::Matrix4cd &  U)

Definition at line 416 of file MatrixAnalysis.cpp.

◆ lift_perm()

Eigen::PermutationMatrix< Eigen::Dynamic > tket::lift_perm ( const std::map< unsigned, unsigned > &  p)

Lift a permutation of \( [0,n) \) to a permutation of \( [0,2^n) \) as a matrix.

The result is a \( 2^n \times 2^n \) permutation matrix representing the derived permutation on the powerset of \( [0,n) \) using big-endian encoding, i.e. a subset \( S \subseteq [0,n) \) is represented by \( f(S) = \sum_{i \in S} 2^{n-1-i} \) and the \( (f(S),f(T)) \) entry of the matrix is 1 iff \( T = p(S) \).

Parameters
ppermutation of \( [0,n) \)
Returns
\( 2^n \times 2^n \) permutation matrix

Definition at line 220 of file MatrixAnalysis.cpp.

◆ load_dynamic_matrix()

template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > tket::load_dynamic_matrix ( const nlohmann::json &  j,
std::size_t  rows,
std::size_t  cols 
)

Definition at line 327 of file PhasePoly.cpp.

◆ measurement_reduction()

MeasurementSetup tket::measurement_reduction ( const std::list< SpPauliString > &  strings,
PauliPartitionStrat  strat,
GraphColourMethod  method = GraphColourMethod::Lazy,
CXConfigType  cx_config = CXConfigType::Snake 
)

A tool for reducing the number of measurements required for variational quantum algorithms by partitioning Pauli strings into mutually commuting sets.

See: https://arxiv.org/abs/1907.07859, https://arxiv.org/abs/1908.11857, https://arxiv.org/abs/1907.13623, https://arxiv.org/abs/1908.08067, https://arxiv.org/abs/1908.06942, https://arxiv.org/abs/1907.03358

Definition at line 21 of file MeasurementReduction.cpp.

◆ minus_times()

Expr tket::minus_times ( const Expr e)

Return -e.

Expanding e after multiplying by -1 may reduce its size, especially when minus_times is applied repeatedly and should cancel out.

Parameters
eexpression
Returns
Expr -e

Definition at line 119 of file Expression.cpp.

◆ mod()

double tket::mod ( double  d,
double  max 
)
inline

Definition at line 302 of file MatrixAnalysis.cpp.

◆ multi_controlled_to_2q()

Circuit tket::multi_controlled_to_2q ( const Op_ptr  op,
const std::optional< OpType > &  two_q_type = std::nullopt 
)

Replace CnRy, CnRx, CnRz, CnX, CnZ, CnY with 2-qubit gates and single qubit gates.

Parameters
opoperation
two_q_typewhether rebase 2-q gates to CX or TK2
Returns
equivalent circuit

Definition at line 31 of file Replacement.cpp.

◆ multiply_coeffs()

template<typename CoeffType >
CoeffType tket::multiply_coeffs ( const CoeffType &  first,
const CoeffType &  second 
)
delete

Multiply together two coefficients of the same type.

Multiplication of no_coeff_t is trivial. Multiplication of quarter_turns_t adds the unsigned values (e^{i*a*pi/2} * e^{i*b*pi/2} = e^{i*(a+b)*pi/2}). Multiplication of Complex/Expr is standard multiplication.

◆ multiply_coeffs< Complex >() [1/2]

template<>
Complex tket::multiply_coeffs< Complex > ( const Complex first,
const Complex second 
)

Definition at line 625 of file PauliTensor.cpp.

◆ multiply_coeffs< Complex >() [2/2]

template<>
Complex tket::multiply_coeffs< Complex > ( const Complex first,
const Complex second 
)

Definition at line 625 of file PauliTensor.cpp.

◆ multiply_coeffs< Expr >() [1/2]

template<>
Expr tket::multiply_coeffs< Expr > ( const Expr first,
const Expr second 
)

Definition at line 630 of file PauliTensor.cpp.

◆ multiply_coeffs< Expr >() [2/2]

template<>
Expr tket::multiply_coeffs< Expr > ( const Expr first,
const Expr second 
)

Definition at line 630 of file PauliTensor.cpp.

◆ multiply_coeffs< no_coeff_t >() [1/2]

template<>
no_coeff_t tket::multiply_coeffs< no_coeff_t > ( const no_coeff_t ,
const no_coeff_t  
)

Definition at line 614 of file PauliTensor.cpp.

◆ multiply_coeffs< no_coeff_t >() [2/2]

template<>
no_coeff_t tket::multiply_coeffs< no_coeff_t > ( const no_coeff_t ,
const no_coeff_t  
)

Definition at line 614 of file PauliTensor.cpp.

◆ multiply_coeffs< quarter_turns_t >() [1/2]

template<>
quarter_turns_t tket::multiply_coeffs< quarter_turns_t > ( const quarter_turns_t first,
const quarter_turns_t second 
)

Definition at line 619 of file PauliTensor.cpp.

◆ multiply_coeffs< quarter_turns_t >() [2/2]

template<>
quarter_turns_t tket::multiply_coeffs< quarter_turns_t > ( const quarter_turns_t first,
const quarter_turns_t second 
)

Definition at line 619 of file PauliTensor.cpp.

◆ multiply_strings()

template<typename PauliContainer >
std::pair< quarter_turns_t, PauliContainer > tket::multiply_strings ( const PauliContainer &  first,
const PauliContainer &  second 
)
delete

Multiplies two Pauli containers component-wise, returning both the resulting phase and string.

Maps {P0, P1} -> {k, P2} where P0*P1 = e^{i*k*pi/2}*P2, e.g. {XIY, YZY} -> {1, ZZI} (XIY*YZY = iZZI).

◆ multiply_strings< DensePauliMap >() [1/2]

template<>
std::pair< quarter_turns_t, DensePauliMap > tket::multiply_strings< DensePauliMap > ( const DensePauliMap first,
const DensePauliMap second 
)

Definition at line 530 of file PauliTensor.cpp.

◆ multiply_strings< DensePauliMap >() [2/2]

template<>
std::pair< quarter_turns_t, DensePauliMap > tket::multiply_strings< DensePauliMap > ( const DensePauliMap first,
const DensePauliMap second 
)

Definition at line 530 of file PauliTensor.cpp.

◆ multiply_strings< QubitPauliMap >() [1/2]

template<>
std::pair< quarter_turns_t, QubitPauliMap > tket::multiply_strings< QubitPauliMap > ( const QubitPauliMap first,
const QubitPauliMap second 
)

Definition at line 530 of file PauliTensor.cpp.

◆ multiply_strings< QubitPauliMap >() [2/2]

template<>
std::pair< quarter_turns_t, QubitPauliMap > tket::multiply_strings< QubitPauliMap > ( const QubitPauliMap first,
const QubitPauliMap second 
)

Definition at line 530 of file PauliTensor.cpp.

◆ mutual_diagonalise()

Circuit tket::mutual_diagonalise ( std::list< SpSymPauliTensor > &  gadgets,
std::set< Qubit qubits,
CXConfigType  cx_config 
)

Diagonalise a mutually commuting set of Pauli strings.

Modifies the list of Pauli strings in place, and returns the Clifford circuit required to generate the initial set.

Definition at line 224 of file Diagonalisation.cpp.

◆ n_ys()

template<typename PauliContainer >
unsigned tket::n_ys ( const PauliContainer &  paulis)
delete

Return the number of Pauli::Ys in the container.

Used for PauliTensor::transpose().

◆ n_ys< DensePauliMap >() [1/2]

template<>
unsigned tket::n_ys< DensePauliMap > ( const DensePauliMap paulis)

Definition at line 521 of file PauliTensor.cpp.

◆ n_ys< DensePauliMap >() [2/2]

template<>
unsigned tket::n_ys< DensePauliMap > ( const DensePauliMap paulis)

Definition at line 521 of file PauliTensor.cpp.

◆ n_ys< QubitPauliMap >() [1/2]

template<>
unsigned tket::n_ys< QubitPauliMap > ( const QubitPauliMap paulis)

Definition at line 512 of file PauliTensor.cpp.

◆ n_ys< QubitPauliMap >() [2/2]

template<>
unsigned tket::n_ys< QubitPauliMap > ( const QubitPauliMap paulis)

Definition at line 512 of file PauliTensor.cpp.

◆ name_to_optype()

const std::map< std::string, OpType > & tket::name_to_optype ( )

Definition at line 25 of file OpTypeJson.cpp.

◆ neighbours_of_frontier()

ZXVertSeqSet tket::neighbours_of_frontier ( const ZXDiagram diag,
const ZXVertVec frontier 
)

Definition at line 670 of file ZXConverters.cpp.

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [1/5]

tket::NLOHMANN_JSON_SERIALIZE_ENUM ( ClOp  ,
{ {ClOp::INVALID, "INVALID"}, {ClOp::BitAnd, "BitAnd"}, {ClOp::BitOr, "BitOr"}, {ClOp::BitXor, "BitXor"}, {ClOp::BitEq, "BitEq"}, {ClOp::BitNeq, "BitNeq"}, {ClOp::BitNot, "BitNot"}, {ClOp::BitZero, "BitZero"}, {ClOp::BitOne, "BitOne"}, {ClOp::RegAnd, "RegAnd"}, {ClOp::RegOr, "RegOr"}, {ClOp::RegXor, "RegXor"}, {ClOp::RegEq, "RegEq"}, {ClOp::RegNeq, "RegNeq"}, {ClOp::RegNot, "RegNot"}, {ClOp::RegZero, "RegZero"}, {ClOp::RegOne, "RegOne"}, {ClOp::RegLt, "RegLt"}, {ClOp::RegGt, "RegGt"}, {ClOp::RegLeq, "RegLeq"}, {ClOp::RegGeq, "RegGeq"}, {ClOp::RegAdd, "RegAdd"}, {ClOp::RegSub, "RegSub"}, {ClOp::RegMul, "RegMul"}, {ClOp::RegDiv, "RegDiv"}, {ClOp::RegPow, "RegPow"}, {ClOp::RegLsh, "RegLsh"}, {ClOp::RegRsh, "RegRsh"}, {ClOp::RegNeg, "RegNeg"}, }   
)

A bit variable within an expression.

Identifier for the variable within the expression

Definition at line 73 of file ClExpr.hpp.

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [2/5]

tket::NLOHMANN_JSON_SERIALIZE_ENUM ( CXConfigType  ,
{{CXConfigType::Snake, "Snake"}, {CXConfigType::Tree, "Tree"}, {CXConfigType::Star, "Star"}, {CXConfigType::MultiQGate, "MultiQGate"}}   
)

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [3/5]

tket::NLOHMANN_JSON_SERIALIZE_ENUM ( EdgeType  ,
{ {EdgeType::Quantum, "Q"}, {EdgeType::Classical, "C"}, {EdgeType::Boolean, "B"}, {EdgeType::WASM, "W"}, }   
)

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [4/5]

tket::NLOHMANN_JSON_SERIALIZE_ENUM ( Pauli  ,
{ {Pauli::I, "I"}, {Pauli::X, "X"}, {Pauli::Y, "Y"}, {Pauli::Z, "Z"}, }   
)

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [5/5]

tket::NLOHMANN_JSON_SERIALIZE_ENUM ( ToffoliBoxSynthStrat  ,
{{ToffoliBoxSynthStrat::Matching, "Matching"}, {ToffoliBoxSynthStrat::Cycle, "Cycle"}}   
)

◆ node_default_reg()

const std::string & tket::node_default_reg ( )

Definition at line 94 of file UnitID.cpp.

◆ normalise_TK2_angles()

std::tuple< Circuit, std::array< Expr, 3 >, Circuit > tket::normalise_TK2_angles ( Expr  a,
Expr  b,
Expr  c 
)

Get normalised TK2 angles and local change of basis for normalisation.

Given any TK2 angles, return the equivalent normalised TK2 angles as well as the two change of basis circuits pre and post so that

     TK2(a, b, c) = post * TK2(a', b', c') * pre

where a, b, c are the TK2 angles and a', b', c' are the equivalent normalised angles.

Parameters
afirst TK2 parameter
bsecond TK2 parameter
cthird TK2 parameter
Returns
std::tuple<Circuit, std::array<Expr, 3>, Circuit> pre circuit, normalised TK2 angles and post circuit (in this order)

Definition at line 1269 of file CircUtils.cpp.

◆ NormaliseTK2()

const PassPtr & tket::NormaliseTK2 ( )

Normalises all TK2 gates.

TK2 gates have three angles in the interval [0, 4], but these can always be normalised to be within the so-called Weyl chamber by adding single-qubit gates.

More precisely, the three angles a, b, c of TK2(a, b, c) are normalised exactly when the two following conditions are met:

  • numerical values must be in the Weyl chamber, ie 1/2 >= a >= b >= |c|,
  • symbolic values must come before any numerical value in the array.

After this pass, all TK2 angles will be normalised and the circuit will satisfy NormalisedTK2Predicate.

Returns
compilation pass to perform this transformation

Definition at line 386 of file PassLibrary.cpp.

◆ NotOp()

std::shared_ptr< ExplicitPredicateOp > tket::NotOp ( )

Unary NOT operator.

Definition at line 435 of file ClassicalOps.cpp.

◆ nth_root()

Eigen::Matrix2cd tket::nth_root ( const Eigen::Matrix2cd &  u,
unsigned long long  n 
)

Get an nth root of a 2x2 unitary matrix.

Definition at line 528 of file MatrixAnalysis.cpp.

◆ operator*()

Circuit tket::operator* ( const Circuit c1,
const Circuit c2 
)

Definition at line 125 of file macro_manipulation.cpp.

◆ operator<()

bool tket::operator< ( const PauliGadgetProperties pgp1,
const PauliGadgetProperties pgp2 
)

Definition at line 25 of file PauliGraph.cpp.

◆ operator<<() [1/16]

std::ostream & tket::operator<< ( std::ostream &  os,
ClOp  fn 
)

Definition at line 30 of file ClExpr.cpp.

◆ operator<<() [2/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const ChoiMixTableau tab 
)

Definition at line 678 of file ChoiMixTableau.cpp.

◆ operator<<() [3/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const ClBitVar var 
)

Definition at line 94 of file ClExpr.cpp.

◆ operator<<() [4/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const ClExpr expr 
)

Definition at line 231 of file ClExpr.cpp.

◆ operator<<() [5/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const ClExprArg arg 
)

Definition at line 166 of file ClExpr.cpp.

◆ operator<<() [6/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const ClExprTerm term 
)

Definition at line 134 of file ClExpr.cpp.

◆ operator<<() [7/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const ClExprVar var 
)

Definition at line 102 of file ClExpr.cpp.

◆ operator<<() [8/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const ClRegVar var 
)

Definition at line 98 of file ClExpr.cpp.

◆ operator<<() [9/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const Rotation q 
)

Definition at line 372 of file Rotation.cpp.

◆ operator<<() [10/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const SymplecticTableau tab 
)

Definition at line 107 of file SymplecticTableau.cpp.

◆ operator<<() [11/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const UnitaryRevTableau tab 
)

Definition at line 712 of file UnitaryTableau.cpp.

◆ operator<<() [12/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const UnitaryTableau tab 
)

Definition at line 472 of file UnitaryTableau.cpp.

◆ operator<<() [13/16]

std::ostream & tket::operator<< ( std::ostream &  os,
const WiredClExpr expr 
)

Definition at line 344 of file ClExpr.cpp.

◆ operator<<() [14/16]

std::ostream & tket::operator<< ( std::ostream &  os,
Op const &  operation 
)

Definition at line 44 of file Op.cpp.

◆ operator<<() [15/16]

std::ostream & tket::operator<< ( std::ostream &  out,
const Circuit circ 
)

Definition at line 108 of file basic_circ_manip.cpp.

◆ operator<<() [16/16]

std::ostream & tket::operator<< ( std::ostream &  out,
const DiagMatrix diam 
)

Definition at line 77 of file Gauss.cpp.

◆ operator>>() [1/3]

Circuit tket::operator>> ( const Circuit ci1,
const Circuit ci2 
)

Definition at line 240 of file macro_manipulation.cpp.

◆ operator>>() [2/3]

PassPtr tket::operator>> ( const PassPtr lhs,
const PassPtr rhs 
)

Definition at line 221 of file CompilerPass.cpp.

◆ operator>>() [3/3]

Transform tket::operator>> ( const Transform lhs,
const Transform rhs 
)
Parameters
[in]lhsfirst transform
[in]rhssecond transform
Returns
the composite transform

Definition at line 23 of file Combinator.cpp.

◆ optypeinfo()

const std::map< OpType, OpTypeInfo > & tket::optypeinfo ( )

Information including name and shape of each operation type.

Definition at line 23 of file OpTypeInfo.cpp.

◆ OrOp()

std::shared_ptr< ExplicitPredicateOp > tket::OrOp ( )

Binary OR operator.

Definition at line 449 of file ClassicalOps.cpp.

◆ OrWithOp()

std::shared_ptr< ExplicitModifierOp > tket::OrWithOp ( )

In-place OR with another input.

Definition at line 470 of file ClassicalOps.cpp.

◆ own_indices()

std::set< unsigned > tket::own_indices ( const DensePauliMap first,
const DensePauliMap second 
)

Find the set of qubits (as unsigned integer indices) on which first has a non-trivial Pauli (X, Y, Z) but second either doesn't contain (>= size) or maps to I.

Definition at line 318 of file PauliTensor.cpp.

◆ own_qubits()

std::set< Qubit > tket::own_qubits ( const QubitPauliMap first,
const QubitPauliMap second 
)

Find the set of Qubits on which first has a non-trivial Pauli (X, Y, Z) but second either doesn't contain or maps to I.

Definition at line 307 of file PauliTensor.cpp.

◆ pad_sparse_pauli_map()

DensePauliMap tket::pad_sparse_pauli_map ( const QubitPauliMap sparse_string,
size_t  size 
)

Definition at line 546 of file PauliExpBoxes.cpp.

◆ pauli_gadget()

Circuit tket::pauli_gadget ( SpSymPauliTensor  pauli,
CXConfigType  cx_config = CXConfigType::Snake 
)

Construct a 'Pauli gadget' corresponding to a tensor of Pauli operators.

The returned circuit implements the unitary operator \( e^{-\frac12 i \pi t \sigma_0 \otimes \sigma_1 \otimes \cdots} \) where \( \sigma_i \in \{I,X,Y,Z\} \) are the Pauli operators.

Parameters
pauliPauli operators; coefficient gives rotation angle in half-turns
cx_configCX configuration
Returns
Pauli gadget implementation wrapped in a ConjugationBox

Definition at line 275 of file CircUtils.cpp.

◆ pauli_gadget_pair()

Circuit tket::pauli_gadget_pair ( SpSymPauliTensor  paulis0,
SpSymPauliTensor  paulis1,
CXConfigType  cx_config = CXConfigType::Snake 
)

Construct a circuit realising a pair of Pauli gadgets with the fewest two-qubit gates.

The returned circuit implements the unitary e^{-i pi angle1 paulis1 / 2} e^{-i pi angle0 paulis0 / 2}, i.e. a gadget of angle0 about paulis0 followed by a gadget of angle1 about paulis1.

Parameters
paulis0Pauli operators for first gadget; coefficient gives rotation angle in half-turns
paulis1Pauli operators for second gadget; coefficient gives rotation angle in half-turns
cx_configCX configuration

Definition at line 365 of file CircUtils.cpp.

◆ pauli_graph_to_pauli_exp_box_circuit_individually()

Circuit tket::pauli_graph_to_pauli_exp_box_circuit_individually ( const PauliGraph pg,
CXConfigType  cx_config = CXConfigType::Snake 
)

Synthesises a circuit equivalent to the PauliGraph by adding each pauli gadget to the circuit as a PauliExpBox individually in the order given by TopSortIterator.

The tableau is then synthesised at the end.

Definition at line 51 of file PauliGraphConverters.cpp.

◆ pauli_graph_to_pauli_exp_box_circuit_pairwise()

Circuit tket::pauli_graph_to_pauli_exp_box_circuit_pairwise ( const PauliGraph pg,
CXConfigType  cx_config 
)

Synthesises a circuit equivalent to the PauliGraph by inserting pairs of pauli gadgets as PauliExpPairBoxes into the circuit The tableau is then synthesised at the end.

Definition at line 74 of file PauliGraphConverters.cpp.

◆ pauli_graph_to_pauli_exp_box_circuit_sets()

Circuit tket::pauli_graph_to_pauli_exp_box_circuit_sets ( const PauliGraph pg,
CXConfigType  cx_config 
)

Synthesises a circuit equivalent to the PauliGraph by building sets of mutually commuting pauli gadgets and inserting them into the circuit as PauliExpCommutingSetBoxes The tableau is then synthesised at the end.

  • Currently follows a greedy set-building method *‍/

Definition at line 113 of file PauliGraphConverters.cpp.

◆ PauliSquash()

PassPtr tket::PauliSquash ( Transforms::PauliSynthStrat  strat,
CXConfigType  cx_config 
)

Builds a sequence of PauliSimp (gen_synthesise_pauli_graph) and FullPeepholeOptimise.

Definition at line 1154 of file PassGenerators.cpp.

◆ PeepholeOptimise2Q()

PassPtr tket::PeepholeOptimise2Q ( bool  allow_swaps = true)

Performs peephole optimisation including resynthesis of 2-qubit gate sequences, and converts to a circuit containing CX and TK1 gates.

Parameters
allow_swapswhether to allow introduction of implicit wire swaps Expects: Any gates Produces: CX, TK1

Definition at line 878 of file PassGenerators.cpp.

◆ phase_gadget()

Circuit tket::phase_gadget ( unsigned  n_qubits,
const Expr angle,
CXConfigType  cx_config = CXConfigType::Snake 
)

Construct a phase gadget.

Parameters
n_qubitsnumber of qubits
anglephase parameter
cx_configCX configuration
Returns
phase gadget implementation wrapped in a ConjugationBox

Definition at line 270 of file CircUtils.cpp.

◆ predicate_name()

const std::string & tket::predicate_name ( std::type_index  idx)

Definition at line 57 of file Predicates.cpp.

◆ print_coeff()

template<typename CoeffType >
void tket::print_coeff ( std::ostream &  os,
const CoeffType &  coeff 
)
delete

◆ print_coeff< Complex >() [1/2]

template<>
void tket::print_coeff< Complex > ( std::ostream &  os,
const Complex coeff 
)

Definition at line 450 of file PauliTensor.cpp.

◆ print_coeff< Complex >() [2/2]

template<>
void tket::print_coeff< Complex > ( std::ostream &  os,
const Complex coeff 
)

Definition at line 450 of file PauliTensor.cpp.

◆ print_coeff< Expr >() [1/2]

template<>
void tket::print_coeff< Expr > ( std::ostream &  os,
const Expr coeff 
)

Definition at line 459 of file PauliTensor.cpp.

◆ print_coeff< Expr >() [2/2]

template<>
void tket::print_coeff< Expr > ( std::ostream &  os,
const Expr coeff 
)

Definition at line 459 of file PauliTensor.cpp.

◆ print_coeff< no_coeff_t >() [1/2]

template<>
void tket::print_coeff< no_coeff_t > ( std::ostream &  ,
const no_coeff_t  
)

Generates the coefficient prefix for PauliTensor::to_str()

Definition at line 425 of file PauliTensor.cpp.

◆ print_coeff< no_coeff_t >() [2/2]

template<>
void tket::print_coeff< no_coeff_t > ( std::ostream &  ,
const no_coeff_t  
)

Generates the coefficient prefix for PauliTensor::to_str()

Definition at line 425 of file PauliTensor.cpp.

◆ print_coeff< quarter_turns_t >() [1/2]

template<>
void tket::print_coeff< quarter_turns_t > ( std::ostream &  os,
const quarter_turns_t coeff 
)

Definition at line 428 of file PauliTensor.cpp.

◆ print_coeff< quarter_turns_t >() [2/2]

template<>
void tket::print_coeff< quarter_turns_t > ( std::ostream &  os,
const quarter_turns_t coeff 
)

Definition at line 428 of file PauliTensor.cpp.

◆ print_paulis()

template<typename PauliContainer >
void tket::print_paulis ( std::ostream &  os,
const PauliContainer &  paulis 
)
delete

Generates the readable Pauli string portion of PauliTensor::to_str().

Dense strings are printed as e.g. XIYZ. Sparse strings are printed as e.g. (Xq[0], Yq[2], Zq[3]).

◆ print_paulis< DensePauliMap >() [1/2]

template<>
void tket::print_paulis< DensePauliMap > ( std::ostream &  os,
const DensePauliMap paulis 
)

Definition at line 400 of file PauliTensor.cpp.

◆ print_paulis< DensePauliMap >() [2/2]

template<>
void tket::print_paulis< DensePauliMap > ( std::ostream &  os,
const DensePauliMap paulis 
)

Definition at line 400 of file PauliTensor.cpp.

◆ print_paulis< QubitPauliMap >() [1/2]

template<>
void tket::print_paulis< QubitPauliMap > ( std::ostream &  os,
const QubitPauliMap paulis 
)

Definition at line 369 of file PauliTensor.cpp.

◆ print_paulis< QubitPauliMap >() [2/2]

template<>
void tket::print_paulis< QubitPauliMap > ( std::ostream &  os,
const QubitPauliMap paulis 
)

Definition at line 369 of file PauliTensor.cpp.

◆ projector_assertion_synthesis()

std::tuple< Circuit, std::vector< bool > > tket::projector_assertion_synthesis ( const Eigen::MatrixXcd &  P)

Synthesise an assertion circuit from an arbitrary 2x2, 4x4 or 8x8 projector matrix.

Parameters
Pprojector matrix in BasisOrder::ilo
Returns
circuit implementing the projector based assertion and the expected readouts

Definition at line 218 of file AssertionSynthesis.cpp.

◆ q_default_reg()

const std::string & tket::q_default_reg ( )

Definition at line 70 of file UnitID.cpp.

◆ q_routing_ancilla_reg()

const std::string & tket::q_routing_ancilla_reg ( )

Definition at line 76 of file UnitID.cpp.

◆ RebaseTket()

const PassPtr & tket::RebaseTket ( )

Definition at line 75 of file PassLibrary.cpp.

◆ RebaseUFR()

const PassPtr & tket::RebaseUFR ( )

Definition at line 82 of file PassLibrary.cpp.

◆ recursive_conditional_circuit()

Circuit tket::recursive_conditional_circuit ( const Op_ptr op,
const Circuit base_circ 
)

Definition at line 390 of file macro_manipulation.cpp.

◆ reduce_anticommuting_paulis_to_z_x()

std::pair< Circuit, Qubit > tket::reduce_anticommuting_paulis_to_z_x ( SpPauliStabiliser  pauli0,
SpPauliStabiliser  pauli1,
CXConfigType  cx_config 
)

Given a pair of anticommuting Pauli tensors P0, P1, produces a short Clifford circuit C which maps P0 to Z and P1 to X on the same qubit, i.e.

Z_i C P0 = C = X_i C P1. This can be viewed as the components required to synthesise a pair of noncommuting Pauli gadgets C^dag RX(b)_i RZ(a)_i C = exp(-i pi b P1/2) exp(-i pi a P0/2) (up to global phase). This is not strictly a diagonalisation because anticommuting strings cannot be simultaneously diagonalised. Returns the circuit C and the qubit i where the Z and X end up.

Reduce each remaining Pauli to the shared mismatching qubit. Since reduce_pauli_to_Z does not allow us to pick the final qubit, we reserve the mismatching qubit, call reduce_pauli_to_Z on the rest, and add a CX.

Definition at line 697 of file Diagonalisation.cpp.

◆ reduce_commuting_paulis_to_zi_iz()

std::tuple< Circuit, Qubit, Qubit > tket::reduce_commuting_paulis_to_zi_iz ( SpPauliStabiliser  pauli0,
SpPauliStabiliser  pauli1,
CXConfigType  cx_config 
)

Given a pair of commuting Pauli tensors P0, P1, produces a short Clifford circuit C which maps P0 and P1 to Z on different qubits, i.e.

Z_i C P0 = C = Z_j C P1. This can be viewed as the components required to synthesise a pair of commuting Pauli gadgets C^dag RZ(b)_j RZ(a)_i C = exp(-i pi b P1/2) exp(-i pi a P0/2) (up to global phase), or as a mutual diagonalisation of two Pauli strings along with CXs to reduce them to independent, individual qubits. Returns the circuit C and the qubits i and j where the Zs end up.

Reduce each remaining Pauli to a single qubit.

Definition at line 733 of file Diagonalisation.cpp.

◆ reduce_overlap_of_paulis()

std::pair< Circuit, std::optional< Qubit > > tket::reduce_overlap_of_paulis ( SpPauliStabiliser pauli0,
SpPauliStabiliser pauli1,
CXConfigType  cx_config,
bool  allow_matching_final = false 
)

Given a pair of (either commuting or anticommuting) Pauli tensors P0, P1, produces a short Clifford circuit C which maps P0 and P1 to strings which overlap on at most one qubit (which is also returned).

If P0 and P1 anticommute, a mismatching qubit is always left. If they commute, contain at least one matching qubit and no mismatching qubits, then the final matching qubit is returned if allow_matching_final is true, otherwise P0 and P1 are reduced to non-overlapping strings.

Definition at line 508 of file Diagonalisation.cpp.

◆ reduce_pauli_to_z()

std::pair< Circuit, Qubit > tket::reduce_pauli_to_z ( const SpPauliStabiliser pauli,
CXConfigType  cx_config 
)

Given a Pauli tensor P, produces a short Clifford circuit C which maps P to Z on a single qubit, i.e.

Z_i C P = C. This can be viewed as the components required to synthesise a single Pauli gadget C^dag RZ(a)_i C = exp(-i pi a P/2) (up to global phase), or as a diagonalisation of a single Pauli string along with CXs to reduce it to a single qubit. Returns the circuit C and the qubit i where the Z ends up.

This is only equal to the CX decompositions above up to phase, but phase differences are cancelled out by its dagger

Definition at line 344 of file Diagonalisation.cpp.

◆ remove_all_gadgets()

bool tket::remove_all_gadgets ( ZXDiagram diag,
const ZXVertVec frontier,
std::map< ZXVert, ZXVert > &  input_qubits 
)

Definition at line 713 of file ZXConverters.cpp.

◆ RemoveBarriers()

const PassPtr & tket::RemoveBarriers ( )

Remove all& OpType::Barrier from the circuit.

Definition at line 302 of file PassLibrary.cpp.

◆ RemoveDiscarded()

const PassPtr & tket::RemoveDiscarded ( )

Remove all operations that have no OpType::Output or OpType::ClOutput in their causal future.

Definition at line 356 of file PassLibrary.cpp.

◆ RemoveImplicitQubitPermutation()

const PassPtr & tket::RemoveImplicitQubitPermutation ( )

Remove any implicit qubit permutation by appending SWAP gates.

Note that if the circuit contains measurements, they may become mid-circuit measurements in the transformed circuit.

Returns
compilation pass to perform this transformation

Definition at line 451 of file PassLibrary.cpp.

◆ RemovePhaseOps()

const PassPtr & tket::RemovePhaseOps ( )

Remove all OpType::Phase (including conditionals) from the circuit.

Definition at line 532 of file PassLibrary.cpp.

◆ RemoveRedundancies()

const PassPtr & tket::RemoveRedundancies ( )

Definition at line 89 of file PassLibrary.cpp.

◆ replace_CX_with_TK2()

void tket::replace_CX_with_TK2 ( Circuit c)

Utility function to replace all CX gates with TK2 and single-qubit gates.

Parameters
ccircuit to modify

Definition at line 410 of file CircUtils.cpp.

◆ respects_connectivity_constraints()

bool tket::respects_connectivity_constraints ( const Circuit circ,
const Architecture arch,
bool  directed,
bool  bridge_allowed = false 
)

Check that the circuit respects architectural constraints.

Parameters
circcircuit to check
archarchitecture
directedif true, disallow two-qubit gates except for CX
bridge_allowedwhether 3-qubit OpType::BRIDGE operations are allowed

Definition at line 18 of file Verification.cpp.

◆ reverse_bits()

uint64_t tket::reverse_bits ( uint64_t  v,
unsigned  w 
)

Reverse bits 0,1,...,w-1 of the number v, assuming v < 2^w and w <= 64.

Definition at line 40 of file HelperFunctions.cpp.

◆ reverse_indexing() [1/4]

Eigen::Matrix4cd tket::reverse_indexing ( const Eigen::Matrix4cd &  m)

Definition at line 257 of file MatrixAnalysis.cpp.

◆ reverse_indexing() [2/4]

Eigen::MatrixXcd tket::reverse_indexing ( const Eigen::MatrixXcd &  m)

Definition at line 266 of file MatrixAnalysis.cpp.

◆ reverse_indexing() [3/4]

Eigen::VectorXcd tket::reverse_indexing ( const Eigen::VectorXcd &  v)

Definition at line 273 of file MatrixAnalysis.cpp.

◆ reverse_indexing() [4/4]

Matrix8cd tket::reverse_indexing ( const Matrix8cd m)

Definition at line 261 of file MatrixAnalysis.cpp.

◆ RoundAngles()

PassPtr tket::RoundAngles ( unsigned  n,
bool  only_zeros = false 
)

Generate a pass that rounds all angles to the nearest \( \pi / 2^n \).

In particular, angles smaller than \( \pi / 2^{n+1} \) are set to zero; if a gate is turned into the identity by this operation it is removed.

Parameters
nprecision to retain in angles
only_zerosonly set angles smaller than \( \pi / 2^{n+1} \) to zero

@ pre n < 32

Returns
compilation pass that performs rounding

Definition at line 1160 of file PassGenerators.cpp.

◆ serialise() [1/3]

nlohmann::json tket::serialise ( const BasePass bp)

Definition at line 355 of file CompilerPass.cpp.

◆ serialise() [2/3]

nlohmann::json tket::serialise ( const PassPtr pp)

Definition at line 356 of file CompilerPass.cpp.

◆ serialise() [3/3]

nlohmann::json tket::serialise ( const std::vector< PassPtr > &  pp)

Definition at line 357 of file CompilerPass.cpp.

◆ set_box_id()

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

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.

◆ SimplifyMeasured()

const PassPtr & tket::SimplifyMeasured ( )

Replace all measured classical maps that are followed by Measure operations whose quantum output is discarded with classical operations following the Measure.

Definition at line 368 of file PassLibrary.cpp.

◆ sin_halfpi_times()

Expr tket::sin_halfpi_times ( const Expr e)

Return sin(e*pi/2)

If e is within EPS of an integer then it is rounded so that the result can be evaluated.

Definition at line 115 of file Expression.cpp.

◆ SquashRzPhasedX()

const PassPtr & tket::SquashRzPhasedX ( )

Squash single qubit gates into PhasedX and Rz gates.

Commute Rzs to the back if possible.

Definition at line 423 of file PassLibrary.cpp.

◆ SquashTK1()

const PassPtr & tket::SquashTK1 ( )

Squash sequences of single-qubit gates to TK1 gates.

Definition at line 248 of file PassLibrary.cpp.

◆ stabiliser_assertion_synthesis()

std::tuple< Circuit, std::vector< bool > > tket::stabiliser_assertion_synthesis ( const PauliStabiliserVec paulis)

Synthesise an assertion circuit from a list of Paulis strings with +/-1 coefficients.

Parameters
paulislist of Paulis strings
Returns
circuit implementing the stabiliser based assertion and the expected readouts

Definition at line 340 of file AssertionSynthesis.cpp.

◆ SynthesiseTK()

const PassPtr & tket::SynthesiseTK ( )

Definition at line 63 of file PassLibrary.cpp.

◆ SynthesiseTket()

const PassPtr & tket::SynthesiseTket ( )

Definition at line 69 of file PassLibrary.cpp.

◆ term_sequence()

std::list< std::list< SpPauliString > > tket::term_sequence ( const std::list< SpPauliString > &  strings,
PauliPartitionStrat  strat,
GraphColourMethod  method = GraphColourMethod::Lazy 
)

Partitions a QubitOperator into lists of mutually commuting gadgets.

Assumes that each SpPauliString is unique and does not attempt to combine them. If it is given non-unique tensors it will produce inefficient results.

Definition at line 265 of file PauliPartition.cpp.

◆ three_qubit_synthesis()

Circuit tket::three_qubit_synthesis ( const Eigen::MatrixXcd &  U)

Synthesise a 3-qubit circuit from an arbitrary 8x8 unitary.

The returned circuit consists of CX, TK1, H, Ry and Rz gates only. It contains a maximum of 20 CX gates.

Parameters
Uunitary matrix in BasisOrder::ilo
Returns
circuit implementing the unitary

Definition at line 436 of file ThreeQubitConversion.cpp.

◆ three_qubit_tk_synthesis()

Circuit tket::three_qubit_tk_synthesis ( const Eigen::MatrixXcd &  U)

Synthesise a 3-qubit circuit from an arbitrary 8x8 unitary.

The returned circuit consists of TK2 and 1-qubit gates only. It contains a maximum of 15 TK2 gates.

Parameters
Uunitary matrix in BasisOrder::ilo
Returns
circuit implementing the unitary

Definition at line 470 of file ThreeQubitConversion.cpp.

◆ ThreeQubitSquash()

PassPtr tket::ThreeQubitSquash ( bool  allow_swaps = true)

Resynthesize and squash three-qubit interactions.

Steps through the circuit accumulating sequences of 2- and 3-qubit interactions, where possible squashing them into subcircuits having lower CX count, then applies Clifford simplification.

Parameters
allow_swapswhether to allow introduction of implicit swaps

Definition at line 859 of file PassGenerators.cpp.

◆ tk1_angles_from_unitary()

std::vector< double > tket::tk1_angles_from_unitary ( const Eigen::Matrix2cd &  U)

Construct TK1 angles and phase from matrix.

Parameters
U2x2 unitary matrix
Returns
[a,b,c,t] where a,b,c are the TK1 angles and t is the phase

Definition at line 385 of file Rotation.cpp.

◆ TK2_circ_from_multiq()

Circuit tket::TK2_circ_from_multiq ( const Op_ptr  op)

Replace a multi-qubit operation with an equivalent circuit using TK2 gates.

Parameters
opoperation
Returns
equivalent circuit
Precondition
op is a multi-qubit operation
Postcondition
The only multi-qubit gates in the replacement circuit are TK2

Definition at line 88 of file Replacement.cpp.

◆ to_json() [1/34]

void tket::to_json ( nlohmann::json &  ,
const no_coeff_t  
)

Definition at line 21 of file PauliTensor.cpp.

◆ to_json() [2/34]

void tket::to_json ( nlohmann::json &  j,
const Architecture ar 
)

Definition at line 214 of file Architecture.cpp.

◆ to_json() [3/34]

void tket::to_json ( nlohmann::json &  j,
const Architecture::Connection link 
)

Definition at line 204 of file Architecture.cpp.

◆ to_json() [4/34]

void tket::to_json ( nlohmann::json &  j,
const Bit cb 
)

Definition at line 37 of file UnitID.cpp.

◆ to_json() [5/34]

void tket::to_json ( nlohmann::json &  j,
const ChoiMixTableau tab 
)

Definition at line 700 of file ChoiMixTableau.cpp.

◆ to_json() [6/34]

void tket::to_json ( nlohmann::json &  j,
const ChoiMixTableau::TableauSegment seg 
)

Definition at line 690 of file ChoiMixTableau.cpp.

◆ to_json() [7/34]

void tket::to_json ( nlohmann::json &  j,
const Circuit circ 
)

Definition at line 19 of file CircuitJson.cpp.

◆ to_json() [8/34]

void tket::to_json ( nlohmann::json &  j,
const ClExpr expr 
)

Definition at line 253 of file ClExpr.cpp.

◆ to_json() [9/34]

void tket::to_json ( nlohmann::json &  j,
const ClExprArg arg 
)

Definition at line 175 of file ClExpr.cpp.

◆ to_json() [10/34]

void tket::to_json ( nlohmann::json &  j,
const ClExprTerm term 
)

Definition at line 143 of file ClExpr.cpp.

◆ to_json() [11/34]

void tket::to_json ( nlohmann::json &  j,
const ClExprVar var 
)

Definition at line 111 of file ClExpr.cpp.

◆ to_json() [12/34]

void tket::to_json ( nlohmann::json &  j,
const Command com 
)

Definition at line 22 of file CommandJson.cpp.

◆ to_json() [13/34]

void tket::to_json ( nlohmann::json &  j,
const composite_def_ptr_t cdef 
)

Definition at line 674 of file Boxes.cpp.

◆ to_json() [14/34]

void tket::to_json ( nlohmann::json &  j,
const DeviceCharacterisation dc 
)

Definition at line 97 of file DeviceCharacterisation.cpp.

◆ to_json() [15/34]

void tket::to_json ( nlohmann::json &  j,
const FullyConnected ar 
)

Definition at line 243 of file Architecture.cpp.

◆ to_json() [16/34]

void tket::to_json ( nlohmann::json &  j,
const MeasurementSetup setup 
)

Definition at line 119 of file MeasurementSetup.cpp.

◆ to_json() [17/34]

void tket::to_json ( nlohmann::json &  j,
const MeasurementSetup::MeasurementBitMap result 
)

Definition at line 105 of file MeasurementSetup.cpp.

◆ to_json() [18/34]

void tket::to_json ( nlohmann::json &  j,
const Node node 
)

Definition at line 45 of file UnitID.cpp.

◆ to_json() [19/34]

void tket::to_json ( nlohmann::json &  j,
const Op_ptr op 
)

Definition at line 48 of file Op.cpp.

◆ to_json() [20/34]

void tket::to_json ( nlohmann::json &  j,
const OpType type 
)

Definition at line 38 of file OpTypeJson.cpp.

◆ to_json() [21/34]

template<typename PauliContainer , typename CoeffType >
void tket::to_json ( nlohmann::json &  j,
const PauliTensor< PauliContainer, CoeffType > &  tensor 
)

Definition at line 1023 of file PauliTensor.hpp.

◆ to_json() [22/34]

void tket::to_json ( nlohmann::json &  j,
const Placement::Ptr placement_ptr 
)

Definition at line 124 of file Placement.cpp.

◆ to_json() [23/34]

void tket::to_json ( nlohmann::json &  j,
const PredicatePtr pred_ptr 
)

Definition at line 680 of file Predicates.cpp.

◆ to_json() [24/34]

void tket::to_json ( nlohmann::json &  j,
const Qubit qb 
)

Definition at line 34 of file UnitID.cpp.

◆ to_json() [25/34]

void tket::to_json ( nlohmann::json &  j,
const qubit_map_t qm 
)

Definition at line 48 of file UnitID.cpp.

◆ to_json() [26/34]

template<arithmetic T>
void tket::to_json ( nlohmann::json &  j,
const ResourceBounds< T > &  bounds 
)

Definition at line 48 of file ResourceData.hpp.

◆ to_json() [27/34]

void tket::to_json ( nlohmann::json &  j,
const ResourceData data 
)

Definition at line 25 of file ResourceData.cpp.

◆ to_json() [28/34]

void tket::to_json ( nlohmann::json &  j,
const RoutingMethod rm 
)

Definition at line 26 of file RoutingMethodJson.cpp.

◆ to_json() [29/34]

void tket::to_json ( nlohmann::json &  j,
const std::vector< RoutingMethodPtr > &  rmp_v 
)

Definition at line 32 of file RoutingMethodJson.cpp.

◆ to_json() [30/34]

void tket::to_json ( nlohmann::json &  j,
const SymplecticTableau tab 
)

Definition at line 421 of file SymplecticTableau.cpp.

◆ to_json() [31/34]

void tket::to_json ( nlohmann::json &  j,
const UnitaryRevTableau tab 
)

Definition at line 735 of file UnitaryTableau.cpp.

◆ to_json() [32/34]

void tket::to_json ( nlohmann::json &  j,
const UnitaryTableau tab 
)

Definition at line 512 of file UnitaryTableau.cpp.

◆ to_json() [33/34]

void tket::to_json ( nlohmann::json &  j,
const WasmState wb 
)

Definition at line 40 of file UnitID.cpp.

◆ to_json() [34/34]

void tket::to_json ( nlohmann::json &  j,
const WiredClExpr expr 
)

Definition at line 398 of file ClExpr.cpp.

◆ to_sparse_matrix() [1/3]

template<typename PauliContainer >
CmplxSpMat tket::to_sparse_matrix ( const PauliContainer &  paulis)
delete

Evaluates a Pauli container to a sparse matrix describing the tensor product of each Pauli in the string.

The matrix gives the operator in ILO-BE format, e.g. (Zq[0], Xq[1]): 0 1 0 0 1 0 0 0 0 0 0 -1 0 0 -1 0

For sparse Pauli containers, just those qubits present in the container will be treated as part of the Pauli string (e.g. (Zq[1], Iq[2]) is treated as ZI since q[0] is ignored but q[2] is present in the string), so it is often preferred to use the other variants which explicitly provide the expected qubits.

◆ to_sparse_matrix() [2/3]

template<typename PauliContainer >
CmplxSpMat tket::to_sparse_matrix ( const PauliContainer &  paulis,
const qubit_vector_t qubits 
)
delete

Evaluates a Pauli container to a sparse matrix describing the tensor product of each Pauli in the string.

qubits dictates the order of the qubits in the tensor product, with the operator returned in Big Endian format. E.g. (Zq[0], Xq[1]), [q[1], q[0]]: 0 0 1 0 0 0 0 -1 1 0 0 0 0 -1 0 0

◆ to_sparse_matrix() [3/3]

template<typename PauliContainer >
CmplxSpMat tket::to_sparse_matrix ( const PauliContainer &  paulis,
unsigned  n_qubits 
)
delete

Evaluates a Pauli container to a sparse matrix describing the tensor product of each Pauli in the string.

Qubits are restricted to the default register, from q[0] to q[ n_qubits - 1], then presents the operator in ILO-BE format (if a sparse container contains Qubits outside of this range or not in the default register, an exception is thrown). E.g. (Zq[0]), 2: 1 0 0 0 0 -1 0 0 0 0 1 0 0 0 0 -1

◆ to_sparse_matrix< DensePauliMap >() [1/6]

template<>
CmplxSpMat tket::to_sparse_matrix< DensePauliMap > ( const DensePauliMap paulis)

Definition at line 678 of file PauliTensor.cpp.

◆ to_sparse_matrix< DensePauliMap >() [2/6]

template<>
CmplxSpMat tket::to_sparse_matrix< DensePauliMap > ( const DensePauliMap paulis)

Definition at line 678 of file PauliTensor.cpp.

◆ to_sparse_matrix< DensePauliMap >() [3/6]

template<>
CmplxSpMat tket::to_sparse_matrix< DensePauliMap > ( const DensePauliMap paulis,
const qubit_vector_t qubits 
)

Definition at line 728 of file PauliTensor.cpp.

◆ to_sparse_matrix< DensePauliMap >() [4/6]

template<>
CmplxSpMat tket::to_sparse_matrix< DensePauliMap > ( const DensePauliMap paulis,
const qubit_vector_t qubits 
)

Definition at line 728 of file PauliTensor.cpp.

◆ to_sparse_matrix< DensePauliMap >() [5/6]

template<>
CmplxSpMat tket::to_sparse_matrix< DensePauliMap > ( const DensePauliMap paulis,
unsigned  n_qubits 
)

Definition at line 696 of file PauliTensor.cpp.

◆ to_sparse_matrix< DensePauliMap >() [6/6]

template<>
CmplxSpMat tket::to_sparse_matrix< DensePauliMap > ( const DensePauliMap paulis,
unsigned  n_qubits 
)

Definition at line 696 of file PauliTensor.cpp.

◆ to_sparse_matrix< QubitPauliMap >() [1/6]

template<>
CmplxSpMat tket::to_sparse_matrix< QubitPauliMap > ( const QubitPauliMap paulis)

Definition at line 671 of file PauliTensor.cpp.

◆ to_sparse_matrix< QubitPauliMap >() [2/6]

template<>
CmplxSpMat tket::to_sparse_matrix< QubitPauliMap > ( const QubitPauliMap paulis)

Definition at line 671 of file PauliTensor.cpp.

◆ to_sparse_matrix< QubitPauliMap >() [3/6]

template<>
CmplxSpMat tket::to_sparse_matrix< QubitPauliMap > ( const QubitPauliMap paulis,
const qubit_vector_t qubits 
)

Definition at line 708 of file PauliTensor.cpp.

◆ to_sparse_matrix< QubitPauliMap >() [4/6]

template<>
CmplxSpMat tket::to_sparse_matrix< QubitPauliMap > ( const QubitPauliMap paulis,
const qubit_vector_t qubits 
)

Definition at line 708 of file PauliTensor.cpp.

◆ to_sparse_matrix< QubitPauliMap >() [5/6]

template<>
CmplxSpMat tket::to_sparse_matrix< QubitPauliMap > ( const QubitPauliMap paulis,
unsigned  n_qubits 
)

Definition at line 689 of file PauliTensor.cpp.

◆ to_sparse_matrix< QubitPauliMap >() [6/6]

template<>
CmplxSpMat tket::to_sparse_matrix< QubitPauliMap > ( const QubitPauliMap paulis,
unsigned  n_qubits 
)

Definition at line 689 of file PauliTensor.cpp.

◆ trace_fidelity()

double tket::trace_fidelity ( double  a,
double  b,
double  c 
)

Similarity measure of TK2(a, b, c) to SU(4) identity.

This computes the fidelity between TK2(a, b, c) and the 2-qubit identity.

a, b and c must be in the Weyl chamber, i.e. 1/2 >= a >= b >= |c|.

This is computed using the formula Fidᵤ = (4 + Tr(Id₄U)) / 20 = (4 + Tr(U)) / 20 where U is the 4x4 matrix of TK2(a, b, c).

Tr(U) can in turn be computed as Tr(U) = 4cos(a)cos(b)cos(c) − 4i sin(a)sin(b)sin(c).

These are formulas B3 and B5 of https://arxiv.org/pdf/1811.12926.pdf. Refer to that paper for more details.

Parameters
aThe XX interaction angle
bThe YY interaction angle
cThe ZZ interaction angle

Definition at line 292 of file MatrixAnalysis.cpp.

◆ tri_lexicographical_comparison() [1/2]

int tket::tri_lexicographical_comparison ( const dist_vec dist1,
const dist_vec dist2 
)

Definition at line 173 of file Architecture.cpp.

◆ tri_lexicographical_comparison() [2/2]

int tket::tri_lexicographical_comparison ( const std::vector< std::size_t > &  dist1,
const std::vector< std::size_t > &  dist2 
)

Definition at line 173 of file Architecture.cpp.

◆ trivial_callback()

void tket::trivial_callback ( const CompilationUnit ,
const nlohmann::json &   
)

Default callback when applying a pass (does nothing)

Definition at line 31 of file CompilerPass.cpp.

◆ two_qubit_canonical()

Circuit tket::two_qubit_canonical ( const Eigen::Matrix4cd &  U,
OpType  target_2qb_gate = OpType::TK2 
)

Convert a 4x4 unitary matrix optimally to a corresponding circuit.

This will express U using CX gates or a single TK2 gate. See also decompose_TK2 to decompose the TK2 gate further into other primitives.

Parameters
Uunitary matrix
target_2qb_gatewhether to decompose to TK2 or CX (default: TK2)
Precondition
U is in BasisOrder::ilo
Postcondition
Circuit consists of one normalised TK2 and single-qubit gates, or of up to 3 CX and single-qubit gates.
Returns
circuit implementing U exactly

Definition at line 145 of file CircUtils.cpp.

◆ unitary_product2()

template<class MatrixT >
MatrixT tket::unitary_product2 ( const MatrixT &  U,
const MatrixT &  V 
)

Compute the product of two unitary matrices, with error correction.

The arguments are assumed to be unitary.

Definition at line 208 of file MatrixAnalysis.hpp.

◆ unitary_product3()

template<class MatrixT >
MatrixT tket::unitary_product3 ( const MatrixT &  U,
const MatrixT &  V,
const MatrixT &  W 
)

Compute the product of three unitary matrices, with error correction.

The arguments are assumed to be unitary.

Definition at line 219 of file MatrixAnalysis.hpp.

◆ unitary_rev_tableau_to_circuit()

Circuit tket::unitary_rev_tableau_to_circuit ( const UnitaryRevTableau tab)

Definition at line 255 of file UnitaryTableauConverters.cpp.

◆ unitary_tableau_to_circuit()

Circuit tket::unitary_tableau_to_circuit ( const UnitaryTableau tab)

Constructs a circuit producing the same effect as the tableau.

Uses the method from Aaronson-Gottesman: Improved Simulation of Stabilizer Circuits, Theorem 8. CAUTION: GATE COUNT IS ATROCIOUS IN PRACTICE

Definition at line 31 of file UnitaryTableauConverters.cpp.

◆ unitid_to_json()

template<class Unit_T >
void tket::unitid_to_json ( nlohmann::json &  j,
const Unit_T &  unit 
)

Definition at line 142 of file UnitID.hpp.

◆ update_maps()

template<typename UnitA , typename UnitB >
bool tket::update_maps ( std::shared_ptr< unit_bimaps_t maps,
const std::map< UnitA, UnitB > &  um_initial,
const std::map< UnitA, UnitB > &  um_final 
)

Update a pair of "initial" and "final" correspondences.

If maps is null then the function does nothing and returns false.

Parameters
[in,out]mapsmaps to be updated
[in]um_initialnew correspondences added to initial map
[in]um_finalnew correspondences added to final map
Template Parameters
UnitAfirst unit type
UnitBsecond unit type
Returns
whether any changes were made to the maps

Definition at line 361 of file UnitID.hpp.

◆ w_default_reg()

const std::string & tket::w_default_reg ( )

Definition at line 88 of file UnitID.cpp.

◆ with_controls()

Circuit tket::with_controls ( const Circuit c,
unsigned  n_controls = 1 
)

Construct a controlled version of a given circuit.

Parameters
ccircuit
n_controlsnumber of controls
Returns
controlled circuit
Precondition
c consists only of unitary Gate operations
c has a single default qubit register
c has no implicit wireswaps
Postcondition
the returned circuit has a single default qubit register, whose initial qubits act as the controls over the other qubits, which correspond to those of c in the same order

Definition at line 1254 of file CircUtils.cpp.

◆ with_CX()

Circuit tket::with_CX ( Gate_ptr  op)

Express a gate as a circuit using CX as the only multi-qubit gate.

Parameters
opoperation
Returns
circuit representing the operation

Definition at line 523 of file CircUtils.cpp.

◆ with_TK2()

Circuit tket::with_TK2 ( Gate_ptr  op)

Express a gate as a circuit using TK2 as the only multi-qubit gate.

Parameters
opoperation
Returns
circuit representing the operation

Definition at line 415 of file CircUtils.cpp.

◆ XorOp()

std::shared_ptr< ExplicitPredicateOp > tket::XorOp ( )

Binary XOR operator.

Definition at line 456 of file ClassicalOps.cpp.

◆ XorWithOp()

std::shared_ptr< ExplicitModifierOp > tket::XorWithOp ( )

In-place XOR with another input.

Definition at line 477 of file ClassicalOps.cpp.

◆ zx_to_circuit()

Circuit tket::zx_to_circuit ( const zx::ZXDiagram diag)

Takes a unitary ZX diagram in MBQC form with the promise that a gflow exists.

Produces an equivalent circuit using the gate extraction method from Backens et al., "There and Back Again: A Circuit Extraction Tale".

Definition at line 822 of file ZXConverters.cpp.

◆ ZXGraphlikeOptimisation()

const PassPtr & tket::ZXGraphlikeOptimisation ( bool  allow_swaps = true)

Attempt to optimise the circuit by simplifying in ZX calculus and extracting a circuit back out.

Due to limitations in extraction, will not work if the circuit contains created or discarded qubits.

As a resynthesis pass, this will ignore almost all optimisations achieved beforehand and may increase the cost of the circuit.

Parameters
allow_swapsDetermines whether the extracted circuit may have implicit wire swaps. If set to false, implict wire swaps will be removed by adding SWAP gates at the end of the circuit.
Returns
compilation pass to perform this transformation

Definition at line 476 of file PassLibrary.cpp.

◆ ZZPhaseToRz()

const PassPtr & tket::ZZPhaseToRz ( )

Converts ZZPhase with angle 1 or -1 to two Rz(1) gates.

Returns
compilation pass to perform this transformation

Definition at line 406 of file PassLibrary.cpp.

Variable Documentation

◆ any

const OptUInt tket::any = std::nullopt
inline

Unspecified unsigned integer.

Definition at line 29 of file OpDesc.hpp.

◆ ClBitVar

tket::ClBitVar

Definition at line 99 of file ClExpr.hpp.

◆ EPS

constexpr double tket::EPS = 1e-11
constexpr

Default tolerance for floating-point comparisons.

Definition at line 38 of file Constants.hpp.

◆ PI

constexpr double tket::PI
constexpr
Initial value:
=
3.141'592'653'589'793'238'462'643'383'279'502'884'197'169'399'375'105'820'974

\( \pi \)

Definition at line 41 of file Constants.hpp.