diff --git a/mrmustard/lab_dev/states/__init__.py b/mrmustard/lab_dev/states/__init__.py index 3e6ee5e5d..35581e03c 100644 --- a/mrmustard/lab_dev/states/__init__.py +++ b/mrmustard/lab_dev/states/__init__.py @@ -20,6 +20,7 @@ from .ket import Ket from .dm import DM +from .bargmanneigenstate import BargmannEigenstate from .coherent import Coherent from .displaced_squeezed import DisplacedSqueezed from .number import Number diff --git a/mrmustard/lab_dev/states/bargmanneigenstate.py b/mrmustard/lab_dev/states/bargmanneigenstate.py new file mode 100644 index 000000000..2863f15b9 --- /dev/null +++ b/mrmustard/lab_dev/states/bargmanneigenstate.py @@ -0,0 +1,57 @@ +# Copyright 2024 Xanadu Quantum Technologies Inc. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +The class representing a Bargmann eigenstate. +""" + +from __future__ import annotations + +from typing import Sequence + +from mrmustard.physics.ansatz import PolyExpAnsatz +from mrmustard.physics import triples +from .ket import Ket +from ..utils import make_parameter, reshape_params + +__all__ = ["BargmannEigenstate"] + + +class BargmannEigenstate(Ket): + r""" + Multimode Bargmann eigenstate. These are basically re-scaled coherent states i.e., + .. math:: + A = 0 , b = alpha, c = 1 + """ + + short_name = "Be" + + def __init__( + self, + modes: Sequence[int], + alpha: float | Sequence[float] = 0.0, + alpha_trainable: bool = False, + alpha_bounds: tuple[float | None, float | None] = (None, None), + ): + super().__init__(name="BargmannEigenstate") + + alphas = list(reshape_params(len(modes), alphas=alpha)) + self._add_parameter(make_parameter(alpha_trainable, alphas, "alpha", alpha_bounds)) + print(self.alpha.value) + self._representation = self.from_ansatz( + modes=modes, + ansatz=PolyExpAnsatz.from_function( + fn=triples.bargmann_eigenstate_Abc, x=self.alpha.value + ), + ).representation diff --git a/mrmustard/physics/triples.py b/mrmustard/physics/triples.py index c41367fd6..c46e1d13e 100644 --- a/mrmustard/physics/triples.py +++ b/mrmustard/physics/triples.py @@ -94,6 +94,18 @@ def vacuum_state_Abc(n_modes: int) -> Union[Matrix, Vector, Scalar]: return A, b, c +def bargmann_eigenstate_Abc(x: Union[float, Iterable[float]]) -> Union[Matrix, Vector, Scalar]: + r""" + The Abc triple of a Bargmann eigenstate. + """ + x = list(_reshape(x=x)) + nmodes = len(x) + A = _vacuum_A_matrix(nmodes) + b = x + c = 1 + return A, b, c + + def coherent_state_Abc( x: Union[float, Iterable[float]], y: Union[float, Iterable[float]] = 0 ) -> Union[Matrix, Vector, Scalar]: