Safe Haskell | None |
---|
This module contains small examples of arithmetic functions, coded in Template Haskell, for use with Quipper.Libraries.ClassicalOptim.QuickCheck.
Synopsis
- int_of_boollist :: [Bool] -> Integer
- boollist_of_int :: Int -> Integer -> [Bool]
- template_map :: Circ ((a -> Circ a) -> Circ ([a] -> Circ [a]))
- template_zip :: Circ ([a] -> Circ ([b] -> Circ [(a, b)]))
- template_tail :: Circ ([a] -> Circ [a])
- template_symb_obracket_symb_cbracket_ :: Circ [a]
- mapAccumLM :: (acc -> x -> Circ (acc, y)) -> acc -> [x] -> Circ (acc, [y])
- template_mapAccumL :: Circ ((acc -> Circ (x -> Circ (acc, y))) -> Circ (acc -> Circ ([x] -> Circ (acc, [y]))))
- majority :: Bool -> Bool -> Bool -> Bool
- template_majority :: Circ (Qubit -> Circ (Qubit -> Circ (Qubit -> Circ Qubit)))
- bit_adder :: Bool -> (Bool, Bool, Bool) -> (Bool, Bool)
- template_bit_adder :: Circ (Qubit -> Circ ((Qubit, Qubit, Qubit) -> Circ (Qubit, Qubit)))
- adder :: [Bool] -> [Bool] -> [Bool]
- template_adder :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit]))
- test_adder' :: Property
- test_adder :: IO ()
- subtract :: [Bool] -> [Bool] -> [Bool]
- template_subtract :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit]))
- test_subtract' :: Property
- test_subtract :: IO ()
- pad_right :: [Bool] -> [Bool] -> [Bool]
- template_pad_right :: Circ ([a] -> Circ ([a] -> Circ [a]))
- shift :: [Bool] -> [Bool]
- template_shift :: Circ ([Qubit] -> Circ [Qubit])
- takeOnly :: [Bool] -> [Bool] -> [Bool]
- template_takeOnly :: Circ ([a1] -> Circ ([a2] -> Circ [a2]))
- multiplier' :: [Bool] -> [Bool] -> [Bool]
- template_multipliersymb_quote_ :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit]))
- multiplier :: [Bool] -> [Bool] -> [Bool]
- template_multiplier :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit]))
- test_multiplier' :: Property
- test_multiplier :: IO Result
Binary representation of integers
int_of_boollist :: [Bool] -> Integer Source #
Compute an unsigned integer from its binary representation. The input is a big-headian list of booleans. This means that the head of the list is the most significant digit.
boollist_of_int :: Int -> Integer -> [Bool] Source #
Compute the binary representation of an unsigned integer, using the given number of digits. The output is the binary representation as a big-headian list of booleans.
Circuit templates for common functions
template_map :: Circ ((a -> Circ a) -> Circ ([a] -> Circ [a])) Source #
Template Haskell version of map
.
template_symb_obracket_symb_cbracket_ :: Circ [a] Source #
Template Haskell version of []
.
mapAccumLM :: (acc -> x -> Circ (acc, y)) -> acc -> [x] -> Circ (acc, [y]) Source #
Monadic version of mapAccumL
.
template_mapAccumL :: Circ ((acc -> Circ (x -> Circ (acc, y))) -> Circ (acc -> Circ ([x] -> Circ (acc, [y])))) Source #
Template Haskell version of mapAccumL
.
Tests
Addition
adder :: [Bool] -> [Bool] -> [Bool] Source #
Multi-bit adder. Add two n-bit integers, represented as little-tailian bit lists.
test_adder' :: Property Source #
Test the validity of the functional implementation of adder
.
test_adder :: IO () Source #
Wrapper around test_adder'
.
Subtraction
test_subtract' :: Property Source #
Test the validity of the functional implementation of subtract
.
test_subtract :: IO () Source #
Wrapper around test_subtract'
.
Multiplication
pad_right :: [Bool] -> [Bool] -> [Bool] Source #
Pad the second list on the right, to the length of (and using the corresponding elements of) the first list.
test_multiplier' :: Property Source #
Test the validity of the functional implementation of multiplier
.
test_multiplier :: IO Result Source #
Wrapper around test_multiplier'
.