Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
arsalan-motamedi committed Oct 17, 2024
1 parent 1f44cbc commit b161715
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
15 changes: 5 additions & 10 deletions mrmustard/lab_dev/transformations/grn.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,17 @@ class GRN(Channel):
"""

short_name = "GRN"

def __init__(
self,
modes: Sequence[int],
Y: RealMatrix,
Y_train: bool = False,):
Y_train: bool = False,
):

super().__init__(modes_out=modes, modes_in=modes, name="GRN")
self._add_parameter(
make_parameter(
Y_train,
value= Y,
name="Y",
bounds = (None, None)
)
)
self._add_parameter(make_parameter(Y_train, value=Y, name="Y", bounds=(None, None)))

self._representation = Bargmann.from_function(
fn=triples.gaussian_random_noise_Abc, Y = self.Y.value
fn=triples.gaussian_random_noise_Abc, Y=self.Y.value
)
36 changes: 22 additions & 14 deletions mrmustard/physics/triples.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,21 +606,29 @@ def fock_damping_Abc(


def gaussian_random_noise_Abc(Y: RealMatrix) -> Union[Matrix, Vector, Scalar]:
m = Y.shape[-1]//2
xi = math.eye(2*m) + Y/settings.HBAR
m = Y.shape[-1] // 2
xi = math.eye(2 * m) + Y / settings.HBAR
xi_inv = math.inv(xi)
temp = math.block([[math.eye(2*m) - xi_inv, xi_inv],
[xi_inv, math.eye(2*m) - xi_inv]])
R = 1/np.sqrt(2) * math.block([[math.eye(m), 1j * math.eye(m), math.zeros((m,2*m))],
[math.zeros((m,2*m)), math.eye(m), -1j * math.eye(m)],
[math.eye(m), -1j * math.eye(m), math.zeros((m,2*m))],
[math.zeros((m,2*m)), math.eye(m), 1j * math.eye(m)]])

A = math.Xmat(2*m) @ R @ temp @ math.conj(R).T
b = math.zeros(2*m)
c = 1/math.sqrt(math.det(xi))

return A,b,c
temp = math.block([[math.eye(2 * m) - xi_inv, xi_inv], [xi_inv, math.eye(2 * m) - xi_inv]])
R = (
1
/ np.sqrt(2)
* math.block(
[
[math.eye(m), 1j * math.eye(m), math.zeros((m, 2 * m))],
[math.zeros((m, 2 * m)), math.eye(m), -1j * math.eye(m)],
[math.eye(m), -1j * math.eye(m), math.zeros((m, 2 * m))],
[math.zeros((m, 2 * m)), math.eye(m), 1j * math.eye(m)],
]
)
)

A = math.Xmat(2 * m) @ R @ temp @ math.conj(R).T
b = math.zeros(2 * m)
c = 1 / math.sqrt(math.det(xi))

return A, b, c


def bargmann_to_quadrature_Abc(n_modes: int, phi: float) -> tuple[Matrix, Vector, Scalar]:
r"""
Expand Down

0 comments on commit b161715

Please sign in to comment.