mm.physics.converters.to_fock¶
- mrmustard.physics.converters.to_fock(rep, shape=None)[source]¶
A function to map
Representation
s toFock
representations.If the given
rep
isFock
, this function simply returnsrep
.- Parameters:
rep (
Representation
) – The orginal representation of the object.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.
- Raises:
ValueError – If the size of the shape given is not compatible with the representation.
- Return type:
- Returns:
A
Fock
representation object.
>>> from mrmustard.physics.converters import to_fock >>> from mrmustard.physics.representations import Bargmann, Fock >>> from mrmustard.physics.triples import displacement_gate_Abc >>> bargmann = Bargmann(*displacement_gate_Abc(x=0.1, y=[0.2, 0.3])) >>> fock = to_fock(bargmann, shape=10) >>> assert isinstance(fock, Fock)
code/api/mrmustard.physics.converters.to_fock
Download Python script
Download Notebook
View on GitHub