Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symplectic override on Ggate #495

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions mrmustard/lab_dev/transformations/ggate.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ def __init__(
symplectic_trainable: bool = False,
):
super().__init__(modes_out=modes, modes_in=modes, name="Ggate")
S = make_parameter(symplectic_trainable, symplectic, "symplectic", (None, None))
self.parameter_set.add_parameter(S)

self._add_parameter(
make_parameter(symplectic_trainable, symplectic, "symplectic", (None, None))
)
self._representation = Bargmann.from_function(
fn=lambda s: Unitary.from_symplectic(modes, s).bargmann_triple(),
s=self.parameter_set.symplectic,
)

@property
def symplectic(self):
return self.parameter_set.symplectic.value
1 change: 1 addition & 0 deletions tests/test_lab_dev/test_transformations/test_ggate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_init(self):
Eye = Ggate(modes=[0], symplectic=math.eye(2))
assert isinstance(Eye, Ggate)
assert Eye.name == "Ggate"
assert math.allclose(Eye.symplectic, math.eye(2))

def test_ggate_is_unitary_1mode(self):
"""Test that the Ggate applied to its dual is the identity."""
Expand Down
Loading