lol-0.4.0.0: A library for lattice cryptography.

Crypto.Lol.Prelude

Description

$$\def\Z{\mathbb{Z}}$$ $$\def\C{\mathbb{C}}$$

A substitute for the Prelude that is more suitable for Lol. This module exports most of the Numeric Prelude and other frequently used modules, plus some low-level classes, missing instances, and assorted utility functions.

Synopsis

# Classes and families

class Enumerable a where Source #

Poor man's Enum.

Minimal complete definition

values

Methods

values :: [a] Source #

Instances

 GFCtx k fp d => Enumerable (GF k fp d) Source # Methodsvalues :: [GF k fp d] Source # (Reflects k q z, ToInteger z, Enum z) => Enumerable (ZqBasic k q z) Source # Methodsvalues :: [ZqBasic k q z] Source #

class (ToInteger (ModRep a), Additive a) => Mod a where Source #

Represents a quotient group modulo some integer.

Minimal complete definition

modulus

Associated Types

type ModRep a Source #

Methods

modulus :: Tagged a (ModRep a) Source #

Instances

 (Mod a, Mod b) => Mod (a, b) Source # Product ring of $$\Z_q$$s as a $$\Z_q$$ (with Integer modulus) Associated Typestype ModRep (a, b) :: * Source # Methodsmodulus :: Tagged * (a, b) (ModRep (a, b)) Source # (Reflects k q z, ToInteger z) => Mod (ZqBasic k q z) Source # Associated Typestype ModRep (ZqBasic k q z) :: * Source # Methodsmodulus :: Tagged * (ZqBasic k q z) (ModRep (ZqBasic k q z)) Source #

class (Additive a, Additive b) => Subgroup a b where Source #

Represents that a is a subgroup of b.

Minimal complete definition

fromSubgroup

Methods

fromSubgroup :: a -> b Source #

Instances

 (ToInteger i, RealField r, Reflects k q i, Reflects k q r) => Subgroup (ZqBasic k q i) (RRq k q r) Source # MethodsfromSubgroup :: ZqBasic k q i -> RRq k q r Source #

class (Additive a, Additive b) => Reduce a b where Source #

Represents that b is a quotient group of a.

Minimal complete definition

reduce

Methods

reduce :: a -> b Source #

Instances

 (Reduce a b1, Reduce a b2) => Reduce a (b1, b2) Source # Reduce into product ring. Methodsreduce :: a -> (b1, b2) Source # (Reflects k q z, ToInteger z, Additive (ZqBasic k q z)) => Reduce Integer (ZqBasic k q z) Source # Methodsreduce :: Integer -> ZqBasic k q z Source # (Reflects k q z, ToInteger z) => Reduce z (ZqBasic k q z) Source # Methodsreduce :: z -> ZqBasic k q z Source # (Reflects k q r, RealField r, Additive (RRq k q r)) => Reduce r (RRq k q r) Source # Methodsreduce :: r -> RRq k q r Source # (Reduce a b, Fact m, CElt t a, CElt t b) => Reduce (Cyc t m a) (Cyc t m b) Source # Methodsreduce :: Cyc t m a -> Cyc t m b Source # (Reduce a b, Tensor t, Fact m, TElt t a, TElt t b) => Reduce (UCyc t m D a) (UCyc t m D b) Source # Methodsreduce :: UCyc t m D a -> UCyc t m D b Source # (Reduce a b, Tensor t, Fact m, TElt t a, TElt t b) => Reduce (UCyc t m P a) (UCyc t m P b) Source # Methodsreduce :: UCyc t m P a -> UCyc t m P b Source # (Reduce z zq, Fact s, CElt t z, CElt t zq) => Reduce (Linear t z e r s) (Linear t zq e r s) Source # Methodsreduce :: Linear t z e r s -> Linear t zq e r s Source #

type family LiftOf b Source #

The type of representatives of b.

