paulicirc.builders
Circuit builders
CircuitBuilder
- class CircuitBuilder(num_qubits, *, init_capacity=None, capacity_scaling=2)[source]
Bases:
objectA utility class to build circuits using common gate-based syntax.
- static __new__(cls, num_qubits, *, init_capacity=None, capacity_scaling=2)[source]
Create an empty circuit builder with the given number of qubits.
Optionally, initial capacity and/or capacity scaling can be specified for the underlying circuit. By default, the initial capacity is set to the number of qubits (with a minimum of 1), while the capacity scaling factor is set to 2 (doubling capacity whenever required).
- circuit()[source]
Returns a circuit constructed from the gadgets currently in the builder.
- Return type:
- extend(gadgets)[source]
Appends the given gadgets to the circuit being built. Gadgets are all validated prior to any modification, so either they are all appended to the circuit or none is.
- h(q, *, xzx=False)[source]
Adds a H gate on the given qubit.
By default, this is decomposed as
Z(pi/2)X(pi/2)Z(pi/2), but settingxzx=Truedecomposes it asX(pi/2)Z(pi/2)X(pi/2)instead.
- hdg(q, *, xzx=False)[source]
Adds a H gate on the given qubit.
By default, this is decomposed as
Z(-pi/2)X(-pi/2)Z(-pi/2), but settingxzx=Truedecomposes it asX(-pi/2)Z(-pi/2)X(-pi/2)instead.
- statevec(input, _normalise_phase=False)[source]
Computes the statevector resulting from the application of the circuit being built to the given input statevector.
- Parameters:
input (
Complex128Array1D)_normalise_phase (
bool; default =False)
- Return type:
- unitary(*, _normalise_phase=True)[source]
Returns the unitary matrix associated to the circuit being built.
- Parameters:
_normalise_phase (
bool; default =True)- Return type: