From 78838396c195d80dff82929bb0940a36bf3e47df Mon Sep 17 00:00:00 2001
From: Lou Bernabeu <lou.bernabeu@student-cs.fr>
Date: Wed, 6 Jan 2021 14:26:26 +0100
Subject: [PATCH] implemented common plate matrices for quantum gates and
 actual plate

---
 __main__.py |  2 ++
 matrices.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 matrices.py

diff --git a/__main__.py b/__main__.py
index bc5b490..873ba8c 100644
--- a/__main__.py
+++ b/__main__.py
@@ -1,4 +1,6 @@
 import numpy as np
+import matplotlib as mpl
+import matplotlib.pyplot as plt
 import elements
 import graphics
 
diff --git a/matrices.py b/matrices.py
new file mode 100644
index 0000000..3976ce0
--- /dev/null
+++ b/matrices.py
@@ -0,0 +1,44 @@
+import numpy as np
+
+### Pauli matrices
+
+X = np.array([[0, 1], [1, 0]], dtype="complex")
+Y = np.array([[0, 0.-1j], [0+1j, 0]], dtype = "complex")
+Z = np.array([[1, 0], [0, -1]], dtype = "complex")
+
+### Other One-qubit matrices
+
+H = np.array([[1, 1],[1, -1]], dtype='complex')
+S = np.array([[1, 0], [0, 0+1j]], dtype='complex')
+T = np.array([[1, 0], [0, np.exp(complex(0, np.pi/8))]], dtype="complex")
+
+
+QUARTER_WAVE_RIGHT_CIRCULAR_RETARDER = (1/np.sqrt(2))*np.array([[1j, 1j],
+                                                                [-1j, 1j]])
+QUARTER_WAVE_LEFT_CIRCULAR_RETARDER = QUARTER_WAVE_RIGHT_CIRCULAR_RETARDER.T
+
+HALF_WAVE_RIGHT_CIRCULAR_RETARDER = 1j*Y
+HALF_WAVE_LEFT_CIRCULAR_RETARDER = 1j*Y.T
+
+### Matrix functions
+
+def PHASE(angle):
+    return np.array([[1, 0], [0, np.exp(complex(0, angle))]], dtype="complex")
+
+def LINEAR_POLARIZER(theta):
+    return np.array([[np.cos(theta)*np.cos(theta), np.cos(theta)*np.sin(theta)],
+                     [np.cos(theta)*np.sin(theta), np.sin(theta)*np.sin(theta)]])
+
+def ELLIPTICAL_POLARIZER(epsilon, psi):
+    J11 = np.cos(psi)**2 + (epsilon*np.sin(psi))**2
+    J12 = 1j*epsilon + (epsilon**2 - 1)*np.cons(psi)*np.sin(psi)
+    J22 = (epsilon*np.cos(psi))**2 + np.sin(psi)**2
+    return (1/(1+epsilon**2))*np.array([[J11, J12],
+                                        [-J12, J22]])
+
+def LINEAR_RETARDER(delta, theta): ### symmetric phase convention
+    L11 = np.exp(-1j*delta/2)*(np.cos(theta)**2) + np.exp(1j*delta/2)*(np.sin(theta)**2)
+    L12 =-1j*np.sin(delta/2)*np.sin(2*theta)
+    L22 = np.exp(1j*delta/2)*(np.cos(theta)**2) + np.exp(-1j*delta/2)*(np.sin(theta)**2)
+    return np.array([[L11, L12],
+                     [L12, L22]])
-- 
GitLab