Instances

 type LiftOf (a, b) Source # type LiftOf (a, b) = Integer type LiftOf (ZqBasic k q z) Source # type LiftOf (ZqBasic k q z) = z type LiftOf (RRq k q r) Source # type LiftOf (RRq k q r) = r type LiftOf (Cyc t m r) Source # type LiftOf (Cyc t m r) = Cyc t m (LiftOf r) type LiftOf (UCyc t m D r) Source # type LiftOf (UCyc t m D r) = UCyc t m D (LiftOf r) type LiftOf (UCyc t m P r) Source # type LiftOf (UCyc t m P r) = UCyc t m P (LiftOf r) type LiftOf (Linear t zp e r s) Source # type LiftOf (Linear t zp e r s) = Linear t (LiftOf zp) e r s

type Lift b a = (Lift' b, LiftOf b ~ a) Source #

Represents that b can be lifted to a "short" a congruent to b.

class Reduce (LiftOf b) b => Lift' b where Source #

Fun-dep version of Lift.

Minimal complete definition

lift

Methods

lift :: b -> LiftOf b Source #

Instances

 (Mod a, Mod b, Lift' a, Lift' b, Reduce Integer (a, b), ToInteger (LiftOf a), ToInteger (LiftOf b)) => Lift' (a, b) Source # Lift product ring of $$\Z_q$$s to Integer Methodslift :: (a, b) -> LiftOf (a, b) Source # (Reflects k q z, ToInteger z) => Lift' (ZqBasic k q z) Source # Methodslift :: ZqBasic k q z -> LiftOf (ZqBasic k q z) Source # (Reflects k q r, Reduce r (RRq k q r), Ord r, Ring r) => Lift' (RRq k q r) Source # Methodslift :: RRq k q r -> LiftOf (RRq k q r) Source # (Lift' r, Tensor t, Fact m, TElt t r, TElt t (LiftOf r)) => Lift' (UCyc t m D r) Source # Methodslift :: UCyc t m D r -> LiftOf (UCyc t m D r) Source # (Lift' r, Tensor t, Fact m, TElt t r, TElt t (LiftOf r)) => Lift' (UCyc t m P r) Source # Methodslift :: UCyc t m P r -> LiftOf (UCyc t m P r) Source # (CElt t zp, CElt t z, (~) * z (LiftOf zp), Lift zp z, Fact s) => Lift' (Linear t zp e r s) Source # lifts with respect to powerful basis, for best geometry Methodslift :: Linear t zp e r s -> LiftOf (Linear t zp e r s) Source #

class (Additive a, Additive b) => Rescale a b where Source #

Represents that a can be rescaled to b, as an "approximate" additive homomorphism.

Minimal complete definition

rescale

Methods

rescale :: a -> b Source #

Instances

 (Ring b, Mod a, Reduce (ModRep a) b) => Rescale b (a, b) Source # Rescale up to a product ring of $$\Z_q$$s Methodsrescale :: b -> (a, b) Source # (Ring a, Mod b, Reduce (ModRep b) a) => Rescale a (a, b) Source # Rescale up to a product ring of $$\Z_q$$s Methodsrescale :: a -> (a, b) Source # (Rescale ((a, b), c) (a, b), Rescale (a, b) a, Additive a, Additive c) => Rescale ((a, b), c) a Source # Rescale a (multi-)product ring of $$\Z_q$$s Methodsrescale :: ((a, b), c) -> a Source # (Rescale (a, (b, c)) (b, c), Rescale (b, c) c, Additive a, Additive c) => Rescale (a, (b, c)) c Source # Rescale a (multi-)product ring of $$\Z_q$$s Methodsrescale :: (a, (b, c)) -> c Source # (Mod b, Field a, Lift b (ModRep b), Reduce (LiftOf b) a) => Rescale (a, b) a Source # Rescale a product ring of $$\Z_q$$s Methodsrescale :: (a, b) -> a Source # (Mod a, Field b, Lift a (ModRep a), Reduce (LiftOf a) b) => Rescale (a, b) b Source # Rescale a product ring of $$\Z_q$$s Methodsrescale :: (a, b) -> b Source # (Reflects k q z, ToInteger z, Reflects k1 q' z, Ring z) => Rescale (ZqBasic k q z) (ZqBasic k1 q' z) Source # Methodsrescale :: ZqBasic k q z -> ZqBasic k1 q' z Source # (Rescale a b, Tensor t, Fact m, TElt t a, TElt t b) => Rescale (UCyc t m D a) (UCyc t m D b) Source # Methodsrescale :: UCyc t m D a -> UCyc t m D b Source # (Rescale a b, Tensor t, Fact m, TElt t a, TElt t b) => Rescale (UCyc t m P a) (UCyc t m P b) Source # Methodsrescale :: UCyc t m P a -> UCyc t m P b Source #

class (Field src, Field tgt) => Encode src tgt where Source #

Represents that the target ring can "noisily encode" values from the source ring, in either "most significant digit" (MSD) or "least significant digit" (LSD) encodings, and provides conversion factors between the two types of encodings.

Minimal complete definition

lsdToMSD

Methods

lsdToMSD :: (src, tgt) Source #

The factor that converts an element from LSD to MSD encoding in the target field, with associated scale factor to apply to correct the resulting encoded value.

Instances

 (Encode s t1, Encode s t2, Field (t1, t2)) => Encode s (t1, t2) Source # Encode for a product ring MethodslsdToMSD :: (s, (t1, t2)) Source # (Reflects k p z, Reflects k1 q z, ToInteger z, Field (ZqBasic k1 q z), Field (ZqBasic k p z)) => Encode (ZqBasic k p z) (ZqBasic k1 q z) Source # MethodslsdToMSD :: (ZqBasic k p z, ZqBasic k1 q z) Source #

msdToLSD :: Encode src tgt => (src, tgt) Source #

Inverted entries of lsdToMSD.

type family CharOf fp :: k Source #

The characteristic of a ring, represented as a type.

Instances

 type CharOf k (ZqBasic k p z) Source # type CharOf k (ZqBasic k p z) = p

# Numeric

max :: Ord a => a -> a -> a Source #

The Prelude definition of max.

min :: Ord a => a -> a -> a Source #

The Prelude definition of min.

abs :: Absolute a => a -> a Source #

The sane definition of abs from Numeric rather than the default from NumericPrelude.

realToField :: (Field b, ToRational a) => a -> b Source #

The hidden NP function from Algebra.ToRational.

type ZeroTestable a = C a Source #

Sane synonym for C.

type Additive a = C a Source #

Sane synonym for C.

type Ring a = C a Source #

Sane synonym for C.

type Module a v = C a v Source #

Sane synonym for C.

type IntegralDomain a = C a Source #

Sane synonym for C.

type ToRational a = C a Source #

Sane synonym for C.

type Field a = C a Source #

Sane synonym for C.

type RealRing a = C a Source #

Sane synonym for C.

type RealField a = C a Source #

Sane synonym for C.

type Algebraic a = C a Source #

Sane synonym for C.

type Transcendental a = C a Source #

Sane synonym for C.

type RealTranscendental a = C a Source #

Sane synonym for C.

type OrdFloat a = (Ord a, Transcendental a) Source #

Convenient synonym for (Ord a, Transcendental a)

type ToInteger a = C a Source #

Sane synonym for C.

type Absolute a = C a Source #

Sane synonym for C.

type RealIntegral a = C a Source #

Sane synonym for C.

type PID a = C a Source #

Sane synonym for C.

type Polynomial a = T a Source #

Sane synonym for T.

type Matrix a = T a Source #

Sane synonym for T.

(^) :: forall a i. (Ring a, ToInteger i) => a -> i -> a Source #

Our custom exponentiation, overriding NP's version that requires Integer exponent. Copied from http://hackage.haskell.org/package/base-4.7.0.0/docs/src/GHC-Real.html#%5E

modinv :: (PID i, Eq i) => i -> i -> Maybe i Source #

Inverse of $$a$$ modulo $$q$$, in range $$[0,q-1]$$. (Argument order is infix-friendly.)

decomp :: (IntegralDomain z, Ord z) => [z] -> z -> [z] Source #

Decompose an element into a list of "centered" digits with respect to relative radices.

roundMult :: (RealField r, ToInteger i) => i -> r -> i Source #

Deterministically round to the nearest multiple of $$i$$.

roundScalarCentered :: (RealField r, Random r, ToInteger i, MonadRandom mon) => i -> r -> mon i Source #

Randomly round to the nearest larger or smaller multiple of $$i$$, where the round-off term has expectation zero.

Arguments

 :: IntegralDomain i => i dividend $$a$$ -> i divisor $$b$$ -> (i, i) (quotient, remainder)

Variant of divMod in which the remainder is in the range $$[-b/2,b/2)$$.

data Int64 :: * #

64-bit signed integer type

Instances

 Methods Methodssucc :: Int64 -> Int64 #pred :: Int64 -> Int64 #toEnum :: Int -> Int64 #enumFrom :: Int64 -> [Int64] #enumFromThen :: Int64 -> Int64 -> [Int64] #enumFromTo :: Int64 -> Int64 -> [Int64] #enumFromThenTo :: Int64 -> Int64 -> Int64 -> [Int64] # Methods(==) :: Int64 -> Int64 -> Bool #(/=) :: Int64 -> Int64 -> Bool # Methodsquot :: Int64 -> Int64 -> Int64 #rem :: Int64 -> Int64 -> Int64 #div :: Int64 -> Int64 -> Int64 #mod :: Int64 -> Int64 -> Int64 #quotRem :: Int64 -> Int64 -> (Int64, Int64) #divMod :: Int64 -> Int64 -> (Int64, Int64) # Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int64 -> c Int64 #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int64 #dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Int64) #dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int64) #gmapT :: (forall b. Data b => b -> b) -> Int64 -> Int64 #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r #gmapQ :: (forall d. Data d => d -> u) -> Int64 -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Int64 -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 # Methods(+) :: Int64 -> Int64 -> Int64 #(-) :: Int64 -> Int64 -> Int64 #(*) :: Int64 -> Int64 -> Int64 #abs :: Int64 -> Int64 # Methods(<) :: Int64 -> Int64 -> Bool #(<=) :: Int64 -> Int64 -> Bool #(>) :: Int64 -> Int64 -> Bool #(>=) :: Int64 -> Int64 -> Bool #max :: Int64 -> Int64 -> Int64 #min :: Int64 -> Int64 -> Int64 # Methods Methods MethodsshowsPrec :: Int -> Int64 -> ShowS #show :: Int64 -> String #showList :: [Int64] -> ShowS # Methodsrange :: (Int64, Int64) -> [Int64] #index :: (Int64, Int64) -> Int64 -> Int #unsafeIndex :: (Int64, Int64) -> Int64 -> IntinRange :: (Int64, Int64) -> Int64 -> Bool #rangeSize :: (Int64, Int64) -> Int #unsafeRangeSize :: (Int64, Int64) -> Int Methodslift :: Int64 -> Q Exp # MethodsrandomR :: RandomGen g => (Int64, Int64) -> g -> (Int64, g) #random :: RandomGen g => g -> (Int64, g) #randomRs :: RandomGen g => (Int64, Int64) -> g -> [Int64] #randoms :: RandomGen g => g -> [Int64] #randomRIO :: (Int64, Int64) -> IO Int64 # Methodsshrink :: Int64 -> [Int64] # Methodscoarbitrary :: Int64 -> Gen b -> Gen b # MethodssizeOf :: Int64 -> Int #pokeElemOff :: Ptr Int64 -> Int -> Int64 -> IO () #peekByteOff :: Ptr b -> Int -> IO Int64 #pokeByteOff :: Ptr b -> Int -> Int64 -> IO () #poke :: Ptr Int64 -> Int64 -> IO () # Methods(.&.) :: Int64 -> Int64 -> Int64 #(.|.) :: Int64 -> Int64 -> Int64 #xor :: Int64 -> Int64 -> Int64 #shift :: Int64 -> Int -> Int64 #rotate :: Int64 -> Int -> Int64 #bit :: Int -> Int64 #setBit :: Int64 -> Int -> Int64 #clearBit :: Int64 -> Int -> Int64 #testBit :: Int64 -> Int -> Bool #bitSize :: Int64 -> Int #shiftL :: Int64 -> Int -> Int64 #shiftR :: Int64 -> Int -> Int64 #rotateL :: Int64 -> Int -> Int64 #rotateR :: Int64 -> Int -> Int64 # Methods Methods Methodsrnf :: Int64 -> () # Methodscrandom :: CryptoRandomGen g => g -> Either GenError (Int64, g) #crandoms :: CryptoRandomGen g => g -> [Int64] # MethodscrandomR :: CryptoRandomGen g => (Int64, Int64) -> g -> Either GenError (Int64, g) #crandomRs :: CryptoRandomGen g => (Int64, Int64) -> g -> [Int64] # Methods Methodsquot :: Int64 -> Int64 -> Int64 #rem :: Int64 -> Int64 -> Int64 #quotRem :: Int64 -> Int64 -> (Int64, Int64) # Methods Methodsabs :: Int64 -> Int64 # MethodsextendedGCD :: Int64 -> Int64 -> (Int64, (Int64, Int64)) #gcd :: Int64 -> Int64 -> Int64 #lcm :: Int64 -> Int64 -> Int64 # MethodsisUnit :: Int64 -> Bool # Methodsdiv :: Int64 -> Int64 -> Int64 #mod :: Int64 -> Int64 -> Int64 #divMod :: Int64 -> Int64 -> (Int64, Int64) # Methods(*) :: Int64 -> Int64 -> Int64 #(^) :: Int64 -> Integer -> Int64 # MethodsisZero :: Int64 -> Bool # Methods(+) :: Int64 -> Int64 -> Int64 #(-) :: Int64 -> Int64 -> Int64 # MethodsreadByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#VoidRep, PtrRepLifted, State# s, Int64#) #writeByteArray# :: MutableByteArray# s -> Int# -> Int64 -> State# s -> State# s #setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Int64 -> State# s -> State# s #readOffAddr# :: Addr# -> Int# -> State# s -> (#VoidRep, PtrRepLifted, State# s, Int64#) #writeOffAddr# :: Addr# -> Int# -> Int64 -> State# s -> State# s #setOffAddr# :: Addr# -> Int# -> Int# -> Int64 -> State# s -> State# s # Methods MethodstellT :: String -> Int64 -> Output #getT :: Stream s Identity Char => String -> Parsec s () Int64 # MethodsmergeConcat :: Foldable t => t Int64 -> Int64 # Methods Methodstouch :: Int64 -> IO () # Source # Embeds into the complex numbers $$\C$$. Associated Typestype CRTExt Int64 :: * Source # Methods MethodsbasicUnsafeThaw :: PrimMonad m => Vector Int64 -> m (Mutable Vector (PrimState m) Int64) #basicUnsafeIndexM :: Monad m => Vector Int64 -> Int -> m Int64 #basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) Int64 -> Vector Int64 -> m () #elemseq :: Vector Int64 -> Int64 -> b -> b # MethodsbasicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) Int64) #basicInitialize :: PrimMonad m => MVector (PrimState m) Int64 -> m () #basicUnsafeReplicate :: PrimMonad m => Int -> Int64 -> m (MVector (PrimState m) Int64) #basicUnsafeRead :: PrimMonad m => MVector (PrimState m) Int64 -> Int -> m Int64 #basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) Int64 -> Int -> Int64 -> m () #basicClear :: PrimMonad m => MVector (PrimState m) Int64 -> m () #basicSet :: PrimMonad m => MVector (PrimState m) Int64 -> Int64 -> m () #basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) Int64 -> MVector (PrimState m) Int64 -> m () #basicUnsafeMove :: PrimMonad m => MVector (PrimState m) Int64 -> MVector (PrimState m) Int64 -> m () #basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) Int64 -> Int -> m (MVector (PrimState m) Int64) # Source # Returns Nothing Methods MessageAPI msg (msg -> Int64) Int64 MethodsgetVal :: msg -> (msg -> Int64) -> Int64 #isSet :: msg -> (msg -> Int64) -> Bool # (Fact m, Reflects k q Int64) => Protoable (CT m (ZqBasic k q Int64)) Source # Associated Typestype ProtoType (CT m (ZqBasic k q Int64)) :: * Source # MethodstoProto :: CT m (ZqBasic k q Int64) -> ProtoType (CT m (ZqBasic k q Int64)) Source #fromProto :: MonadError String m => ProtoType (CT m (ZqBasic k q Int64)) -> m (CT m (ZqBasic k q Int64)) Source # (Fact m, Reflects k q Int64) => Protoable (RT m (ZqBasic k q Int64)) Source # Associated Typestype ProtoType (RT m (ZqBasic k q Int64)) :: * Source # MethodstoProto :: RT m (ZqBasic k q Int64) -> ProtoType (RT m (ZqBasic k q Int64)) Source #fromProto :: MonadError String m => ProtoType (RT m (ZqBasic k q Int64)) -> m (RT m (ZqBasic k q Int64)) Source # data Vector Int64 type CRTExt Int64 Source # data MVector s Int64 data MVector s Int64 = MV_Int64 (MVector s Int64) type ProtoType (CT m (ZqBasic k q Int64)) Source # type ProtoType (CT m (ZqBasic k q Int64)) = Rq type ProtoType (RT m (ZqBasic k q Int64)) Source # type ProtoType (RT m (ZqBasic k q Int64)) = Rq

# Complex

data Complex a Source #

Newtype wrapper (with slightly different instances) for Number.Complex.

Instances

 Unbox a0 => Vector Vector (Complex a0) Source # MethodsbasicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Complex a0) -> m (Vector (Complex a0)) #basicUnsafeThaw :: PrimMonad m => Vector (Complex a0) -> m (Mutable Vector (PrimState m) (Complex a0)) #basicLength :: Vector (Complex a0) -> Int #basicUnsafeSlice :: Int -> Int -> Vector (Complex a0) -> Vector (Complex a0) #basicUnsafeIndexM :: Monad m => Vector (Complex a0) -> Int -> m (Complex a0) #basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Complex a0) -> Vector (Complex a0) -> m () #elemseq :: Vector (Complex a0) -> Complex a0 -> b -> b # Unbox a0 => MVector MVector (Complex a0) Source # MethodsbasicLength :: MVector s (Complex a0) -> Int #basicUnsafeSlice :: Int -> Int -> MVector s (Complex a0) -> MVector s (Complex a0) #basicOverlaps :: MVector s (Complex a0) -> MVector s (Complex a0) -> Bool #basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Complex a0)) #basicInitialize :: PrimMonad m => MVector (PrimState m) (Complex a0) -> m () #basicUnsafeReplicate :: PrimMonad m => Int -> Complex a0 -> m (MVector (PrimState m) (Complex a0)) #basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Complex a0) -> Int -> m (Complex a0) #basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Complex a0) -> Int -> Complex a0 -> m () #basicClear :: PrimMonad m => MVector (PrimState m) (Complex a0) -> m () #basicSet :: PrimMonad m => MVector (PrimState m) (Complex a0) -> Complex a0 -> m () #basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Complex a0) -> MVector (PrimState m) (Complex a0) -> m () #basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Complex a0) -> MVector (PrimState m) (Complex a0) -> m () #basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Complex a0) -> Int -> m (MVector (PrimState m) (Complex a0)) # (Monad mon, Transcendental a) => CRTrans mon (Complex a) Source # Complex numbers have CRTrans for any index $$m$$ MethodscrtInfo :: Reflects k m Int => TaggedT k * m mon (CRTInfo (Complex a)) Source # Eq a => Eq (Complex a) Source # Methods(==) :: Complex a -> Complex a -> Bool #(/=) :: Complex a -> Complex a -> Bool # Show a => Show (Complex a) Source # MethodsshowsPrec :: Int -> Complex a -> ShowS #show :: Complex a -> String #showList :: [Complex a] -> ShowS # Random a => Random (Complex a) Source # MethodsrandomR :: RandomGen g => (Complex a, Complex a) -> g -> (Complex a, g) #random :: RandomGen g => g -> (Complex a, g) #randomRs :: RandomGen g => (Complex a, Complex a) -> g -> [Complex a] #randoms :: RandomGen g => g -> [Complex a] #randomRIO :: (Complex a, Complex a) -> IO (Complex a) #randomIO :: IO (Complex a) # Arbitrary a => Arbitrary (Complex a) Source # Methodsarbitrary :: Gen (Complex a) #shrink :: Complex a -> [Complex a] # Storable a => Storable (Complex a) Source # MethodssizeOf :: Complex a -> Int #alignment :: Complex a -> Int #peekElemOff :: Ptr (Complex a) -> Int -> IO (Complex a) #pokeElemOff :: Ptr (Complex a) -> Int -> Complex a -> IO () #peekByteOff :: Ptr b -> Int -> IO (Complex a) #pokeByteOff :: Ptr b -> Int -> Complex a -> IO () #peek :: Ptr (Complex a) -> IO (Complex a) #poke :: Ptr (Complex a) -> Complex a -> IO () # NFData a => NFData (Complex a) Source # Methodsrnf :: Complex a -> () # C a => C (Complex a) Source # Methods(/) :: Complex a -> Complex a -> Complex a #recip :: Complex a -> Complex a #(^-) :: Complex a -> Integer -> Complex a # Field a => C (Complex a) Source # Custom instance replacing the one provided by numeric prelude: it always returns 0 as the remainder of a division. (The NP instance sometimes has precision issues, because it yields nonzero remainders, which is a problem for divG methods.) Methodsdiv :: Complex a -> Complex a -> Complex a #mod :: Complex a -> Complex a -> Complex a #divMod :: Complex a -> Complex a -> (Complex a, Complex a) # C a => C (Complex a) Source # Methods(*) :: Complex a -> Complex a -> Complex a #one :: Complex a #(^) :: Complex a -> Integer -> Complex a # C a => C (Complex a) Source # MethodsisZero :: Complex a -> Bool # C a => C (Complex a) Source # Methodszero :: Complex a #(+) :: Complex a -> Complex a -> Complex a #(-) :: Complex a -> Complex a -> Complex a #negate :: Complex a -> Complex a # Elt a => Elt (Complex a) Source # Methodstouch :: Complex a -> IO () #zero :: Complex a #one :: Complex a # Unbox a0 => Unbox (Complex a0) Source # Source # Self-embed Associated Typestype CRTExt (Complex a) :: * Source # MethodstoExt :: Complex a -> CRTExt (Complex a) Source #fromExt :: CRTExt (Complex a) -> Complex a Source # data MVector s (Complex a0) Source # data MVector s (Complex a0) = MV_Complex (MVector s (a, a)) data Vector (Complex a0) Source # data Vector (Complex a0) = V_Complex (Vector (a, a)) type CRTExt (Complex a) Source # type CRTExt (Complex a) = Complex a

roundComplex :: (RealRing a, ToInteger b) => Complex a -> (b, b) Source #

Rounds the real and imaginary components to the nearest integer.

cis :: Transcendental a => a -> Complex a Source #

cis $$t$$ is a complex value with magnitude 1 and phase $$t \bmod 2\cdot\pi$$).

