| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Quil.Execute
Contents
Description
Executing Quil programs.
This example makes measurements on a prepared state.
>>> import Language.Quil.Execute >>> import Language.Quil.Types -- Run a simple program and examine the quantum and classical states.. >>> let program = [H 0, CNOT 0 1, RX (Expression . Number $ pi/4) 1] >>> runProgramWithStdRandom 2 [BoolBit False] program Quantum state: 0.6532814824381882|00> + -0.27059805007309845i|01> + -0.27059805007309845i|10> + 0.6532814824381882|11> @ [1,0] Classical state: 0x0 [1] Program counter: 3 Halted? False -- Add measurement to the program and re-run it. >>> let program' = program ++ [MEASURE 0 (Just 0)] >>> runProgramWithStdRandom 2 [BoolBit False] program' Quantum state: 0.9238795325112867|00> + -0.3826834323650897i|10> @ [1,0] Classical state: 0x0 [1] Program counter: 4 Halted? False -- Run the program again. >>> runProgramWithStdRandom 2 [BoolBit False] program' Quantum state: -0.3826834323650897i|01> + 0.9238795325112867|11> @ [1,0] Classical state: 0x1 [1] Program counter: 4 Halted? False
- runProgram :: RandomGen g => Int -> [BitData] -> [Instruction] -> Rand g Machine
- runProgramWithStdGen :: StdGen -> Int -> [BitData] -> [Instruction] -> Machine
- runProgramWithStdRandom :: Int -> [BitData] -> [Instruction] -> IO Machine
- executeInstructions :: RandomGen g => [Instruction] -> Machine -> Rand g Machine
- executeInstruction :: RandomGen g => Instruction -> Machine -> Rand g Machine
- compileGate :: Parameters -> [Expression] -> [QBit] -> Arguments -> Operator
- compileExpression :: Parameters -> Expression -> Arguments -> Number
Execution
Arguments
| :: RandomGen g | |
| => Int | The number of qubits. |
| -> [BitData] | The classical bits. |
| -> [Instruction] | The instructions. |
| -> Rand g Machine | Action for the resulting state of the machine. |
Run a program, starting from the ground state and using the global random number generator.
Arguments
| :: StdGen | The random number generator. |
| -> Int | The number of qubits. |
| -> [BitData] | The classical bits. |
| -> [Instruction] | The instructions. |
| -> Machine | The resulting state of the machine. |
Create an action to run a program, starting from the ground state.
runProgramWithStdRandom Source #
Arguments
| :: Int | The number of qubits. |
| -> [BitData] | The classical bits. |
| -> [Instruction] | The instructions. |
| -> IO Machine | Action for the resulting state of the machine. |
Run a program, starting from the ground state and using a particular random-number generator.
Arguments
| :: RandomGen g | |
| => [Instruction] | The instructions. |
| -> Machine | The state of the machine. |
| -> Rand g Machine | Action for the resulting state of the machine. |
Execute a series of instructions.
Arguments
| :: RandomGen g | |
| => Instruction | The instruction. |
| -> Machine | The state of the machine. |
| -> Rand g Machine | Action for the resulting state of the machine. |
Execute an instruction.
Compilation
Arguments
| :: Parameters | The formal parameters. |
| -> [Expression] | The expressions for the matrix elements. |
| -> [QBit] | Which qubits to operate on. |
| -> Arguments | The argument. |
| -> Operator | The resulting operator. |
Compile a gate.
Arguments
| :: Parameters | The formal parameters. |
| -> Expression | The expression. |
| -> Arguments | The arguments. |
| -> Number | The result. |
Compile an expression.