module Quantum.Gates
(
iGate
, swapGate
, hGate
, xGate
, yGate
, zGate
, cNotGate
, Gate
)where
import qualified Numeric.LinearAlgebra as LA
import Quantum.QDataTypes
iGate :: Gate
iGate :: Gate
iGate = Int -> Gate
forall a. (Num a, Element a) => Int -> Matrix a
LA.ident Int
2 :: Gate
swapGate :: Gate
swapGate :: Gate
swapGate = (Int
4Int -> Int -> [Complex Double] -> Gate
forall a. Storable a => Int -> Int -> [a] -> Matrix a
LA.><Int
4)
[ Complex Double
1, Complex Double
0, Complex Double
0, Complex Double
0
, Complex Double
0, Complex Double
0, Complex Double
1, Complex Double
0
, Complex Double
0, Complex Double
1, Complex Double
0, Complex Double
0
, Complex Double
0, Complex Double
0, Complex Double
0, Complex Double
1]::Gate
hGate :: Gate
hGate :: Gate
hGate = (Int
2Int -> Int -> [Complex Double] -> Gate
forall a. Storable a => Int -> Int -> [a] -> Matrix a
LA.><Int
2) [Complex Double
1Complex Double -> Complex Double -> Complex Double
forall a. Fractional a => a -> a -> a
/Complex Double -> Complex Double
forall a. Floating a => a -> a
sqrt Complex Double
2,Complex Double
1Complex Double -> Complex Double -> Complex Double
forall a. Fractional a => a -> a -> a
/Complex Double -> Complex Double
forall a. Floating a => a -> a
sqrt Complex Double
2,Complex Double
1Complex Double -> Complex Double -> Complex Double
forall a. Fractional a => a -> a -> a
/Complex Double -> Complex Double
forall a. Floating a => a -> a
sqrt Complex Double
2,(-Complex Double
1)Complex Double -> Complex Double -> Complex Double
forall a. Fractional a => a -> a -> a
/Complex Double -> Complex Double
forall a. Floating a => a -> a
sqrt Complex Double
2] :: Gate
yGate :: Gate
yGate :: Gate
yGate = (Int
2Int -> Int -> [Complex Double] -> Gate
forall a. Storable a => Int -> Int -> [a] -> Matrix a
LA.><Int
2) [Complex Double
0.0,Double
0.0Double -> Double -> Complex Double
forall a. a -> a -> Complex a
LA.:+(-Double
1.0),Double
0.0Double -> Double -> Complex Double
forall a. a -> a -> Complex a
LA.:+Double
1.0,Complex Double
0.0] :: Gate
zGate :: Gate
zGate :: Gate
zGate = (Int
2Int -> Int -> [Complex Double] -> Gate
forall a. Storable a => Int -> Int -> [a] -> Matrix a
LA.><Int
2) [Complex Double
1,Complex Double
0,Complex Double
0,-Complex Double
1] :: Gate
xGate :: Gate
xGate :: Gate
xGate = (Int
2Int -> Int -> [Complex Double] -> Gate
forall a. Storable a => Int -> Int -> [a] -> Matrix a
LA.><Int
2) [Complex Double
0,Complex Double
1,Complex Double
1,Complex Double
0] :: Gate
cNotGate :: Gate
cNotGate :: Gate
cNotGate = (Int
4Int -> Int -> [Complex Double] -> Gate
forall a. Storable a => Int -> Int -> [a] -> Matrix a
LA.><Int
4)
[Complex Double
1,Complex Double
0,Complex Double
0,Complex Double
0,
Complex Double
0,Complex Double
1,Complex Double
0,Complex Double
0,
Complex Double
0,Complex Double
0,Complex Double
0,Complex Double
1
,Complex Double
0,Complex Double
0,Complex Double
1,Complex Double
0] :: Gate