real :: Complex a -> a Source #

Real component of a complex number.

imag :: Complex a -> a Source #

Imaginary component of a complex number.

fromReal :: Additive a => a -> Complex a Source #

Embeds a scalar as the real component of a complex number.

# Miscellaneous

rescaleMod :: forall a b. (Mod a, Mod b, ModRep a ~ ModRep b, Lift a (ModRep b), Ring b) => a -> b Source #

A default implementation of rescaling for Mod types.

roundCoset :: forall zp z r. (Mod zp, z ~ ModRep zp, Lift zp z, RealField r) => zp -> r -> z Source #

Deterministically round to a nearby value in the desired coset.

fromJust' :: String -> Maybe a -> a Source #

Version of fromJust with an error message.

pureT :: Applicative f => Tagged t a -> TaggedT t f a Source #

Apply any applicative to a Tagged value.

peelT :: Tagged t (f a) -> TaggedT t f a Source #

Expose the monad of a Tagged value.

pasteT :: TaggedT t f a -> Tagged t (f a) Source #

Hide the monad of a Tagged value.

withWitness :: forall n r. (SingI n => Tagged n r) -> Sing n -> r Source #

Use a singleton as a witness to extract a value from a Tagged value.

withWitnessT :: forall n mon r. (SingI n => TaggedT n mon r) -> Sing n -> mon r Source #

Transformer version of withWitness.

module Data.Proxy