Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module defines the functions that can be used to simulate the running of QIO computations.
- type Pure = VecEqL CC HeapMap
- updateP :: Pure -> Qbit -> Bool -> Pure
- newtype Unitary = U {}
- unitaryRot :: Rotation -> Bool
- uMatrix :: Qbit -> (CC, CC, CC, CC) -> Unitary
- uRot :: Qbit -> Rotation -> Unitary
- uSwap :: Qbit -> Qbit -> Unitary
- uCond :: Qbit -> (Bool -> Unitary) -> Unitary
- uLet :: Bool -> (Qbit -> Unitary) -> Unitary
- runU :: U -> Unitary
- data StateQ = StateQ {}
- initialStateQ :: StateQ
- pa :: Pure -> RR
- data Split = Split {}
- split :: Pure -> Qbit -> Split
- class Monad m => PMonad m where
- data Prob a = Prob {}
- evalWith :: PMonad m => QIO a -> State StateQ (m a)
- eval :: PMonad m => QIO a -> m a
- run :: QIO a -> IO a
- sim :: QIO a -> Prob a
Documentation
type Pure = VecEqL CC HeapMap Source #
A Pure state can be thought of as a vector of classical basis states, stored as Heaps, along with complex amplitudes.
updateP :: Pure -> Qbit -> Bool -> Pure Source #
The state of a qubit can be updated in a Pure state, by mapping the update operation over each Heap.
A Unitary can be thought of as an operation on a HeapMap that may produce a Pure state.
unitaryRot :: Rotation -> Bool Source #
A function that checks if a given Rotation is in face unitary. Note that this is currently a dummy stub function, and states that any rotation is unitary. (This is only o.k. at the moment as all the rotations defined in the QIO library are unitary, but won't catch un-unitary user-defined Rotations)
uMatrix :: Qbit -> (CC, CC, CC, CC) -> Unitary Source #
Given the four complex numbers that make up a 2-by-2 matrix, we can create a Unitary that applies the rotation to the given qubit.
uCond :: Qbit -> (Bool -> Unitary) -> Unitary Source #
A conditional operation can be defined as a Unitary
A quantum state is a defined as the next free qubit reference, along with the Pure state that represents the overall quantum state
initialStateQ :: StateQ Source #
The initial StateQ
A Split, is defined as a probability, along with the two Pure states.
split :: Pure -> Qbit -> Split Source #
Given a Pure state, we can create a Split, by essentially splitting the state into the part where the qubit is True, and the part where the qubit is False. This is how measurements are implemented in QIO.
class Monad m => PMonad m where Source #
We can extend a Monad into a PMonad if it defines a way of probabilistically merging two computations, based on a given probability.
The type Prob is defined as a wrapper around Vectors with Real probabilities.
Monad Prob Source # | Prob forms a Monad |
Functor Prob Source # | |
Applicative Prob Source # | |
PMonad Prob Source # | Prob is also a PMonad, where the result of both computations are combined into a probability distribution. |
Show a => Show (Prob a) Source # | We can show a probability distribution by filtering out elements with a zero probability. |
evalWith :: PMonad m => QIO a -> State StateQ (m a) Source #
Given a PMonad, a QIO Computation can be converted into a Stateful computation
over a quantum state (of type StateQ
).