Circuit¶
A quantum optical circuit. |
Circuit¶
- class mrmustard.lab.circuit.Circuit(components)[source]¶
A quantum optical circuit.
A circuit is defined by a collection of
CircuitComponents. Each mode is expected to begin with aStatefollowed by a series ofTransformations.- Parameters:
components (list[CircuitComponent]) – A list of components in the circuit.
- draw(draw_params=True)[source]¶
A string-based representation of this circuit.
- Parameters:
draw_params (bool) – Whether to draw the parameters of the components.
- Returns:
A string-based representation of the circuit.
- Return type:
str
- expectation(operator)[source]¶
Compute the expectation value of an operator with respect to the circuit.
- Parameters:
operator (CircuitComponent) – The operator to compute the expectation value of. Expected to be a unitary-like component (input and output ket wires on each of its modes).
- Returns:
The expectation value of the operator with respect to the circuit.
- Raises:
ValueError – If the operator acts on a mode that is no longer open in the circuit (e.g. already measured out).
- Return type:
- run(output_shape=None, representation=None)[source]¶
Runs the circuit.
The return type depends on whether the underlying computational graph is fully specified or not.
- Parameters:
output_shape (tuple[int, ...] | None) – If the circuit returns a
State, the shape of the output in the Fock basis.representation (Literal[ReprEnum.BARGMANN, ReprEnum.FOCK] | None) – If the circuit returns a
State, the representation of the output.
- Returns:
The result of the circuit.
- Return type: