Safe Haskell | None |
---|
A module implementing signed quantum integers. We piggy-back on
the type IntM
, considering it as a type of unsigned quantum
integers.
Synopsis
- data SignedInt x = SInt [x] x
- type FSignedInt = SignedInt Bool
- type QSignedInt = SignedInt Qubit
- type CSignedInt = SignedInt Bit
- fsint_of_integer :: Int -> Integer -> FSignedInt
- integer_of_fsint :: FSignedInt -> Integer
- sint_length :: SignedInt x -> Int
- left_pad_qulist :: [Qubit] -> [Qubit] -> Circ ([Qubit], [Qubit])
- fsint_shift :: Int -> FSignedInt -> FSignedInt
- s_qdint_of_qsint :: QSignedInt -> (Qubit, QDInt)
- qsint_of_s_qdint :: (Qubit, QDInt) -> QSignedInt
- qsint_shift :: Int -> QSignedInt -> Circ QSignedInt
- q_mod :: QSignedInt -> QSignedInt -> Circ QSignedInt
- my_test :: IO ()
Signed integer type
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 |
Instances
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.
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.
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
.