{-# LINE 1 "src/Data/Number/Flint/Fmpz/Poly/Factor/FFI.hsc" #-}
module Data.Number.Flint.Fmpz.Poly.Factor.FFI (
FmpzPolyFactor (..)
, CFmpzPolyFactor (..)
, newFmpzPolyFactor
, withFmpzPolyFactor
, withNewFmpzPolyFactor
, fmpz_poly_factor_init
, fmpz_poly_factor_init2
, fmpz_poly_factor_realloc
, fmpz_poly_factor_fit_length
, fmpz_poly_factor_clear
, fmpz_poly_factor_set
, fmpz_poly_factor_insert
, fmpz_poly_factor_concat
, fmpz_poly_factor_print
, fmpz_poly_factor_squarefree
, fmpz_poly_factor_zassenhaus_recombination
, _fmpz_poly_factor_zassenhaus
, fmpz_poly_factor_zassenhaus
, _fmpz_poly_factor_quadratic
, fmpz_poly_factor
) where
import Foreign.C.String
import Foreign.C.Types
import Foreign.ForeignPtr
import Foreign.Ptr ( Ptr, FunPtr, plusPtr, castPtr )
import Foreign.Storable
import Foreign.Marshal ( free )
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Fmpz.Poly
data FmpzPolyFactor =
FmpzPolyFactor {-# UNPACK #-} !(ForeignPtr CFmpzPolyFactor)
data CFmpzPolyFactor = CFmpzPolyFactor (Ptr CFmpz) (Ptr CFmpzPoly) (Ptr CLong) CLong CLong
instance Storable CFmpzPolyFactor where
{-# INLINE sizeOf #-}
sizeOf :: CFmpzPolyFactor -> Int
sizeOf CFmpzPolyFactor
_ = (Int
40)
{-# LINE 71 "src/Data/Number/Flint/Fmpz/Poly/Factor/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CFmpzPolyFactor -> Int
alignment CFmpzPolyFactor
_ = Int
8
{-# LINE 73 "src/Data/Number/Flint/Fmpz/Poly/Factor/FFI.hsc" #-}
peek ptr = CFmpzPolyFactor
<$> (return $ castPtr ptr)
<*> (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr
{-# LINE 76 "src/Data/Number/Flint/Fmpz/Poly/Factor/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 16) ptr
{-# LINE 77 "src/Data/Number/Flint/Fmpz/Poly/Factor/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 24) ptr
{-# LINE 78 "src/Data/Number/Flint/Fmpz/Poly/Factor/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 32) ptr
{-# LINE 79 "src/Data/Number/Flint/Fmpz/Poly/Factor/FFI.hsc" #-}
poke = error "CFmpzPolyFactor.poke: Not defined"
newFmpzPolyFactor :: IO FmpzPolyFactor
newFmpzPolyFactor = do
ForeignPtr CFmpzPolyFactor
p <- IO (ForeignPtr CFmpzPolyFactor)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CFmpzPolyFactor
-> (Ptr CFmpzPolyFactor -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFmpzPolyFactor
p Ptr CFmpzPolyFactor -> IO ()
fmpz_poly_factor_init
FinalizerPtr CFmpzPolyFactor -> ForeignPtr CFmpzPolyFactor -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CFmpzPolyFactor
p_fmpz_poly_factor_clear ForeignPtr CFmpzPolyFactor
p
FmpzPolyFactor -> IO FmpzPolyFactor
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (FmpzPolyFactor -> IO FmpzPolyFactor)
-> FmpzPolyFactor -> IO FmpzPolyFactor
forall a b. (a -> b) -> a -> b
$ ForeignPtr CFmpzPolyFactor -> FmpzPolyFactor
FmpzPolyFactor ForeignPtr CFmpzPolyFactor
p
{-# INLINE withFmpzPolyFactor #-}
withFmpzPolyFactor :: FmpzPolyFactor
-> (Ptr CFmpzPolyFactor -> IO a) -> IO (FmpzPolyFactor, a)
withFmpzPolyFactor (FmpzPolyFactor ForeignPtr CFmpzPolyFactor
p) Ptr CFmpzPolyFactor -> IO a
f = do
ForeignPtr CFmpzPolyFactor
-> (Ptr CFmpzPolyFactor -> IO (FmpzPolyFactor, a))
-> IO (FmpzPolyFactor, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFmpzPolyFactor
p ((Ptr CFmpzPolyFactor -> IO (FmpzPolyFactor, a))
-> IO (FmpzPolyFactor, a))
-> (Ptr CFmpzPolyFactor -> IO (FmpzPolyFactor, a))
-> IO (FmpzPolyFactor, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CFmpzPolyFactor
fp -> Ptr CFmpzPolyFactor -> IO a
f Ptr CFmpzPolyFactor
fp IO a -> (a -> IO (FmpzPolyFactor, a)) -> IO (FmpzPolyFactor, a)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (FmpzPolyFactor, a) -> IO (FmpzPolyFactor, a)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((FmpzPolyFactor, a) -> IO (FmpzPolyFactor, a))
-> (a -> (FmpzPolyFactor, a)) -> a -> IO (FmpzPolyFactor, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForeignPtr CFmpzPolyFactor -> FmpzPolyFactor
FmpzPolyFactor ForeignPtr CFmpzPolyFactor
p,)
withNewFmpzPolyFactor :: (Ptr CFmpzPolyFactor -> IO a) -> IO (FmpzPolyFactor, a)
withNewFmpzPolyFactor Ptr CFmpzPolyFactor -> IO a
f = do
FmpzPolyFactor
x <- IO FmpzPolyFactor
newFmpzPolyFactor
FmpzPolyFactor
-> (Ptr CFmpzPolyFactor -> IO a) -> IO (FmpzPolyFactor, a)
forall {a}.
FmpzPolyFactor
-> (Ptr CFmpzPolyFactor -> IO a) -> IO (FmpzPolyFactor, a)
withFmpzPolyFactor FmpzPolyFactor
x ((Ptr CFmpzPolyFactor -> IO a) -> IO (FmpzPolyFactor, a))
-> (Ptr CFmpzPolyFactor -> IO a) -> IO (FmpzPolyFactor, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CFmpzPolyFactor
x -> Ptr CFmpzPolyFactor -> IO a
f Ptr CFmpzPolyFactor
x
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_init"
fmpz_poly_factor_init :: Ptr CFmpzPolyFactor -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_init2"
fmpz_poly_factor_init2 :: Ptr CFmpzPolyFactor -> CLong -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_realloc"
fmpz_poly_factor_realloc :: Ptr CFmpzPolyFactor -> CLong -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_fit_length"
fmpz_poly_factor_fit_length :: Ptr CFmpzPolyFactor -> CLong -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_clear"
fmpz_poly_factor_clear :: Ptr CFmpzPolyFactor -> IO ()
foreign import ccall "fmpz_poly_factor.h &fmpz_poly_factor_clear"
p_fmpz_poly_factor_clear :: FunPtr (Ptr CFmpzPolyFactor -> IO ())
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_set"
fmpz_poly_factor_set :: Ptr CFmpzPolyFactor -> Ptr CFmpzPolyFactor -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_insert"
fmpz_poly_factor_insert :: Ptr CFmpzPolyFactor -> Ptr CFmpzPoly -> CLong -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_concat"
fmpz_poly_factor_concat :: Ptr CFmpzPolyFactor -> Ptr CFmpzPolyFactor -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_print"
fmpz_poly_factor_print :: Ptr CFmpzPolyFactor -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_squarefree"
fmpz_poly_factor_squarefree :: Ptr CFmpzPolyFactor -> Ptr CFmpzPoly -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_zassenhaus_recombination"
fmpz_poly_factor_zassenhaus_recombination :: Ptr CFmpzPolyFactor -> Ptr CFmpzPolyFactor -> Ptr CFmpzPoly -> Ptr CFmpz -> CLong -> IO ()
foreign import ccall "fmpz_poly_factor.h _fmpz_poly_factor_zassenhaus"
_fmpz_poly_factor_zassenhaus :: Ptr CFmpzPolyFactor -> CLong -> Ptr CFmpzPoly -> CLong -> CInt -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor_zassenhaus"
fmpz_poly_factor_zassenhaus :: Ptr CFmpzPolyFactor -> Ptr CFmpzPoly -> IO ()
foreign import ccall "fmpz_poly_factor.h _fmpz_poly_factor_quadratic"
_fmpz_poly_factor_quadratic :: Ptr CFmpzPolyFactor -> Ptr CFmpzPoly -> CLong -> IO ()
foreign import ccall "fmpz_poly_factor.h fmpz_poly_factor"
fmpz_poly_factor :: Ptr CFmpzPolyFactor -> Ptr CFmpzPoly -> IO ()