Safe Haskell | None |
---|---|
Language | Haskell98 |
This module contains the interface between the simplified circuit model and Quipper's internal circuit model. The main useful exported functions are:
, which optimizes a classical circuit such as those coming from Template Haskell;simplify_classical
, which provides a mechanism equivalent toclassical_to_reversible_optim
, but with optimization inlined.classical_to_reversible
Synopsis
- getListWire :: QData qc => qc -> [Wire]
- quipperGateToMyGate :: (IntSet, IntMap Wire, Wire) -> Gate -> ((IntSet, IntMap Wire, Wire), Maybe Gate)
- quipperGateInitW :: Gate -> Maybe Wire
- quipperGateFreshWire :: Wire -> [Gate] -> Wire
- quipperCircuitToMyCirc :: Circuit -> CircState
- quipperBCircuitToMyCirc :: BCircuit -> CircState
- myCircErrMsg :: String -> String
- quipperFunToMyCirc :: (QData x, QData y) => (x -> Circ y) -> x -> (CircState, [Wire])
- myGateToQuipperGate :: Gate -> Gate
- makeComment :: String -> String -> [Wire] -> Gate
- quipperBCircuitSimpl :: BCircuit -> [Wire] -> (BCircuit, [Wire])
- simplify_classical' :: (QData x, QData y) => (x -> Circ y) -> x -> (BCircuit, [Wire])
- simplify_classical :: (QData x, QData y) => (x -> Circ y) -> x -> Circ y
- classical_to_reversible_optim :: (QData qa, QData qb) => (qa -> Circ qb) -> (qa, qb) -> Circ (qa, qb)
- box_classical_to_reversible_optim :: (QData qa, QData qb) => String -> (qa -> Circ qb) -> (qa, qb) -> Circ (qa, qb)
Auxiliary functions
getListWire :: QData qc => qc -> [Wire] Source #
Extract the list of wires from a piece of quantum data.
Quipper circuits to simple circuits
quipperGateToMyGate :: (IntSet, IntMap Wire, Wire) -> Gate -> ((IntSet, IntMap Wire, Wire), Maybe Gate) Source #
Translates a Quipper circuit to a simple circuit. The only gates considered are initializations, terminations, and multi-controlled NOT gates. All other gates are ignored.
Note that simple circuits do not possess termination wires: these wires are simply not terminated, and all subsequent initializations using the same wire ID are sent to fresh wires.
The state of this function is a bit complex, as it keeps track of where the output wires are mapped to.
quipperGateInitW :: Gate -> Maybe Wire Source #
Get the wire initialized by the gate, if it is an initialization gate.
quipperGateFreshWire :: Wire -> [Gate] -> Wire Source #
Given a list of Quipper gates, get the smallest wire id not in use.
myCircErrMsg :: String -> String Source #
Generate a custom error message.
quipperFunToMyCirc :: (QData x, QData y) => (x -> Circ y) -> x -> (CircState, [Wire]) Source #
Given a Quipper circuit generating function and a shape argument, return a simple circuit together with the list of non-garbage circuit outputs.
Simple circuits to Quipper circuits
myGateToQuipperGate :: Gate -> Gate Source #
Translate a gate from the simple circuit model into a Quipper gate.
makeComment :: String -> String -> [Wire] -> Gate Source #
Generate a Quipper comment. The first argument is a comment string, and the second argument is a label to apply to the qubits in the third argument.
Algebraic optimization of Quipper circuits
quipperBCircuitSimpl :: BCircuit -> [Wire] -> (BCircuit, [Wire]) Source #
Optimize a Quipper BCircuit
. The second argument is the list
of non-garbage outputs. A corresponding list of outputs is also
returned along with the circuit.
simplify_classical' :: (QData x, QData y) => (x -> Circ y) -> x -> (BCircuit, [Wire]) Source #
Optimize a Quipper circuit producing function (together with a
shape argument). Return the optimized circuit as a Quipper
BCircuit
, along with a list of the non-garbage circuit outputs.
simplify_classical :: (QData x, QData y) => (x -> Circ y) -> x -> Circ y Source #
Optimize a Quipper circuit-producing function. This assumes that the function only consists of pseudo-classical quantum gates, i.e., initializations, terminations, and (possibly multiply controlled) NOT gates. The behavior on other kinds of circuits is undefined. The second argument is a shape parameter.
classical_to_reversible_optim :: (QData qa, QData qb) => (qa -> Circ qb) -> (qa, qb) -> Circ (qa, qb) Source #
Like classical_to_reversible
, but also apply circuit optimization.
box_classical_to_reversible_optim :: (QData qa, QData qb) => String -> (qa -> Circ qb) -> (qa, qb) -> Circ (qa, qb) Source #
Like classical_to_reversible_optim
, but insert the optimized
circuit as a boxed subroutine.