The Quipper System

Algorithms.QLS.QSignedInt

Description

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

Synopsis

# 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.

Constructors

 SInt [x] x

Instances

 # Methods # Methods # Methods # Methods # Methods # Methods # Methods # Methods Show x => Show (SignedInt x) # MethodsshowsPrec :: Int -> SignedInt x -> ShowS #show :: SignedInt x -> String #showList :: [SignedInt x] -> ShowS # QCLeaf x => QCData (SignedInt x) # Methodsqcdata_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 # # Methods type QTypeB FSignedInt # type QCType x y (SignedInt z) # type QCType x y (SignedInt z) = SignedInt (QCType x y z)

The parameter type of signed integers.

The quantum type of signed integers.

The classical type of signed integers.

# Conversions for FSignedInt

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

Convert an FSignedInt to an integer.

Get the length of a SignedInt.

# Operations

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.

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

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

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

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

The modulo operation on QSignedInt.