Skip to content

Commit

Permalink
added bargmann eigenstates
Browse files Browse the repository at this point in the history
  • Loading branch information
arsalan-motamedi committed Nov 7, 2024
1 parent 50917c8 commit bdecc2f
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions mrmustard/lab_dev/states/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 57 additions & 0 deletions mrmustard/lab_dev/states/bargmanneigenstate.py
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions mrmustard/physics/triples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit bdecc2f

Please sign in to comment.