Prev: Automated Testing Up: Contents Next: GATES.HS

CIRCUIT.HS

module Circuit where
import Complex
import Gates

type Circuit = ( Int, Int, [Gate] )

-- test circuits
notTestCircuit :: Int -> Int -> Circuit
notTestCircuit (n+1) i = (n+1, i, (sqrtGates [0..n]) ++ (sqrtGates [0..n]) )

flipTestCircuit :: Int -> Int -> Circuit
flipTestCircuit (n+1) i = (n+1, i, (flipGates [0..n]) ++ (flipGates [0..n]) )

-- QFT
qft :: Int -> Int -> [Gate]
qft 0 l = [shorRGate 0]
qft n l = (shorRGate n) : (shorSGates (n-1) (l-1)) ++ qft (n-1) l

-- Pure QFT
qftCircuit :: Int -> Int -> Circuit
qftCircuit (n+1) i = (n+1, i, (qft n (n+1)) )

-- Circuit for factorisation
qftFactor :: Int -> Circuit
qftFactor n = ( d, 0, (qft (n-1) n) ++ swapGates [0..n-1] ) 
                   where d = n + div (n+1) 2

Prev: Automated Testing Up: Contents Next: GATES.HS

This web page (c) 2000 Jon Marshall. Last updated 3rd June 2000