The Quipper System

Safe HaskellNone

Quipper.Libraries.ClassicalOptim.QuickCheckArith

Description

This module contains small examples of arithmetic functions, coded in Template Haskell, for use with Quipper.Libraries.ClassicalOptim.QuickCheck.

Synopsis

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_zip :: Circ ([a] -> Circ ([b] -> Circ [(a, b)])) Source #

Template Haskell version of zip .

template_tail :: Circ ([a] -> Circ [a]) Source #

Template Haskell version of tail .

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

majority :: Bool -> Bool -> Bool -> Bool Source #

Return the majority of three booleans.

template_majority :: Circ (Qubit -> Circ (Qubit -> Circ (Qubit -> Circ Qubit))) Source #

bit_adder :: Bool -> (Bool, Bool, Bool) -> (Bool, Bool) Source #

Bit adder. The first input is False for adding, and True for subtracting. The second input is a triple consisting of a carry, and two bits to be added. The output consists of the new carry and the sum.

template_bit_adder :: Circ (Qubit -> Circ ((Qubit, Qubit, Qubit) -> Circ (Qubit, Qubit))) Source #

adder :: [Bool] -> [Bool] -> [Bool] Source #

Multi-bit adder. Add two n-bit integers, represented as little-tailian bit lists.

template_adder :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit])) Source #

test_adder' :: Property Source #

Test the validity of the functional implementation of adder .

test_adder :: IO () Source #

Wrapper around test_adder' .

Subtraction

subtract :: [Bool] -> [Bool] -> [Bool] Source #

Reversible subtraction.

template_subtract :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit])) Source #

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.

template_pad_right :: Circ ([a] -> Circ ([a] -> Circ [a])) Source #

shift :: [Bool] -> [Bool] Source #

Shift a bit list to the right by one.

template_shift :: Circ ([Qubit] -> Circ [Qubit]) Source #

takeOnly :: [Bool] -> [Bool] -> [Bool] Source #

takeOnly shape l: take the first (length shape) elements out of l.

template_takeOnly :: Circ ([a1] -> Circ ([a2] -> Circ [a2])) Source #

multiplier' :: [Bool] -> [Bool] -> [Bool] Source #

Reversible multiplier stripping high bits.

template_multipliersymb_quote_ :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit])) Source #

multiplier :: [Bool] -> [Bool] -> [Bool] Source #

Reversible multiplier keeping high bits.

template_multiplier :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit])) Source #

test_multiplier' :: Property Source #

Test the validity of the functional implementation of multiplier .

test_multiplier :: IO Result Source #

Wrapper around test_multiplier' .

AltStyle によって変換されたページ (->オリジナル) /