qfunc-0.1.0.0
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Lib.Core

Description

The core language operations.

Synopsis

QBit manipulation

new :: Bit -> QM QBit Source #

Create new QBit from a bit. maps \(0 \mapsto |0>\) and \(1 \mapsto |1>\)

measure :: QBit -> QM Bit Source #

Performs a measurement operation, collapsing a QBit to a Bit. The qubit will still exist in the quantum state, but be collapsed.

Finds qubit probability to collapse to a zero and one. Uses random number generator to "measure it" to a zero or one. Updates quantum state to remove impossible states, and normalizes it so probabilites sum to one.

Control functions

controlbit :: QM a -> Bit -> QM () Source #

Sets a classical bit as the controlbit for a quantum gate. Making it run only when the classical bit is equal to one.

(===) :: QM a -> Bit -> QM () Source #

Synonym for controlbit

Distribution functions

dist :: QM Bit -> IO () Source #

Print results from a 100 runs of a program

ndist :: Int -> QM Bit -> IO () Source #

Run a quantum program producing a single bit reps times and print the results

Bit

data Bit #

Instances

Instances details
Bounded Bit 
Instance details

Defined in Data.Bit.Internal

Methods

minBound :: Bit #

maxBound :: Bit #

Enum Bit 
Instance details

Defined in Data.Bit.Internal

Methods

succ :: Bit -> Bit #

pred :: Bit -> Bit #

toEnum :: Int -> Bit #

fromEnum :: Bit -> Int #

enumFrom :: Bit -> [Bit] #

enumFromThen :: Bit -> Bit -> [Bit] #

enumFromTo :: Bit -> Bit -> [Bit] #

enumFromThenTo :: Bit -> Bit -> Bit -> [Bit] #

Eq Bit 
Instance details

Defined in Data.Bit.Internal

Methods

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

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

Fractional Bit 
Instance details

Defined in Data.Bit.Internal

Methods

(/) :: Bit -> Bit -> Bit #

recip :: Bit -> Bit #

fromRational :: Rational -> Bit #

Integral Bit 
Instance details

Defined in Data.Bit.Internal

Methods

quot :: Bit -> Bit -> Bit #

rem :: Bit -> Bit -> Bit #

div :: Bit -> Bit -> Bit #

mod :: Bit -> Bit -> Bit #

quotRem :: Bit -> Bit -> (Bit, Bit) #

divMod :: Bit -> Bit -> (Bit, Bit) #

toInteger :: Bit -> Integer #

Num Bit 
Instance details

Defined in Data.Bit.Internal

Methods

(+) :: Bit -> Bit -> Bit #

(-) :: Bit -> Bit -> Bit #

(*) :: Bit -> Bit -> Bit #

negate :: Bit -> Bit #

abs :: Bit -> Bit #

signum :: Bit -> Bit #

fromInteger :: Integer -> Bit #

Ord Bit 
Instance details

Defined in Data.Bit.Internal

Methods

compare :: Bit -> Bit -> Ordering #

(<) :: Bit -> Bit -> Bool #

(<=) :: Bit -> Bit -> Bool #

(>) :: Bit -> Bit -> Bool #

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

max :: Bit -> Bit -> Bit #

min :: Bit -> Bit -> Bit #

Read Bit 
Instance details

Defined in Data.Bit.Internal

Real Bit 
Instance details

Defined in Data.Bit.Internal

Methods

toRational :: Bit -> Rational #

Show Bit 
Instance details

Defined in Data.Bit.Internal

Methods

showsPrec :: Int -> Bit -> ShowS #

show :: Bit -> String #

showList :: [Bit] -> ShowS #

Generic Bit 
Instance details

Defined in Data.Bit.Internal

Associated Types

type Rep Bit :: Type -> Type #

Methods

from :: Bit -> Rep Bit x #

to :: Rep Bit x -> Bit #

Bits Bit 
Instance details

Defined in Data.Bit.Internal

Methods

(.&.) :: Bit -> Bit -> Bit #

(.|.) :: Bit -> Bit -> Bit #

xor :: Bit -> Bit -> Bit #

complement :: Bit -> Bit #

shift :: Bit -> Int -> Bit #

rotate :: Bit -> Int -> Bit #

zeroBits :: Bit #

bit :: Int -> Bit #

setBit :: Bit -> Int -> Bit #

clearBit :: Bit -> Int -> Bit #

complementBit :: Bit -> Int -> Bit #

testBit :: Bit -> Int -> Bool #

bitSizeMaybe :: Bit -> Maybe Int #

bitSize :: Bit -> Int #

isSigned :: Bit -> Bool #

shiftL :: Bit -> Int -> Bit #

unsafeShiftL :: Bit -> Int -> Bit #

shiftR :: Bit -> Int -> Bit #

unsafeShiftR :: Bit -> Int -> Bit #

rotateL :: Bit -> Int -> Bit #

rotateR :: Bit -> Int -> Bit #

popCount :: Bit -> Int #

FiniteBits Bit 
Instance details

Defined in Data.Bit.Internal

NFData Bit 
Instance details

Defined in Data.Bit.Internal

Methods

rnf :: Bit -> () #

Unbox Bit 
Instance details

Defined in Data.Bit.Internal

MVector MVector Bit 
Instance details

Defined in Data.Bit.Internal

Methods

basicLength :: MVector s Bit -> Int

basicUnsafeSlice :: Int -> Int -> MVector s Bit -> MVector s Bit

basicOverlaps :: MVector s Bit -> MVector s Bit -> Bool

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) Bit)

basicInitialize :: PrimMonad m => MVector (PrimState m) Bit -> m ()

basicUnsafeReplicate :: PrimMonad m => Int -> Bit -> m (MVector (PrimState m) Bit)

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) Bit -> Int -> m Bit

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) Bit -> Int -> Bit -> m ()

basicClear :: PrimMonad m => MVector (PrimState m) Bit -> m ()

basicSet :: PrimMonad m => MVector (PrimState m) Bit -> Bit -> m ()

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) Bit -> MVector (PrimState m) Bit -> m ()

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) Bit -> MVector (PrimState m) Bit -> m ()

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) Bit -> Int -> m (MVector (PrimState m) Bit)

Vector Vector Bit 
Instance details

Defined in Data.Bit.Internal

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) Bit -> m (Vector Bit)

basicUnsafeThaw :: PrimMonad m => Vector Bit -> m (Mutable Vector (PrimState m) Bit)

basicLength :: Vector Bit -> Int

basicUnsafeSlice :: Int -> Int -> Vector Bit -> Vector Bit

basicUnsafeIndexM :: Monad m => Vector Bit -> Int -> m Bit

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Bit -> Vector Bit -> m ()

elemseq :: Vector Bit -> Bit -> b -> b

type Rep Bit 
Instance details

Defined in Data.Bit.Internal

type Rep Bit = D1 ('MetaData "Bit" "Data.Bit.Internal" "bitvec-1.0.3.0-1bYctJlKC6eAXJO2rehjXD" 'True) (C1 ('MetaCons "Bit" 'PrefixI 'True) (S1 ('MetaSel ('Just "unBit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))
data Vector Bit 
Instance details

Defined in Data.Bit.Internal

data Vector Bit = BitVec !Int !Int !ByteArray
data MVector s Bit 
Instance details

Defined in Data.Bit.Internal

data MVector s Bit = BitMVec !Int !Int !(MutableByteArray s)