qchas-1.0.1.0: A library for implementing Quantum Algorithms

Safe HaskellNone
LanguageHaskell2010

Qubits

Description

  • Module : Qubits
  • Description : Definitions of |0>, |1>, |+> and |->
  • Copyright : (c) Mihai Sebastian Ardelean, 2017
  • License : BSD3
  • Maintainer : ardeleanasm@gmail.com
  • Portability : POSIX

Synopsis

Documentation

qOne :: Qubit Source #

  • qOne function is used to represent a 1 qubit |1>
>>> qOne
(2><1)
[ 0.0 :+ 0.0
, 1.0 :+ 0.0 ]

qZero :: Qubit Source #

  • qZero function is used to represent a 0 qubit |0>
>>> qZero
(2><1)
[ 1.0 :+ 0.0
, 0.0 :+ 0.0 ]

qPlus :: Qubit Source #

  • qPlus function is used to represent a + qubit |+>
  • |+> can be also obtained by applying Hadamard Gate on |0>. See apply for more information
>>> qPlus
(2><1)
[ 0.7071067811865475 :+ 0.0
, 0.7071067811865475 :+ 0.0 ]

qMinus :: Qubit Source #

  • qMinus function is used to represent a - qubit |->
  • Same as |+>, qubit |-> can be obtained by applying Hadamard Gate on |1>. See apply for more information
>>> qMinus
(2><1)
[       0.7071067811865475 :+ 0.0
, (-0.7071067811865475) :+ (-0.0) ]

entangle Source #

Arguments

:: Qubit

first Qubit argument

-> Qubit

second Qubit argument

-> Qubit

return value: Qubit

  • entangle function is used to perform the Kronecker product between two qubits.
>>> entangle qZero qOne
(4><1)
 [ 0.0 :+ 0.0
 , 1.0 :+ 0.0
 , 0.0 :+ 0.0
 , 0.0 :+ 0.0 ]

apply Source #

Arguments

:: Gate

Gate argument

-> Qubit

Qubit argument

-> Qubit

return value: Qubit

  • apply function is used to apply a gate on a qubit
>>> apply hGate qZero
 (2><1)
 [ 0.7071067811865475 :+ 0.0
 , 0.7071067811865475 :+ 0.0 ]

(|>) Source #

Arguments

:: Qubit

Qubit argument

-> Gate

Gate argument

-> Qubit

return value: Qubit

  • |> function have the same effect like apply.
>>> qZero |> hGate
 (2><1)
 [ 0.7071067811865475 :+ 0.0
 , 0.7071067811865475 :+ 0.0 ]

(|><|) Source #

Arguments

:: Qubit

Qubit argument

-> Qubit

Qubit argument

-> Gate

return value: Gate

  • |><| function represents the outer product.
>>> qZero |><| qZero
 (2><2)
 [ 1.0 :+ 0.0, 0.0 :+ 0.0
 , 0.0 :+ 0.0, 0.0 :+ 0.0 ]}

data Qubit Source #

Constructors

Qubit 

Fields

Instances

Eq Qubit Source # 

Methods

(==) :: Qubit -> Qubit -> Bool #

(/=) :: Qubit -> Qubit -> Bool #

Show Qubit Source # 

Methods

showsPrec :: Int -> Qubit -> ShowS #

show :: Qubit -> String #

showList :: [Qubit] -> ShowS #