pyquil.quil¶
Module for creating and defining Quil programs.

class
pyquil.quil.
Program
(*instructions)¶ Bases:
pyquil.quilbase.InstructionGroup

dagger
(inv_dict=None, suffix='INV')¶ Creates the conjugate transpose of the Quil program. The program must not contain any irreversible actions (measurement, control flow, qubit allocation).
Returns: The Quil program’s inverse Return type: Program

defgate
(name, matrix)¶ Define a new static gate.
Parameters:  name (string) – The name of the gate.
 matrix (arraylike) – List of lists or Numpy 2d array.
Returns: The Program instance.
Return type:

get_qubits
()¶ Returns: a set of all the qubit indices allocated in this program, synthesizing freely allocated qubits if neccessary. :rtype: set

if_then
(classical_reg, if_program, else_program=None)¶ If the classical register at index classical reg is 1, run if_program, else run else_program.
Parameters: Returns: The Quil Program with the branching instructions added.
Return type:

measure
(qubit_index, classical_reg)¶ Measures a qubit at qubit_index and puts the result in classical_reg
Parameters: Returns: The Quil Program with the appropriate measure instruction appended, e.g. MEASURE 0 [1]
Return type:

measure_all
(*qubit_reg_pairs)¶ Measures many qubits into their specified classical bits, in the order they were entered.
Parameters: qubit_reg_pairs (Tuple) – Tuples of qubit indices paired with classical bits. Returns: The Quil Program with the appropriate measure instructions appended, e.g. MEASURE 0 [1] MEASURE 1 [2] MEASURE 2 [3] Return type: Program

out
()¶ Converts the Quil program to a readable string.
Returns: String form of a program Return type: string

synthesize
(resource_manager=None)¶
