Function¶
-
class
Function: public xacc::Instruction, public xacc::Persistable¶ The Function is an Instruction that contains further child Instructions. Functions, like Instructions, can be parameterized. These parameters represent Function arguments.
- Author
Alex McCaskey
Subclassed by xacc::quantum::DWFunction, xacc::quantum::GateFunction
Public Functions
-
virtual const int
nInstructions() = 0¶ Return the number of Instructions that this Function contains.
- Return
nInst The number of instructions
-
virtual InstPtr
getInstruction(const int idx) = 0¶ Return the Instruction at the given index.
- Return
inst The instruction at the given index.
- Parameters
idx: The desired Instruction index
-
virtual std::list<InstPtr>
getInstructions() = 0¶ Return all Instructions in this Function
- Return
insts The list of this Function’s Instructions
-
virtual void
removeInstruction(const int idx) = 0¶ Remove the Instruction at the given index.
- Parameters
idx: The index of the Instruction to remove.
-
virtual void
replaceInstruction(const int idx, InstPtr newInst) = 0¶ Replace the Instruction at the given index with the given new Instruction.
- Parameters
idx: The index of the Instruction to replace.newInst: The new Instruction to replace with.
-
virtual void
insertInstruction(const int idx, InstPtr newInst) = 0¶ Insert a new Instruction at the given index. All previous instructions are pushed back, ie their new indices are currentIndex + 1.
- Parameters
idx: The index where the new instruction should be insertednewInst: The new Instruction to insert.
-
virtual void
addInstruction(InstPtr instruction) = 0¶ Add an Instruction to this Function.
- Parameters
instruction: The instruction to add.
-
virtual void
addParameter(InstructionParameter instParam) = 0¶ Add a parameter to this Function.
@ param The parameter to add to this Function.
-
virtual const int
depth() = 0¶ Return the depth of this Function, applicable for Functions that represent quantum circuits.
- Return
depth The depth of the list of instructions.
-
virtual const std::string
persistGraph() = 0¶ Persist this Function to a graph representation.
- Return
graph The graph represented as a string, like a DOT file
-
bool
isComposite()¶ Return true always to indicate that the Function is composite.
- Return
composite True indicating this is a composite Instruction.
-
virtual const int
nLogicalBits() = 0¶ Return the number of logical qubits.
- Return
nLogical The number of logical qubits.
-
virtual const int
nPhysicalBits() = 0¶ Return the number of physical qubits.
- Return
nPhysical The number of physical qubits.
-
virtual std::shared_ptr<Function>
enabledView() = 0¶ Return a view of this Function that only contains enabled instructions.
- Return
enabledFunction The Function of all enabled instructions.
-
virtual std::shared_ptr<Function>
operator()(const std::vector<double> ¶ms) = 0¶ Evaluate this parameterized function at the given concrete parameters.
- Parameters
params: A vector of parameters
-
virtual
~Function()¶ The destructor