mm.lab_dev.transformations.Attenuator¶
- class mrmustard.lab_dev.transformations.Attenuator(modes, transmissivity=1.0, transmissivity_trainable=False, transmissivity_bounds=(0.0, 1.0))[source]¶
Bases:
Channel
The noisy attenuator channel.
If
transmissivity
is an iterable, its length must be equal to 1 or N. If it length is equal to 1, all the modes share the same transmissivity.>>> import numpy as np >>> from mrmustard.lab_dev import Attenuator >>> channel = Attenuator(modes=[1, 2], transmissivity=0.1) >>> assert channel.modes == [1, 2] >>> assert np.allclose(channel.transmissivity.value, [0.1, 0.1])
- Parameters:
modes (
Sequence
[int
]) – The modes this gate is applied to.transmissivity (
Union
[float
,None
,list
[float
]]) – The transmissivity.transmissivity_trainable (
bool
) – Whether the transmissivity is a trainable variable.transmissivity_bounds (
Tuple
[Optional
[float
],Optional
[float
]]) – The bounds for the transmissivity.
Details and Conventions
The \(N\)-mode attenuator is defined as
\[X = \text{cos}(\theta)I_{2N} \text{ , } Y = \text{sin}^2(\theta)I_{2N} \text{ , and } d = O_{4N}\:,\]where the \(\theta=\text{arcos}(\sqrt{\bar{\eta}})\), \(\eta\) is the transmissivity, and \(\text{diag}_N(\bar{\eta})\) is the \(N\text{x}N\) matrix with diagonal \(\bar{\eta}\).
Its
(A,b,c)
triple is given by\[\begin{split}A &= \begin{bmatrix} O_N & \text{diag}_N(\sqrt{\bar{\eta}}) & O_N & O_N \\ \text{diag}_N(\sqrt{\bar{\eta}}) & O_N & O_N & \text{diag}_N(1-\sqrt{\bar{\eta}})\\ O_N & O_N & O_N & \text{diag}_N(\sqrt{\bar{\eta}})\\ O_N & \text{diag}_N(1-\sqrt{\bar{\eta}}) & \text{diag}_N(\sqrt{\bar{\eta}}) & O_N \end{bmatrix} \\ \\ b &= O_{4N} \\ \\ c &= 1\:.\end{split}\]Attributes
The
AdjointView
of this component.The
DualView
of this component.The sorted list of modes of this component.
The number of modes in this component.
The name of this component.
The set of parameters characterizing this component.
A representation of this circuit component.
The wires of this component.
- adjoint¶
The
AdjointView
of this component.
- dual¶
The
DualView
of this component.
- modes¶
The sorted list of modes of this component.
- n_modes¶
The number of modes in this component.
- name¶
The name of this component.
- parameter_set¶
The set of parameters characterizing this component.
- representation¶
- wires¶
The wires of this component.
Methods
Creates a copy of this component by copying every data stored in memory for it by reference, except for its wires, which are copied by value.
on
(modes)Creates a copy of this component that acts on the given
modes
instead of on the original modes.to_fock_component
([shape])Returns a circuit component with the same attributes as this component, but with
Fock
representation.- light_copy()¶
Creates a copy of this component by copying every data stored in memory for it by reference, except for its wires, which are copied by value.
- Return type:
- on(modes)¶
Creates a copy of this component that acts on the given
modes
instead of on the original modes.- Parameters:
modes (
Sequence
[int
]) – The new modes that this component acts on.- Return type:
- Returns:
The component acting on the specified modes.
- Raises:
ValueError – If
modes
contains more or less modes than the original component.
- to_fock_component(shape=None)¶
Returns a circuit component with the same attributes as this component, but with
Fock
representation.Uses the
mrmustard.physics.converters.to_fock()
method to convert the internal representation.>>> from mrmustard.physics.converters import to_fock >>> from mrmustard.lab_dev import Dgate >>> d = Dgate([1], x=0.1, y=0.1) >>> d_fock = d.to_fock_component(shape=3) >>> assert d_fock.name == d.name >>> assert d_fock.wires == d.wires >>> assert d_fock.representation == to_fock(d.representation, shape=3)
- Parameters:
shape (
Union
[int
,Iterable
[int
],None
]) – The shape of the returned representation. Ifshape``is given as an ``int
, it is broadcasted to all the dimensions. IfNone
, it defaults to the value ofAUTOCUTOFF_MAX_CUTOFF
in the settings.- Return type: