mm.physics.converters.to_fock

mrmustard.physics.converters.to_fock(rep, shape=None)[source]

A function to map Representations to Fock representations.

If the given rep is Fock, this function simply returns rep.

Parameters:
  • rep (Representation) – The orginal representation of the object.

  • shape (Union[int, Iterable[int], None]) – The shape of the returned representation. If shape``is given as an ``int, it is broadcasted to all the dimensions. If None, it defaults to the value of AUTOCUTOFF_MAX_CUTOFF in the settings.

Raises:

ValueError – If the size of the shape given is not compatible with the representation.

Return type:

Fock

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)