jet.circuit.Circuit

class Circuit(num_wires: int, dim: int = 2)[source]

Bases: object

Circuit represents a quantum circuit composed of wires, each of which is intitialized with a qudit of the specified dimension in the vacuum state.

Parameters
  • num_wires (int) – Number of wires in the circuit.

  • dim (int) – Dimension of each wire.

dimension

Returns the dimension of this circuit.

operations

Returns the gates and states that comprise this circuit alongside the wires they are connected to.

wires

Returns the wires of this circuit in increasing order of wire ID.

dimension

Returns the dimension of this circuit.

operations

Returns the gates and states that comprise this circuit alongside the wires they are connected to. The first self.num_wires operations describe the qudits that begin each wire; other operations appear in the order they were appended to the circuit.

wires

Returns the wires of this circuit in increasing order of wire ID.

append_gate(gate, wire_ids)

Applies a gate along the specified wires.

append_state(state, wire_ids)

Terminates the specified wires with a quantum state.

indices(wire_ids)

Returns the index labels associated with a sequence of wire IDs.

take_expected_value(observable)

Completes this circuit by taking the expected value of an observable.

tensor_network([dtype])

Returns the tensor network representation of this circuit.

append_gate(gate: jet.gate.Gate, wire_ids: Sequence[int])None[source]

Applies a gate along the specified wires.

Parameters
  • gate (jet.Gate) – Gate to be applied.

  • wire_ids (Sequence[int]) – IDs of the wires the gate is applied to.

append_state(state: jet.state.State, wire_ids: Sequence[int])None[source]

Terminates the specified wires with a quantum state.

Parameters
  • state (jet.State) – state to be used for termination.

  • wire_ids (Sequence[int]) – IDs of the wires the state terminates.

indices(wire_ids: Iterator[int])Iterator[str][source]

Returns the index labels associated with a sequence of wire IDs.

Parameters

wire_ids (Iterator[int]) – IDs of the wires to get the index labels for.

Returns

Current index label of each wire.

Return type

Iterator[str]

take_expected_value(observable: Iterator[jet.circuit.Operation])None[source]

Completes this circuit by taking the expected value of an observable.

Parameters

observable (Iterator[Operation]) – Sequence of gate and wire ID pairs representing the observable.

Note

This function finalizes the circuit; no more gates or states can be appended after this function is called.

tensor_network(dtype: numpy.dtype = <class 'numpy.complex128'>)Union[jet.bindings.TensorNetworkC64, jet.bindings.TensorNetworkC128][source]

Returns the tensor network representation of this circuit.

Parameters

dtype (np.dtype) – Data type of the tensor network.

Returns

Tensor network representation of this circuit.

Return type

TensorNetworkType