pyquil.gates

A lovely bunch of gates and instructions for programming with. This module is used to provide Pythonic sugar for Quil instructions.

pyquil.gates.AND(classical_reg1, classical_reg2)

Produce an AND instruction.

Parameters:
  • classical_reg1 – The first classical register.
  • classical_reg2 – The second classical register, which gets modified.
Returns:

A ClassicalAnd instance.

pyquil.gates.CCNOT(*qubits)
pyquil.gates.CNOT(*qubits)
pyquil.gates.CPHASE(*params)
pyquil.gates.CPHASE00(*params)
pyquil.gates.CPHASE01(*params)
pyquil.gates.CPHASE10(*params)
pyquil.gates.CSWAP(*qubits)
pyquil.gates.CZ(*qubits)
pyquil.gates.EXCHANGE(classical_reg1, classical_reg2)

Produce an EXCHANGE instruction.

Parameters:
  • classical_reg1 – The first classical register, which gets modified.
  • classical_reg2 – The second classical register, which gets modified.
Returns:

A ClassicalExchange instance.

pyquil.gates.FALSE(classical_reg)

Produce a FALSE instruction.

Parameters:classical_reg – A classical register to modify.
Returns:A ClassicalFalse instance.
pyquil.gates.H(*qubits)
pyquil.gates.I(*qubits)
pyquil.gates.ISWAP(*qubits)
pyquil.gates.MEASURE(qubit, classical_reg=None)

Produce a MEASURE instruction.

Parameters:
  • qubit – The qubit to measure.
  • classical_reg – The classical register to measure into, or None.
Returns:

A Measurement instance.

pyquil.gates.MOVE(classical_reg1, classical_reg2)

Produce a MOVE instruction.

Parameters:
  • classical_reg1 – The first classical register.
  • classical_reg2 – The second classical register, which gets modified.
Returns:

A ClassicalMove instance.

pyquil.gates.NOT(classical_reg)

Produce a NOT instruction.

Parameters:classical_reg – A classical register to modify.
Returns:A ClassicalNot instance.
pyquil.gates.OR(classical_reg1, classical_reg2)

Produce an OR instruction.

Parameters:
  • classical_reg1 – The first classical register.
  • classical_reg2 – The second classical register, which gets modified.
Returns:

A ClassicalOr instance.

pyquil.gates.PHASE(*params)
pyquil.gates.PSWAP(*params)
pyquil.gates.RX(*params)
pyquil.gates.RY(*params)
pyquil.gates.RZ(*params)
pyquil.gates.S(*qubits)
pyquil.gates.SWAP(*qubits)
pyquil.gates.T(*qubits)
pyquil.gates.TRUE(classical_reg)

Produce a TRUE instruction.

Parameters:classical_reg – A classical register to modify.
Returns:A ClassicalTrue instance.
pyquil.gates.X(*qubits)
pyquil.gates.Y(*qubits)
pyquil.gates.Z(*qubits)
pyquil.gates.unpack_classical_reg(c)

Get the address for a classical register.

Parameters:c – A list of length 1 or an int or an Addr.
Returns:The address as an Addr.