hqcsim-0.1.0.0: A library for simulating quantum circuits.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Quantum.Gates

Description

 
Synopsis

Documentation

iGate :: Gate Source #

  • iGate function represent an Identity Matrix
>>> iGate
(2><2)
[ 1.0 :+ 0.0, 0.0 :+ 0.0
, 0.0 :+ 0.0, 1.0 :+ 0.0 ]

swapGate :: Gate Source #

  • swapGate function represent a Swap Gate
>>> swapGate
(4><4)
[ 1.0 :+ 0.0, 0.0 :+ 0.0, 0.0 :+ 0.0, 0.0 :+ 0.0
, 0.0 :+ 0.0, 0.0 :+ 0.0, 1.0 :+ 0.0, 0.0 :+ 0.0
, 0.0 :+ 0.0, 1.0 :+ 0.0, 0.0 :+ 0.0, 0.0 :+ 0.0
, 0.0 :+ 0.0, 0.0 :+ 0.0, 0.0 :+ 0.0, 1.0 :+ 0.0 ]

hGate :: Gate Source #

  • hGate function represent a Hadamard Gate
>>> hGate
 (2><2)
 [ 0.7071067811865475 :+ 0.0,    0.7071067811865475 :+ 0.0
 , 0.7071067811865475 :+ 0.0, (-0.7071067811865475) :+ 0.0 ]

xGate :: Gate Source #

  • xGate function represent a Pauli X-Gate
>>> xGate
(2><2)
[ 0.0 :+ 0.0, 1.0 :+ 0.0
, 1.0 :+ 0.0, 0.0 :+ 0.0 ]

yGate :: Gate Source #

  • yGate function represent a Pauli Y-Gate
>>> yGate
(2><2)
[ 0.0 :+ 0.0, 0.0 :+ (-1.0)
, 0.0 :+ 1.0,    0.0 :+ 0.0 ]

zGate :: Gate Source #

  • zGate function represent a Pauli Z-Gate
>>> zGate
(2><2)
[ 1.0 :+ 0.0,       0.0 :+ 0.0
, 0.0 :+ 0.0, (-1.0) :+ (-0.0) ]

cNotGate :: Gate Source #

  • cNotGate function represent a Controlled-Not Gate
>>> cNotGate
(4><4)
[ 1.0 :+ 0.0, 0.0 :+ 0.0, 0.0 :+ 0.0, 0.0 :+ 0.0
, 0.0 :+ 0.0, 1.0 :+ 0.0, 0.0 :+ 0.0, 0.0 :+ 0.0
, 0.0 :+ 0.0, 0.0 :+ 0.0, 0.0 :+ 0.0, 1.0 :+ 0.0
, 0.0 :+ 0.0, 0.0 :+ 0.0, 1.0 :+ 0.0, 0.0 :+ 0.0 ]

type Gate = Matrix (Complex Double) Source #

The Gate type is an alias for a matrix of complex numbers.

In quantum computing, a Gate is a unitary matrix that represents a quantum operation applied to qubits. The matrix elements are complex numbers.

The Gate type is used to describe quantum gates in algorithms. For example:

-- Represents a 2x2 Hadamard Gate
hGate :: Gate
hGate = (2LA.><2)
  [1sqrt 2,1sqrt 2,1sqrt 2,(-1)sqrt 2] :: Gate