{-# LINE 1 "src/Data/Number/Flint/Fq/Zech/FFI.hsc" #-}
module Data.Number.Flint.Fq.Zech.FFI (
FqZech (..)
, CFqZech (..)
, newFqZech
, withFqZech
, FqZechCtx (..)
, CFqZechCtx (..)
, newFqZechCtx
, newFqZechCtxConway
, newFqZechCtxRandom
, newFqZechCtxModulus
, newFqZechCtxModulusCheck
, newFqZechCtxFqNModCtx
, newFqZechCtxFqNModCtxCheck
, withFqZechCtx
, fq_zech_ctx_init
, _fq_zech_ctx_init_conway
, fq_zech_ctx_init_conway
, fq_zech_ctx_init_random
, fq_zech_ctx_init_modulus
, fq_zech_ctx_init_modulus_check
, fq_zech_ctx_init_fq_nmod_ctx
, fq_zech_ctx_init_fq_nmod_ctx_check
, fq_zech_ctx_clear
, fq_zech_ctx_modulus
, fq_zech_ctx_degree
, fq_zech_ctx_order
, fq_zech_ctx_order_ui
, fq_zech_ctx_get_str
, fq_zech_ctx_fprint
, fq_zech_ctx_print
, fq_zech_ctx_randtest
, fq_zech_ctx_randtest_reducible
, fq_zech_init
, fq_zech_init2
, fq_zech_clear
, fq_zech_reduce
, fq_zech_add
, fq_zech_sub
, fq_zech_sub_one
, fq_zech_neg
, fq_zech_mul
, fq_zech_mul_fmpz
, fq_zech_mul_si
, fq_zech_mul_ui
, fq_zech_sqr
, fq_zech_div
, fq_zech_inv
, fq_zech_gcdinv
, fq_zech_pow
, fq_zech_pow_ui
, fq_zech_sqrt
, fq_zech_pth_root
, fq_zech_is_square
, fq_zech_fprint_pretty
, fq_zech_print_pretty
, fq_zech_fprint
, fq_zech_print
, fq_zech_get_str
, fq_zech_get_str_pretty
, fq_zech_randtest
, fq_zech_randtest_not_zero
, fq_zech_rand
, fq_zech_rand_not_zero
, fq_zech_set
, fq_zech_set_si
, fq_zech_set_ui
, fq_zech_set_fmpz
, fq_zech_swap
, fq_zech_zero
, fq_zech_one
, fq_zech_gen
, fq_zech_get_fmpz
, fq_zech_get_fq_nmod
, fq_zech_set_fq_nmod
, fq_zech_get_nmod_poly
, fq_zech_set_nmod_poly
, fq_zech_get_nmod_mat
, fq_zech_set_nmod_mat
, fq_zech_is_zero
, fq_zech_is_one
, fq_zech_equal
, fq_zech_is_invertible
, fq_zech_is_invertible_f
, fq_zech_trace
, fq_zech_norm
, fq_zech_frobenius
, fq_zech_multiplicative_order
, fq_zech_bit_pack
, fq_zech_bit_unpack
) where
import Foreign.C.String
import Foreign.C.Types
import Foreign.Ptr ( Ptr, FunPtr, plusPtr )
import Foreign.ForeignPtr
import Foreign.Storable
import Foreign.Marshal ( free )
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.NMod.Poly
import Data.Number.Flint.NMod.Mat
import Data.Number.Flint.Fq
import Data.Number.Flint.Fq.NMod
import Data.Number.Flint.Fq.NMod.Mat
import Data.Number.Flint.Fq.Zech.Types
instance Storable CFqZech where
{-# INLINE sizeOf #-}
sizeOf :: CFqZech -> Int
sizeOf CFqZech
_ = (Int
8)
{-# LINE 150 "src/Data/Number/Flint/Fq/Zech/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CFqZech -> Int
alignment CFqZech
_ = Int
8
{-# LINE 152 "src/Data/Number/Flint/Fq/Zech/FFI.hsc" #-}
peek = undefined
poke :: Ptr CFqZech -> CFqZech -> IO ()
poke = Ptr CFqZech -> CFqZech -> IO ()
forall a. HasCallStack => a
undefined
newFqZech :: FqZechCtx -> IO FqZech
newFqZech ctx :: FqZechCtx
ctx@(FqZechCtx ForeignPtr CFqZechCtx
ftx) = do
ForeignPtr CFqZech
x <- IO (ForeignPtr CFqZech)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFqZech -> (Ptr CFqZech -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZech
x ((Ptr CFqZech -> IO ()) -> IO ())
-> (Ptr CFqZech -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZech
x -> do
FqZechCtx -> (Ptr CFqZechCtx -> IO ()) -> IO (FqZechCtx, ())
forall {a}.
FqZechCtx -> (Ptr CFqZechCtx -> IO a) -> IO (FqZechCtx, a)
withFqZechCtx FqZechCtx
ctx ((Ptr CFqZechCtx -> IO ()) -> IO (FqZechCtx, ()))
-> (Ptr CFqZechCtx -> IO ()) -> IO (FqZechCtx, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZechCtx
ctx -> do
Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
fq_zech_init Ptr CFqZech
x Ptr CFqZechCtx
ctx
FinalizerEnvPtr CFqZech CFqZechCtx
-> Ptr CFqZech -> ForeignPtr CFqZechCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CFqZech CFqZechCtx
p_fq_zech_clear Ptr CFqZech
x ForeignPtr CFqZechCtx
ftx
FqZech -> IO FqZech
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FqZech -> IO FqZech) -> FqZech -> IO FqZech
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFqZech -> FqZech
FqZech ForeignPtr CFqZech
x
{-# INLINE withFqZech #-}
withFqZech :: FqZech -> (Ptr CFqZech -> IO a) -> IO (FqZech, a)
withFqZech (FqZech ForeignPtr CFqZech
x) Ptr CFqZech -> IO a
f = do
ForeignPtr CFqZech
-> (Ptr CFqZech -> IO (FqZech, a)) -> IO (FqZech, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZech
x ((Ptr CFqZech -> IO (FqZech, a)) -> IO (FqZech, a))
-> (Ptr CFqZech -> IO (FqZech, a)) -> IO (FqZech, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZech
px -> Ptr CFqZech -> IO a
f Ptr CFqZech
px IO a -> (a -> IO (FqZech, a)) -> IO (FqZech, a)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (FqZech, a) -> IO (FqZech, a)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((FqZech, a) -> IO (FqZech, a))
-> (a -> (FqZech, a)) -> a -> IO (FqZech, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForeignPtr CFqZech -> FqZech
FqZech ForeignPtr CFqZech
x,)
instance Storable CFqZechCtx where
{-# INLINE sizeOf #-}
sizeOf :: CFqZechCtx -> Int
sizeOf CFqZechCtx
_ = (Int
88)
{-# LINE 172 "src/Data/Number/Flint/Fq/Zech/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CFqZechCtx -> Int
alignment CFqZechCtx
_ = Int
8
{-# LINE 174 "src/Data/Number/Flint/Fq/Zech/FFI.hsc" #-}
peek = undefined
poke :: Ptr CFqZechCtx -> CFqZechCtx -> IO ()
poke = Ptr CFqZechCtx -> CFqZechCtx -> IO ()
forall a. HasCallStack => a
undefined
_newFqZechCtx :: (Ptr CFqZechCtx -> Ptr CFmpz -> t -> CString -> IO a)
-> Fmpz -> t -> String -> IO FqZechCtx
_newFqZechCtx Ptr CFqZechCtx -> Ptr CFmpz -> t -> CString -> IO a
f Fmpz
p t
d String
var = do
ForeignPtr CFqZechCtx
x <- IO (ForeignPtr CFqZechCtx)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFqZechCtx
-> (Ptr CFqZechCtx -> IO (Fmpz, a)) -> IO (Fmpz, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZechCtx
x ((Ptr CFqZechCtx -> IO (Fmpz, a)) -> IO (Fmpz, a))
-> (Ptr CFqZechCtx -> IO (Fmpz, a)) -> IO (Fmpz, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZechCtx
x ->
Fmpz -> (Ptr CFmpz -> IO a) -> IO (Fmpz, a)
forall {a}. Fmpz -> (Ptr CFmpz -> IO a) -> IO (Fmpz, a)
withFmpz Fmpz
p ((Ptr CFmpz -> IO a) -> IO (Fmpz, a))
-> (Ptr CFmpz -> IO a) -> IO (Fmpz, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CFmpz
p ->
String -> (CString -> IO a) -> IO a
forall a. String -> (CString -> IO a) -> IO a
withCString String
var ((CString -> IO a) -> IO a) -> (CString -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \CString
var -> do
Ptr CFqZechCtx -> Ptr CFmpz -> t -> CString -> IO a
f Ptr CFqZechCtx
x Ptr CFmpz
p t
d CString
var
FinalizerPtr CFqZechCtx -> ForeignPtr CFqZechCtx -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFqZechCtx
p_fq_zech_ctx_clear ForeignPtr CFqZechCtx
x
FqZechCtx -> IO FqZechCtx
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FqZechCtx -> IO FqZechCtx) -> FqZechCtx -> IO FqZechCtx
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFqZechCtx -> FqZechCtx
FqZechCtx ForeignPtr CFqZechCtx
x
newFqZechCtx :: Fmpz -> CLong -> String -> IO FqZechCtx
newFqZechCtx = (Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ())
-> Fmpz -> CLong -> String -> IO FqZechCtx
forall {t} {a}.
(Ptr CFqZechCtx -> Ptr CFmpz -> t -> CString -> IO a)
-> Fmpz -> t -> String -> IO FqZechCtx
_newFqZechCtx Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ()
fq_zech_ctx_init
newFqZechCtxConway :: Fmpz -> CLong -> String -> IO FqZechCtx
newFqZechCtxConway = (Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ())
-> Fmpz -> CLong -> String -> IO FqZechCtx
forall {t} {a}.
(Ptr CFqZechCtx -> Ptr CFmpz -> t -> CString -> IO a)
-> Fmpz -> t -> String -> IO FqZechCtx
_newFqZechCtx Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ()
fq_zech_ctx_init_conway
newFqZechCtxRandom :: Fmpz -> CLong -> String -> IO FqZechCtx
newFqZechCtxRandom = (Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ())
-> Fmpz -> CLong -> String -> IO FqZechCtx
forall {t} {a}.
(Ptr CFqZechCtx -> Ptr CFmpz -> t -> CString -> IO a)
-> Fmpz -> t -> String -> IO FqZechCtx
_newFqZechCtx Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ()
fq_zech_ctx_init_random
newFqZechCtxModulus :: p -> NModPoly -> String -> IO FqZechCtx
newFqZechCtxModulus p
f NModPoly
modulus String
var = do
ForeignPtr CFqZechCtx
x <- IO (ForeignPtr CFqZechCtx)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFqZechCtx
-> (Ptr CFqZechCtx -> IO (NModPoly, ())) -> IO (NModPoly, ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZechCtx
x ((Ptr CFqZechCtx -> IO (NModPoly, ())) -> IO (NModPoly, ()))
-> (Ptr CFqZechCtx -> IO (NModPoly, ())) -> IO (NModPoly, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZechCtx
x ->
NModPoly -> (Ptr CNModPoly -> IO ()) -> IO (NModPoly, ())
forall {a}. NModPoly -> (Ptr CNModPoly -> IO a) -> IO (NModPoly, a)
withNModPoly NModPoly
modulus ((Ptr CNModPoly -> IO ()) -> IO (NModPoly, ()))
-> (Ptr CNModPoly -> IO ()) -> IO (NModPoly, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CNModPoly
modulus ->
String -> (CString -> IO ()) -> IO ()
forall a. String -> (CString -> IO a) -> IO a
withCString String
var ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
var ->
Ptr CFqZechCtx -> Ptr CNModPoly -> CString -> IO ()
fq_zech_ctx_init_modulus Ptr CFqZechCtx
x Ptr CNModPoly
modulus CString
var
FinalizerPtr CFqZechCtx -> ForeignPtr CFqZechCtx -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFqZechCtx
p_fq_zech_ctx_clear ForeignPtr CFqZechCtx
x
FqZechCtx -> IO FqZechCtx
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FqZechCtx -> IO FqZechCtx) -> FqZechCtx -> IO FqZechCtx
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFqZechCtx -> FqZechCtx
FqZechCtx ForeignPtr CFqZechCtx
x
newFqZechCtxModulusCheck :: p -> NModPoly -> String -> IO FqZechCtx
newFqZechCtxModulusCheck p
f NModPoly
modulus String
var = do
ForeignPtr CFqZechCtx
x <- IO (ForeignPtr CFqZechCtx)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFqZechCtx
-> (Ptr CFqZechCtx -> IO (NModPoly, CInt)) -> IO (NModPoly, CInt)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZechCtx
x ((Ptr CFqZechCtx -> IO (NModPoly, CInt)) -> IO (NModPoly, CInt))
-> (Ptr CFqZechCtx -> IO (NModPoly, CInt)) -> IO (NModPoly, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZechCtx
x ->
NModPoly -> (Ptr CNModPoly -> IO CInt) -> IO (NModPoly, CInt)
forall {a}. NModPoly -> (Ptr CNModPoly -> IO a) -> IO (NModPoly, a)
withNModPoly NModPoly
modulus ((Ptr CNModPoly -> IO CInt) -> IO (NModPoly, CInt))
-> (Ptr CNModPoly -> IO CInt) -> IO (NModPoly, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CNModPoly
modulus ->
String -> (CString -> IO CInt) -> IO CInt
forall a. String -> (CString -> IO a) -> IO a
withCString String
var ((CString -> IO CInt) -> IO CInt)
-> (CString -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \CString
var ->
Ptr CFqZechCtx -> Ptr CNModPoly -> CString -> IO CInt
fq_zech_ctx_init_modulus_check Ptr CFqZechCtx
x Ptr CNModPoly
modulus CString
var
FinalizerPtr CFqZechCtx -> ForeignPtr CFqZechCtx -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFqZechCtx
p_fq_zech_ctx_clear ForeignPtr CFqZechCtx
x
FqZechCtx -> IO FqZechCtx
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FqZechCtx -> IO FqZechCtx) -> FqZechCtx -> IO FqZechCtx
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFqZechCtx -> FqZechCtx
FqZechCtx ForeignPtr CFqZechCtx
x
newFqZechCtxFqNModCtx :: p -> FqNModCtx -> IO FqZechCtx
newFqZechCtxFqNModCtx p
f FqNModCtx
ctxn = do
ForeignPtr CFqZechCtx
x <- IO (ForeignPtr CFqZechCtx)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFqZechCtx
-> (Ptr CFqZechCtx -> IO (FqNModCtx, ())) -> IO (FqNModCtx, ())
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZechCtx
x ((Ptr CFqZechCtx -> IO (FqNModCtx, ())) -> IO (FqNModCtx, ()))
-> (Ptr CFqZechCtx -> IO (FqNModCtx, ())) -> IO (FqNModCtx, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZechCtx
x ->
FqNModCtx -> (Ptr CFqNModCtx -> IO ()) -> IO (FqNModCtx, ())
forall {a}.
FqNModCtx -> (Ptr CFqNModCtx -> IO a) -> IO (FqNModCtx, a)
withFqNModCtx FqNModCtx
ctxn ((Ptr CFqNModCtx -> IO ()) -> IO (FqNModCtx, ()))
-> (Ptr CFqNModCtx -> IO ()) -> IO (FqNModCtx, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CFqNModCtx
ctxn ->
Ptr CFqZechCtx -> Ptr CFqNModCtx -> IO ()
fq_zech_ctx_init_fq_nmod_ctx Ptr CFqZechCtx
x Ptr CFqNModCtx
ctxn
FinalizerPtr CFqZechCtx -> ForeignPtr CFqZechCtx -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFqZechCtx
p_fq_zech_ctx_clear ForeignPtr CFqZechCtx
x
FqZechCtx -> IO FqZechCtx
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FqZechCtx -> IO FqZechCtx) -> FqZechCtx -> IO FqZechCtx
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFqZechCtx -> FqZechCtx
FqZechCtx ForeignPtr CFqZechCtx
x
newFqZechCtxFqNModCtxCheck :: p -> FqNModCtx -> IO FqZechCtx
newFqZechCtxFqNModCtxCheck p
f FqNModCtx
ctxn = do
ForeignPtr CFqZechCtx
x <- IO (ForeignPtr CFqZechCtx)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFqZechCtx
-> (Ptr CFqZechCtx -> IO (FqNModCtx, CInt)) -> IO (FqNModCtx, CInt)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZechCtx
x ((Ptr CFqZechCtx -> IO (FqNModCtx, CInt)) -> IO (FqNModCtx, CInt))
-> (Ptr CFqZechCtx -> IO (FqNModCtx, CInt)) -> IO (FqNModCtx, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZechCtx
x ->
FqNModCtx -> (Ptr CFqNModCtx -> IO CInt) -> IO (FqNModCtx, CInt)
forall {a}.
FqNModCtx -> (Ptr CFqNModCtx -> IO a) -> IO (FqNModCtx, a)
withFqNModCtx FqNModCtx
ctxn ((Ptr CFqNModCtx -> IO CInt) -> IO (FqNModCtx, CInt))
-> (Ptr CFqNModCtx -> IO CInt) -> IO (FqNModCtx, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CFqNModCtx
ctxn ->
Ptr CFqZechCtx -> Ptr CFqNModCtx -> IO CInt
fq_zech_ctx_init_fq_nmod_ctx_check Ptr CFqZechCtx
x Ptr CFqNModCtx
ctxn
FinalizerPtr CFqZechCtx -> ForeignPtr CFqZechCtx -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFqZechCtx
p_fq_zech_ctx_clear ForeignPtr CFqZechCtx
x
FqZechCtx -> IO FqZechCtx
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FqZechCtx -> IO FqZechCtx) -> FqZechCtx -> IO FqZechCtx
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFqZechCtx -> FqZechCtx
FqZechCtx ForeignPtr CFqZechCtx
x
newFqZechCtxFqCtxModulusCheck :: p -> FqNModCtx -> IO FqZechCtx
newFqZechCtxFqCtxModulusCheck p
f FqNModCtx
ctxn = do
ForeignPtr CFqZechCtx
x <- IO (ForeignPtr CFqZechCtx)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFqZechCtx
-> (Ptr CFqZechCtx -> IO (FqNModCtx, CInt)) -> IO (FqNModCtx, CInt)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZechCtx
x ((Ptr CFqZechCtx -> IO (FqNModCtx, CInt)) -> IO (FqNModCtx, CInt))
-> (Ptr CFqZechCtx -> IO (FqNModCtx, CInt)) -> IO (FqNModCtx, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZechCtx
x ->
FqNModCtx -> (Ptr CFqNModCtx -> IO CInt) -> IO (FqNModCtx, CInt)
forall {a}.
FqNModCtx -> (Ptr CFqNModCtx -> IO a) -> IO (FqNModCtx, a)
withFqNModCtx FqNModCtx
ctxn ((Ptr CFqNModCtx -> IO CInt) -> IO (FqNModCtx, CInt))
-> (Ptr CFqNModCtx -> IO CInt) -> IO (FqNModCtx, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CFqNModCtx
ctxn ->
Ptr CFqZechCtx -> Ptr CFqNModCtx -> IO CInt
fq_zech_ctx_init_fq_nmod_ctx_check Ptr CFqZechCtx
x Ptr CFqNModCtx
ctxn
FinalizerPtr CFqZechCtx -> ForeignPtr CFqZechCtx -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFqZechCtx
p_fq_zech_ctx_clear ForeignPtr CFqZechCtx
x
FqZechCtx -> IO FqZechCtx
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FqZechCtx -> IO FqZechCtx) -> FqZechCtx -> IO FqZechCtx
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFqZechCtx -> FqZechCtx
FqZechCtx ForeignPtr CFqZechCtx
x
{-# INLINE withFqZechCtx #-}
withFqZechCtx :: FqZechCtx -> (Ptr CFqZechCtx -> IO a) -> IO (FqZechCtx, a)
withFqZechCtx (FqZechCtx ForeignPtr CFqZechCtx
x) Ptr CFqZechCtx -> IO a
f = do
ForeignPtr CFqZechCtx
-> (Ptr CFqZechCtx -> IO (FqZechCtx, a)) -> IO (FqZechCtx, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFqZechCtx
x ((Ptr CFqZechCtx -> IO (FqZechCtx, a)) -> IO (FqZechCtx, a))
-> (Ptr CFqZechCtx -> IO (FqZechCtx, a)) -> IO (FqZechCtx, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CFqZechCtx
px -> Ptr CFqZechCtx -> IO a
f Ptr CFqZechCtx
px IO a -> (a -> IO (FqZechCtx, a)) -> IO (FqZechCtx, a)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (FqZechCtx, a) -> IO (FqZechCtx, a)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((FqZechCtx, a) -> IO (FqZechCtx, a))
-> (a -> (FqZechCtx, a)) -> a -> IO (FqZechCtx, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForeignPtr CFqZechCtx -> FqZechCtx
FqZechCtx ForeignPtr CFqZechCtx
x,)
foreign import ccall "fq_zech.h fq_zech_ctx_init"
fq_zech_ctx_init :: Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ()
foreign import ccall "fq_zech.h _fq_zech_ctx_init_conway"
_fq_zech_ctx_init_conway :: Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO CInt
foreign import ccall "fq_zech.h fq_zech_ctx_init_conway"
fq_zech_ctx_init_conway :: Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ()
foreign import ccall "fq_zech.h fq_zech_ctx_init_random"
fq_zech_ctx_init_random :: Ptr CFqZechCtx -> Ptr CFmpz -> CLong -> CString -> IO ()
foreign import ccall "fq_zech.h fq_zech_ctx_init_modulus"
fq_zech_ctx_init_modulus :: Ptr CFqZechCtx -> Ptr CNModPoly -> CString -> IO ()
foreign import ccall "fq_zech.h fq_zech_ctx_init_modulus_check"
fq_zech_ctx_init_modulus_check :: Ptr CFqZechCtx -> Ptr CNModPoly -> CString -> IO CInt
foreign import ccall "fq_zech.h fq_zech_ctx_init_fq_nmod_ctx"
fq_zech_ctx_init_fq_nmod_ctx :: Ptr CFqZechCtx -> Ptr CFqNModCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_ctx_init_fq_nmod_ctx_check"
fq_zech_ctx_init_fq_nmod_ctx_check :: Ptr CFqZechCtx -> Ptr CFqNModCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_ctx_clear"
fq_zech_ctx_clear :: Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h &fq_zech_ctx_clear"
p_fq_zech_ctx_clear :: FunPtr (Ptr CFqZechCtx -> IO ())
foreign import ccall "fq_zech.h fq_zech_ctx_modulus"
fq_zech_ctx_modulus :: Ptr CFqZechCtx -> IO (Ptr (Ptr CNModPoly))
foreign import ccall "fq_zech.h fq_zech_ctx_degree"
fq_zech_ctx_degree :: Ptr CFqZechCtx -> IO CLong
foreign import ccall "fq_zech.h fq_zech_ctx_order"
fq_zech_ctx_order :: Ptr CFmpz -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_ctx_order_ui"
fq_zech_ctx_order_ui :: Ptr CFqZechCtx -> IO CMpLimb
foreign import ccall "fq_zech.h fq_zech_ctx_get_str"
fq_zech_ctx_get_str :: Ptr CFqZechCtx -> IO CString
foreign import ccall "fq_zech.h fq_zech_ctx_fprint"
fq_zech_ctx_fprint :: Ptr CFile -> Ptr CFqZechCtx -> IO CInt
fq_zech_ctx_print :: Ptr CFqZechCtx -> IO ()
fq_zech_ctx_print :: Ptr CFqZechCtx -> IO ()
fq_zech_ctx_print Ptr CFqZechCtx
ctx = do
(Ptr CFqZechCtx -> IO CString) -> Ptr CFqZechCtx -> IO CInt
forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr Ptr CFqZechCtx -> IO CString
fq_zech_ctx_get_str Ptr CFqZechCtx
ctx
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
foreign import ccall "fq_zech.h fq_zech_ctx_randtest"
fq_zech_ctx_randtest :: Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_ctx_randtest_reducible"
fq_zech_ctx_randtest_reducible :: Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_init"
fq_zech_init :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_init2"
fq_zech_init2 :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_clear"
fq_zech_clear :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h &fq_zech_clear"
p_fq_zech_clear :: FunPtr (Ptr CFqZech -> Ptr CFqZechCtx -> IO ())
foreign import ccall "fq_zech.h fq_zech_reduce"
fq_zech_reduce :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_add"
fq_zech_add :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_sub"
fq_zech_sub :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_sub_one"
fq_zech_sub_one :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_neg"
fq_zech_neg :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_mul"
fq_zech_mul :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_mul_fmpz"
fq_zech_mul_fmpz :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFmpz -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_mul_si"
fq_zech_mul_si :: Ptr CFqZech -> Ptr CFqZech -> CLong -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_mul_ui"
fq_zech_mul_ui :: Ptr CFqZech -> Ptr CFqZech -> CULong -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_sqr"
fq_zech_sqr :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_div"
fq_zech_div :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_inv"
fq_zech_inv :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_gcdinv"
fq_zech_gcdinv :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_pow"
fq_zech_pow :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFmpz -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_pow_ui"
fq_zech_pow_ui :: Ptr CFqZech -> Ptr CFqZech -> CULong -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_sqrt"
fq_zech_sqrt :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_pth_root"
fq_zech_pth_root :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_is_square"
fq_zech_is_square :: Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_fprint_pretty"
fq_zech_fprint_pretty :: Ptr CFile -> Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
fq_zech_print_pretty :: Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
fq_zech_print_pretty :: Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
fq_zech_print_pretty Ptr CFqZech
op Ptr CFqZechCtx
ctx = do
(Ptr CFqZech -> IO CString) -> Ptr CFqZech -> IO CInt
forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr (\Ptr CFqZech
op -> Ptr CFqZech -> Ptr CFqZechCtx -> IO CString
fq_zech_get_str_pretty Ptr CFqZech
op Ptr CFqZechCtx
ctx) Ptr CFqZech
op
foreign import ccall "fq_zech.h fq_zech_fprint"
fq_zech_fprint :: Ptr CFile -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
fq_zech_print :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
fq_zech_print :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
fq_zech_print Ptr CFqZech
op Ptr CFqZechCtx
ctx = do
(Ptr CFqZech -> IO CString) -> Ptr CFqZech -> IO CInt
forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr (\Ptr CFqZech
op -> Ptr CFqZech -> Ptr CFqZechCtx -> IO CString
fq_zech_get_str Ptr CFqZech
op Ptr CFqZechCtx
ctx) Ptr CFqZech
op
() -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
foreign import ccall "fq_zech.h fq_zech_get_str"
fq_zech_get_str :: Ptr CFqZech -> Ptr CFqZechCtx -> IO CString
foreign import ccall "fq_zech.h fq_zech_get_str_pretty"
fq_zech_get_str_pretty :: Ptr CFqZech -> Ptr CFqZechCtx -> IO CString
foreign import ccall "fq_zech.h fq_zech_randtest"
fq_zech_randtest :: Ptr CFqZech -> Ptr CFRandState -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_randtest_not_zero"
fq_zech_randtest_not_zero :: Ptr CFqZech -> Ptr CFRandState -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_rand"
fq_zech_rand :: Ptr CFqZech -> Ptr CFRandState -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_rand_not_zero"
fq_zech_rand_not_zero :: Ptr CFqZech -> Ptr CFRandState -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_set"
fq_zech_set :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_set_si"
fq_zech_set_si :: Ptr CFqZech -> CLong -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_set_ui"
fq_zech_set_ui :: Ptr CFqZech -> CULong -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_set_fmpz"
fq_zech_set_fmpz :: Ptr CFqZech -> Ptr CFmpz -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_swap"
fq_zech_swap :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_zero"
fq_zech_zero :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_one"
fq_zech_one :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_gen"
fq_zech_gen :: Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_get_fmpz"
fq_zech_get_fmpz :: Ptr CFmpz -> Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_get_fq_nmod"
fq_zech_get_fq_nmod :: Ptr CFqNMod -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_set_fq_nmod"
fq_zech_set_fq_nmod :: Ptr CFqZech -> Ptr CFqNMod -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_get_nmod_poly"
fq_zech_get_nmod_poly :: Ptr CNModPoly -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_set_nmod_poly"
fq_zech_set_nmod_poly :: Ptr CFqZech -> Ptr CNModPoly -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_get_nmod_mat"
fq_zech_get_nmod_mat :: Ptr CNModMat -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_set_nmod_mat"
fq_zech_set_nmod_mat :: Ptr CFqZech -> Ptr CNModMat -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_is_zero"
fq_zech_is_zero :: Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_is_one"
fq_zech_is_one :: Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_equal"
fq_zech_equal :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_is_invertible"
fq_zech_is_invertible :: Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_is_invertible_f"
fq_zech_is_invertible_f :: Ptr CFqZech -> Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_trace"
fq_zech_trace :: Ptr CFmpz -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_norm"
fq_zech_norm :: Ptr CFmpz -> Ptr CFqZech -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_frobenius"
fq_zech_frobenius :: Ptr CFqZech -> Ptr CFqZech -> CLong -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_multiplicative_order"
fq_zech_multiplicative_order :: Ptr CFmpz -> Ptr CFqZech -> Ptr CFqZechCtx -> IO CInt
foreign import ccall "fq_zech.h fq_zech_bit_pack"
fq_zech_bit_pack :: Ptr CFmpz -> Ptr CFqZech -> CFBitCnt -> Ptr CFqZechCtx -> IO ()
foreign import ccall "fq_zech.h fq_zech_bit_unpack"
fq_zech_bit_unpack :: Ptr CFqZech -> Ptr CFmpz -> CFBitCnt -> Ptr CFqZechCtx -> IO ()