mimiqcircuits.BlockCall¶
- class BlockCall(decl, args)[source]¶
Bases:
OperationA call to a
BlockDeclwith values for its arguments.The call holds a reference to its declaration, not a copy. Pushing it to a circuit takes the declaration’s qubits, then its bits, then its z-variables. See
BlockDeclfor an example.- Parameters:
- Raises:
ValueError – If the number of values does not match the arguments.
Examples
>>> from symengine import symbols >>> from mimiqcircuits import * >>> t = symbols("t") >>> decl = BlockDecl("rot", (t,), Circuit().push(GateRX(t), 0)) >>> call = BlockCall(decl, (0.5,)) >>> call rot(0.5) >>> call.decompose() 1-qubit circuit with 1 instruction: └── RX(0.5) @ q[0]
Methods
__init__(decl, args)allow_bit_aliasing()Whether an instruction may list the same classical bit more than once.
allow_zvar_aliasing()Whether an instruction may list the same z-variable more than once.
asciiwidth(qubits, bits, zvars)copy()Return a shallow copy of the operation.
decompose()Decompose the operation one level into simpler operations.
deepcopy()Return a deep copy of the operation and all its attributes.
evaluate(d)Substitute symbols in the call values and return a new
BlockCall.get_operation()Return the operation that this one wraps, or the operation itself.
getparam(pn)Return the value of the parameter named
pn.getparams()Return the values of the operation's parameters.
Return
Trueif any call value contains a free symbol.isidentity()Whether the operation is known to act as the identity.
isopalias()Whether the operation is a named alias of a wrapper.
Return
Trueif every operation in the declaration body is unitary.Return
False: a call is not a wrapper around a single operation.listvars()Return the symbols appearing in the call values.
numparams()Return the number of parameters of the operation.
Return
True: a call can be expanded into its body during canonical rewriting.Attributes
The values passed for the declaration arguments, as a tuple.
cregsizesSize of each classical register, with one entry per register.
The
BlockDeclbeing called.nameShort name of the operation type.
Number of clean ancillas of the operation.
num_bitsNumber of classical bits the operation acts on.
num_cregsNumber of classical registers (groups of bit targets) the operation takes.
num_qregsNumber of quantum registers (groups of qubit targets) the operation takes.
num_qubitsNumber of qubits the operation acts on.
num_zvarsNumber of complex-valued z-variables the operation acts on.
parnamesNames of the operation's parameters, as a tuple of strings.
qregsizesSize of each quantum register, as a list with one entry per register.
zregsizesSize of each z-variable register, with one entry per register.
- property num_ancillas¶
Number of clean ancillas of the operation.
The last
num_ancillasqubit targets must be in|0>when the operation starts, and are returned in|0>. On those inputs the operation acts as the one it was built for, which only touches the other qubits.It is set on
GateDecl,BlockDecl,Blockand calls to them, and is0for every other operation.decompose()sets it when it wraps a decomposition that uses clean ancillas, and marks the ancillas of each call withAncillaAllocandAncillaFree.
- property arguments¶
The values passed for the declaration arguments, as a tuple.