The Quipper System

Safe HaskellNone




A module implementing signed quantum integers. We piggy-back on the type IntM, considering it as a type of unsigned quantum integers.


Signed integer type

data SignedInt x Source #

Data type for signed integers. Note that this particular variant does not use two's complement to represent negative numbers, but an explicit sign bit. In particular, there are two different representations of 0 (however, the arithmetic operations always produce +0).

This is the generic type, where x represents a bit. An integer is represented as Sint digits sign, where digits is a big-headian list of digits (i.e., the most significant bit occupies the head of the list), and sign is the sign, with False representing plus and True representing minus.

When we speak of the "length" of a SignedInt, we mean the number of digits excluding the sign.


SInt [x] x 


Enum FSignedInt # 
Eq FSignedInt # 
Integral FSignedInt # 
Num FSignedInt # 
Ord FSignedInt # 
Real FSignedInt # 
QOrd QSignedInt # 
QNum QSignedInt # 
Show x => Show (SignedInt x) # 
QCLeaf x => QCData (SignedInt x) # 


qcdata_mapM :: Monad m => SignedInt x -> (q -> m q') -> (c -> m c') -> QCType q c (SignedInt x) -> m (QCType q' c' (SignedInt x)) Source #

qcdata_zip :: SignedInt x -> q -> c -> q' -> c' -> QCType q c (SignedInt x) -> QCType q' c' (SignedInt x) -> ErrMsg -> QCType (q, q') (c, c') (SignedInt x) Source #

qcdata_promote :: BType (SignedInt x) -> SignedInt x -> ErrMsg -> BType (SignedInt x) Source #

QCLeaf x => Labelable (SignedInt x) String # 
type QTypeB FSignedInt # 
type QCType x y (SignedInt z) # 
type QCType x y (SignedInt z) = SignedInt (QCType x y z)

type FSignedInt = SignedInt Bool Source #

The parameter type of signed integers.

type QSignedInt = SignedInt Qubit Source #

The quantum type of signed integers.

type CSignedInt = SignedInt Bit Source #

The classical type of signed integers.

Conversions for FSignedInt

fsint_of_integer :: Int -> Integer -> FSignedInt Source #

Take a length and an integer, and return a FSignedInt of the given length.

integer_of_fsint :: FSignedInt -> Integer Source #

Convert an FSignedInt to an integer.

sint_length :: SignedInt x -> Int Source #

Get the length of a SignedInt.


left_pad_qulist :: [Qubit] -> [Qubit] -> Circ ([Qubit], [Qubit]) Source #

Make two qubit lists be of the same length, by prepending qubits initialized to False to the head of the shorter of the two lists.

fsint_shift :: Int -> FSignedInt -> FSignedInt Source #

Shift an FSignedInt by k digits to the left. In other words, multiply it by 2k, while simultaneously increasing the length by k.

s_qdint_of_qsint :: QSignedInt -> (Qubit, QDInt) Source #

One half of an isomorphism between QSignedInt and (Qubit, QDInt).

qsint_of_s_qdint :: (Qubit, QDInt) -> QSignedInt Source #

The other half of an isomorphism between QSignedInt and (Qubit, QDInt).

qsint_shift :: Int -> QSignedInt -> Circ QSignedInt Source #

Shift a QSignedInt by k digits to the left. In other words, multiply it by 2k, while simultaneously increasing the length by k.

q_mod :: QSignedInt -> QSignedInt -> Circ QSignedInt Source #

The modulo operation on QSignedInt.