Source code for mrmustard.lab.circuit_components_utils.b_to_ps
# 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 an operation that changes Bargmann into phase space."""
from __future__ import annotations
from collections.abc import Sequence
from mrmustard.parameters import Parameter
from mrmustard.physics.ansatz_factory import AnsatzFactory
from mrmustard.physics.wires import ReprEnum, Wires
from mrmustard.utils.typing import ComplexTensor
from ..transformations.base import Map
from .builtins import bargmann_to_wigner
__all__ = ["BtoPS"]
[docs]
class BtoPS(Map):
r"""The `s`-parametrized Stratonovich-Weyl kernel as a ``Map``.
Used internally as a ``Channel`` for transformations between representations.
Args:
modes: The modes of this channel.
s: The `s` parameter of this channel. The case `s=-1` corresponds to Husimi, `s=0` to Wigner, and `s=1` to Glauber P function.
"""
short_name = "BtoPS"
def __init__(
self,
modes: int | tuple[int, ...],
s: float,
):
modes = (modes,) if isinstance(modes, int) else modes
super().__init__(
ansatz_factory=AnsatzFactory(
ansatz_dict={ReprEnum.BARGMANN: (bargmann_to_wigner, ("s", "n_modes", "lin_sup"))},
n_modes=len(modes),
),
wires=Wires(
modes_in_bra=set(modes),
modes_out_bra=set(modes),
modes_in_ket=set(modes),
modes_out_ket=set(modes),
),
name=self.__class__.__name__,
)
self.parameters["s"] = Parameter.from_cc_init(s, "float64", f"{self.name}/s")
for w in self.wires.output.standard_order:
w.repr = ReprEnum.PHASESPACE
[docs]
def fock_array(self, shape: int | Sequence[int] | None = None) -> ComplexTensor:
raise NotImplementedError(f"{self.__class__.__name__} does not have a Fock representation.")
_modules/mrmustard/lab/circuit_components_utils/b_to_ps
Download Python script
Download Notebook
View on GitHub