Skip to content

Commit

Permalink
Making S2gate of lab and lab_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
arsalan-motamedi committed Jan 31, 2025
1 parent 5a11703 commit c10e9e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions mrmustard/lab_dev/transformations/s2gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class S2gate(Unitary):
A = \begin{bmatrix}
O & e^{i\phi}\tanh(r) & \sech(r) & 0 \\
e^{i\phi}\tanh(r) & 0 & 0 & \sech(r) \\
\sech(r) & & 0 & 0 e^{i\phi}\tanh(r) \\
O & \sech(r) & e^{i\phi}\tanh(r) & 0
\sech(r) & & 0 & 0 -e^{i\phi}\tanh(r) \\
O & \sech(r) & -e^{i\phi}\tanh(r) & 0
\end{bmatrix} \text{, }
b = O_{4} \text{, and }
c = \sech(r)
Expand Down
4 changes: 2 additions & 2 deletions mrmustard/physics/triples.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ def twomode_squeezing_gate_Abc(
tanhr = math.diag(math.exp(1j * phi) * math.sinh(r) / math.cosh(r))
sechr = math.diag(1 / math.cosh(r))

A_block1 = math.block([[O, -tanhr], [-tanhr, O]])
A_block1 = math.block([[O, tanhr], [tanhr, O]])

A_block2 = math.block([[O, math.conj(tanhr)], [math.conj(tanhr), O]])
A_block2 = math.block([[O, -math.conj(tanhr)], [-math.conj(tanhr), O]])

A_block3 = math.block([[sechr, O], [O, sechr]])

Expand Down
10 changes: 5 additions & 5 deletions tests/test_lab_dev/test_transformations/test_s2gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def test_representation(self):

A_exp = [
[
[0, -tanhr, sechr, 0],
[-tanhr, 0, 0, sechr],
[sechr, 0, 0, np.conj(tanhr)],
[0, sechr, np.conj(tanhr), 0],
[0, tanhr, sechr, 0],
[tanhr, 0, 0, sechr],
[sechr, 0, 0, -np.conj(tanhr)],
[0, sechr, -np.conj(tanhr), 0],
]
]
assert math.allclose(rep1.A, A_exp)
Expand All @@ -77,7 +77,7 @@ def test_trainable_parameters(self):
assert gate3.parameters.phi.value == 2

def test_operation(self):
rep1 = (Vacuum([0]) >> Vacuum([1]) >> S2gate(modes=[0, 1], r=1, phi=0.5)).ansatz
rep1 = (Vacuum([0]) >> Vacuum([1]) >> S2gate(modes=[0, 1], r=-1, phi=0.5)).ansatz
rep2 = (TwoModeSqueezedVacuum(modes=[0, 1], r=1, phi=0.5)).ansatz

assert math.allclose(rep1.A, rep2.A)
Expand Down

0 comments on commit c10e9e5

Please sign in to comment.