Safe Haskell | None |
---|---|
Language | Haskell2010 |
C implementation of GF(p^m) via precomputed tables of Zech's logarithm.
This way I can test the C implementation using the Haskell test framework.
Synopsis
- data WitnessC (p :: Nat) (m :: Nat) = WitnessC (ForeignPtr Int32)
- fromWitnessC :: WitnessC p m -> ForeignPtr Int32
- data SomeWitnessC = forall p m. SomeWitnessC (WitnessC p m)
- mkCField :: Int -> Int -> Maybe SomeWitnessC
- unsafeCField :: Int -> Int -> SomeWitnessC
- makeCZechTable :: WitnessZech p m -> WitnessC p m
- marshalZechTable :: ZechTable -> IO (ForeignPtr Int32)
- saveCZechTable :: FilePath -> WitnessC p q -> IO ()
- loadCZechTable :: FilePath -> IO (Maybe SomeWitnessC)
- constructWitnessC :: SNat64 p -> SNat64 m -> ForeignPtr Int32 -> WitnessC p m
- data CFq (p :: Nat) (m :: Nat) = CFq !(ForeignPtr Int32) !Int32
- randomCFq :: RandomGen gen => WitnessC p m -> gen -> (CFq p m, gen)
- randomInvCFq :: RandomGen gen => WitnessC p m -> gen -> (CFq p m, gen)
- newtype Raw (p :: Nat) (m :: Nat) = Raw Int32
- fromRaw :: Raw p m -> Int32
- rawNeg :: WitnessC p m -> Raw p m -> Raw p m
- rawAdd :: WitnessC p m -> Raw p m -> Raw p m -> Raw p m
- rawSub :: WitnessC p m -> Raw p m -> Raw p m -> Raw p m
- rawInv :: WitnessC p m -> Raw p m -> Raw p m
- rawMul :: WitnessC p m -> Raw p m -> Raw p m -> Raw p m
- rawDiv :: WitnessC p m -> Raw p m -> Raw p m -> Raw p m
- rawPow :: WitnessC p m -> Raw p m -> Int -> Raw p m
- rawIsZero :: Raw p m -> Bool
- rawIsOne :: Raw p m -> Bool
- rawZero :: Raw p m
- rawOne :: Raw p m
- rawPrim :: Raw p m
- rawEmbed :: WitnessC p m -> Int -> Raw p m
- rawEnumerate :: WitnessC p m -> [Raw p m]
- rawPrime :: WitnessC p m -> Int
- rawDim :: WitnessC p m -> Int
- rawFieldSize :: WitnessC p m -> Int
- cboolToBool :: CBool -> Bool
- zech_neg :: Ptr Int32 -> Int32 -> IO Int32
- zech_add :: Ptr Int32 -> Int32 -> Int32 -> IO Int32
- zech_sub :: Ptr Int32 -> Int32 -> Int32 -> IO Int32
- zech_inv :: Ptr Int32 -> Int32 -> IO Int32
- zech_mul :: Ptr Int32 -> Int32 -> Int32 -> IO Int32
- zech_div :: Ptr Int32 -> Int32 -> Int32 -> IO Int32
- zech_pow :: Ptr Int32 -> Int32 -> CInt -> IO Int32
- zech_zero :: Int32
- zech_one :: Int32
- zech_prim :: Int32
- zech_is_zero :: Int32 -> CBool
- zech_is_one :: Int32 -> CBool
- zech_embed :: Ptr Int32 -> CInt -> IO Int32
- zech_enumerate :: Ptr Int32 -> Ptr Int32 -> IO CInt
Documentation
fromWitnessC :: WitnessC p m -> ForeignPtr Int32 Source #
data SomeWitnessC Source #
forall p m. SomeWitnessC (WitnessC p m) |
Instances
Show SomeWitnessC Source # | |
Defined in Math.FiniteField.GaloisField.Zech.C showsPrec :: Int -> SomeWitnessC -> ShowS # show :: SomeWitnessC -> String # showList :: [SomeWitnessC] -> ShowS # |
unsafeCField :: Int -> Int -> SomeWitnessC Source #
makeCZechTable :: WitnessZech p m -> WitnessC p m Source #
marshalZechTable :: ZechTable -> IO (ForeignPtr Int32) Source #
saveCZechTable :: FilePath -> WitnessC p q -> IO () Source #
Save the data necessary to do computations to a file
loadCZechTable :: FilePath -> IO (Maybe SomeWitnessC) Source #
Load the data necessary to do computations from a file
constructWitnessC :: SNat64 p -> SNat64 m -> ForeignPtr Int32 -> WitnessC p m Source #
data CFq (p :: Nat) (m :: Nat) Source #
An element of the field
CFq !(ForeignPtr Int32) !Int32 |
Instances
The "raw" interface, where you have to manually supply the tables
rawEnumerate :: WitnessC p m -> [Raw p m] Source #
rawFieldSize :: WitnessC p m -> Int Source #
foreign imports
cboolToBool :: CBool -> Bool Source #
zech_is_zero :: Int32 -> CBool Source #
zech_is_one :: Int32 -> CBool Source #