Safe Haskell | None |
---|
Algorithms.QLS.TemplateOracle
Description
This module contains an implementation of the oracle and its automatic lifting to quantum circuits using Template Haskell.
- local_any :: (a -> Bool) -> [a] -> Bool
- template_local_any :: Circ ((t -> Circ Qubit) -> Circ ([t] -> Circ Qubit))
- itoxy :: Int -> Int -> Int -> (Int, Int)
- template_itoxy :: Circ (QSignedInt -> Circ (QSignedInt -> Circ (QSignedInt -> Circ (QSignedInt, QSignedInt))))
- sinc :: Double -> Double
- template_sinc :: Circ (QDouble -> Circ QDouble)
- edgetoxy :: Int -> Int -> Int -> (Double, Double)
- template_edgetoxy :: Circ (SignedInt Qubit -> Circ (QSignedInt -> Circ (SignedInt Qubit -> Circ (QDouble, QDouble))))
- calcmatrixelement :: Int -> Int -> Int -> Int -> Double -> Double -> Double -> Complex Double
- template_calcmatrixelement :: Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (QDouble, QDouble))))))))
- get_edges :: [a] -> [(a, a)]
- template_get_edges :: Circ ([a] -> Circ [(a, a)])
- checkedge :: Int -> [(Double, Double)] -> Int -> Int -> Bool
- template_checkedge :: Circ (SignedInt Qubit -> Circ ([(QDouble, QDouble)] -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ Qubit))))
- calcRweights :: Int -> Int -> Int -> Double -> Double -> Double -> Double -> Double -> Complex Double
- template_calcRweights :: Circ (SignedInt Qubit -> Circ (QSignedInt -> Circ (QSignedInt -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (QDouble, QDouble)))))))))
- convertband :: Int -> Int -> Int -> Int -> Int
- template_convertband :: (Num t, Eq t) => Circ (QSignedInt -> Circ (t -> Circ (QSignedInt -> Circ (QSignedInt -> Circ QSignedInt))))
- getNodeValuesMoreOutputs :: Int -> Int -> Int -> Int -> [(Double, Double)] -> Double -> Double -> Double -> BoolParam -> Int -> (Int, Double)
- template_getNodeValuesMoreOutputs :: Circ (QSignedInt -> Circ (Int -> Circ (QSignedInt -> Circ (QSignedInt -> Circ ([(QDouble, QDouble)] -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (BoolParam -> Circ (Int -> Circ (QSignedInt, QDouble)))))))))))
- calcincidentfield :: Int -> Int -> Int -> Double -> Double -> Double -> Double -> Double -> Complex Double
- template_calcincidentfield :: Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (QDouble -> Circ (QDouble -> Circ (QDouble -> Circ (QDouble, QDouble)))))))))
- getconnection :: Int -> Int -> Int -> Int -> Int -> Int
- template_getconnection :: Circ (QSignedInt -> Circ (Int -> Circ (QSignedInt -> Circ (QSignedInt -> Circ (Int -> Circ QSignedInt)))))
- local_loop_with_index_aux :: Int -> Int -> t -> (Int -> t -> t) -> t
- template_local_loop_with_index_aux :: Circ (Int -> Circ (Int -> Circ (t -> Circ ((Int -> Circ (t -> Circ t)) -> Circ t))))
- local_loop_with_index :: Int -> t -> (Int -> t -> t) -> t
- template_local_loop_with_index :: Circ (Int -> Circ (y -> Circ ((Int -> Circ (y -> Circ y)) -> Circ y)))
- getKnownWeights :: Int -> Int -> Int -> [(Double, Double)] -> Double -> Double -> Double -> Double -> Double -> Int -> Complex Double
- template_getKnownWeights :: Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ ([(QDouble, QDouble)] -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (Int -> Circ (QDouble, QDouble)))))))))))
- test_template_sinc :: Circ ()
- test_template_itoxy :: Circ ()
- test_template_edgetoxy :: Circ ()
- test_template_calcRweights :: Circ ()
- test_template_calcincidentfield :: Circ ()
- test_template_calcmatrixelement :: Circ ()
- test_template_getconnection :: Circ ()
- test_template_checkedge :: Circ ()
Documentation
template_itoxy :: Circ (QSignedInt -> Circ (QSignedInt -> Circ (QSignedInt -> Circ (QSignedInt, QSignedInt)))) Source #
template_edgetoxy :: Circ (SignedInt Qubit -> Circ (QSignedInt -> Circ (SignedInt Qubit -> Circ (QDouble, QDouble)))) Source #
calcmatrixelement :: Int -> Int -> Int -> Int -> Double -> Double -> Double -> Complex Double Source #
Auxiliary function. The inputs are:
- y1 ::
Int
- Global edge index of row index of desired matrix element; - y2 ::
Int
- Global edge index of column index of desired matrix element; - nx ::
Int
- Number of vertices left to right; - ny ::
Int
- Number of vertices top to bottom; - lx ::
Double
- Length of horizontal edges (distance between vertices in x direction); - ly ::
Double
- Length of vertical edges (distance between vertices in y direction); - k ::
Double
- Plane wave wavenumber.
The output is the matrix element A(y1, y2).
template_calcmatrixelement :: Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (QDouble, QDouble)))))))) Source #
template_get_edges :: Circ ([a] -> Circ [(a, a)]) Source #
template_checkedge :: Circ (SignedInt Qubit -> Circ ([(QDouble, QDouble)] -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ Qubit)))) Source #
calcRweights :: Int -> Int -> Int -> Double -> Double -> Double -> Double -> Double -> Complex Double Source #
Oracle r.
template_calcRweights :: Circ (SignedInt Qubit -> Circ (QSignedInt -> Circ (QSignedInt -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (QDouble, QDouble))))))))) Source #
template_convertband :: (Num t, Eq t) => Circ (QSignedInt -> Circ (t -> Circ (QSignedInt -> Circ (QSignedInt -> Circ QSignedInt)))) Source #
getNodeValuesMoreOutputs :: Int -> Int -> Int -> Int -> [(Double, Double)] -> Double -> Double -> Double -> BoolParam -> Int -> (Int, Double) Source #
Oracle A. It is equivalent to the Matlab function
getBandNodeValues
.
'getNodeValuesMoreOutputs v b ...' outputs the node of the edge
connected to vertex v in band b, and a real number parameterized by
the BoolParam
parameter: the magnitude (PFalse) or the phase
(PTrue) of the complex value at the corresponding place in the matrix A.
template_getNodeValuesMoreOutputs :: Circ (QSignedInt -> Circ (Int -> Circ (QSignedInt -> Circ (QSignedInt -> Circ ([(QDouble, QDouble)] -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (BoolParam -> Circ (Int -> Circ (QSignedInt, QDouble))))))))))) Source #
calcincidentfield :: Int -> Int -> Int -> Double -> Double -> Double -> Double -> Double -> Complex Double Source #
Auxiliary function for oracle b. The inputs are:
- y ::
Int
- Global edge index. Note this is the unmarked y coordinate, i.e. the coordinate without scattering regions removed; - nx ::
Int
- Number of vertices left to right; - ny ::
Int
- Number of vertices top to bottom; - lx ::
Double
- Length of horizontal edges (distance between vertices in x direction); - ly ::
Double
- Length of vertical edges (distance between vertices in y direction); - k ::
Double
- Plane wave wavenumber; - θ ::
Double
- Direction of wave propagation; - E0 ::
Double
- Magnitude of incident plane wave.
The output is the magnitude of the electric field on edge y.
template_calcincidentfield :: Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (QDouble -> Circ (QDouble -> Circ (QDouble -> Circ (QDouble, QDouble))))))))) Source #
template_getconnection :: Circ (QSignedInt -> Circ (Int -> Circ (QSignedInt -> Circ (QSignedInt -> Circ (Int -> Circ QSignedInt))))) Source #
local_loop_with_index_aux :: Int -> Int -> t -> (Int -> t -> t) -> t Source #
Auxiliary function to
.template_paramZero
template_local_loop_with_index_aux :: Circ (Int -> Circ (Int -> Circ (t -> Circ ((Int -> Circ (t -> Circ t)) -> Circ t)))) Source #
local_loop_with_index :: Int -> t -> (Int -> t -> t) -> t Source #
Local version of
, for lifting.loop_with_index
template_local_loop_with_index :: Circ (Int -> Circ (y -> Circ ((Int -> Circ (y -> Circ y)) -> Circ y))) Source #
getKnownWeights :: Int -> Int -> Int -> [(Double, Double)] -> Double -> Double -> Double -> Double -> Double -> Int -> Complex Double Source #
Oracle b.
template_getKnownWeights :: Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ (SignedInt Qubit -> Circ ([(QDouble, QDouble)] -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (XDouble Qubit -> Circ (Int -> Circ (QDouble, QDouble))))))))))) Source #
test_template_sinc :: Circ () Source #
test_template_itoxy :: Circ () Source #
test_template_edgetoxy :: Circ () Source #
test_template_checkedge :: Circ () Source #