def __init__(self):
"""Create an empty circuit."""
# Map from a wire's name (reg,idx) to a Bool that is True if the
# wire is a classical bit and False if the wire is a qubit.
self.wire_type = {}
# Map from wire names (reg,idx) to input nodes of the graph
self.input_map = {}
# Map from wire names (reg,idx) to output nodes of the graph
self.output_map = {}
# Running count of the total number of nodes
self.node_counter = 0
# Map of named operations in this circuit and their signatures.
# The signature is an integer tuple (nq,nc,np) specifying the
# number of input qubits, input bits, and real parameters.
# The definition is external to the circuit object.
self.basis = {}
# Directed multigraph whose nodes are inputs, outputs, or operations.
# Operation nodes have equal in- and out-degrees and carry
# additional data about the operation, including the argument order
# and parameter values.
# Input nodes have out-degree 1 and output nodes have in-degree 1.
# Edges carry wire labels (reg,idx) and each operation has
# corresponding in- and out-edges with the same wire labels.
self.multi_graph = nx.MultiDiGraph()
# Map of qregs to sizes
self.qregs = {}
# Map of cregs to sizes
self.cregs = {}
# Map of user defined gates to ast nodes defining them
self.gates = {}
# Output precision for printing floats
self.prec = 10
评论列表
文章目录