types

The types package contains quantum types such as Qubit, Qureg, and WeakQubitRef. With further development of the math library, also quantum integers, quantum fixed point numbers etc. will be added.

projectq.types.BasicQubit(engine, idx) BasicQubit objects represent qubits.
projectq.types.Qubit(engine, idx) Qubit class.
projectq.types.Qureg Quantum register class.
projectq.types.WeakQubitRef(engine, idx) WeakQubitRef objects are used inside the Command object.

Module contents

class projectq.types.BasicQubit(engine, idx)[source]

BasicQubit objects represent qubits.

They have an id and a reference to the owning engine.

__init__(engine, idx)[source]

Initialize a BasicQubit object.

Parameters:
  • engine – Owning engine / engine that created the qubit
  • idx – Unique index of the qubit referenced by this qubit
class projectq.types.Qubit(engine, idx)[source]

Qubit class.

Represents a (logical-level) qubit with a unique index provided by the MainEngine. Once the qubit goes out of scope (and is garbage-collected), it deallocates itself automatically, allowing automatic resource management.

Thus the qubit is not copyable; only returns a reference to the same object.

class projectq.types.Qureg[source]

Quantum register class.

Simplifies accessing measured values for single-qubit registers (no []- access necessary) and enables pretty-printing of general quantum registers (call Qureg.__str__(qureg)).

engine[source]

Return owning engine.

class projectq.types.WeakQubitRef(engine, idx)[source]

WeakQubitRef objects are used inside the Command object.

Qubits feature automatic deallocation when destroyed. WeakQubitRefs, on the other hand, do not share this feature, allowing to copy them and pass them along the compiler pipeline, while the actual qubit objects may be garbage-collected (and, thus, cleaned up early). Otherwise there is no difference between a WeakQubitRef and a Qubit object.