{-# LINE 1 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
module Data.Number.Flint.Fmpz.MPoly.Factor.FFI (
FmpzMPolyFactor (..)
, CFmpzMPolyFactor (..)
, newFmpzMPolyFactor
, withFmpzMPolyFactor
, fmpz_mpoly_factor_init
, fmpz_mpoly_factor_clear
, fmpz_mpoly_factor_swap
, fmpz_mpoly_factor_length
, fmpz_mpoly_factor_get_constant_fmpz
, fmpz_mpoly_factor_get_base
, fmpz_mpoly_factor_get_exp_si
, fmpz_mpoly_factor_sort
, fmpz_mpoly_factor_squarefree
, fmpz_mpoly_factor
) where
import Control.Monad
import Foreign.C.String
import Foreign.C.Types
import Foreign.ForeignPtr
import Foreign.Ptr ( Ptr, FunPtr, nullPtr, plusPtr )
import Foreign.Storable
import Foreign.Marshal ( free )
import Foreign.Marshal.Array ( advancePtr )
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Fmpz.MPoly
import Data.Number.Flint.Fmpq
import Data.Number.Flint.MPoly
data FmpzMPolyFactor =
FmpzMPolyFactor {-# UNPACK #-} !(ForeignPtr CFmpzMPolyFactor)
data CFmpzMPolyFactor =
CFmpzMPolyFactor (Ptr CFmpz) (Ptr CFmpz) (Ptr CFmpzMPoly)
(Ptr CFmpz) CLong CLong
instance Storable CFmpzMPolyFactor where
{-# INLINE sizeOf #-}
sizeOf :: CFmpzMPolyFactor -> Int
sizeOf CFmpzMPolyFactor
_ = (Int
48)
{-# LINE 64 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CFmpzMPolyFactor -> Int
alignment CFmpzMPolyFactor
_ = Int
8
{-# LINE 66 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
peek ptr = CFmpzMPolyFactor
<$> (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr
{-# LINE 68 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr
{-# LINE 69 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 16) ptr
{-# LINE 70 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 24) ptr
{-# LINE 71 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 32) ptr
{-# LINE 72 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
<*> (\hsc_ptr -> peekByteOff hsc_ptr 40) ptr
{-# LINE 73 "src/Data/Number/Flint/Fmpz/MPoly/Factor/FFI.hsc" #-}
poke = error "CFmpzMPolyFactor.poke: Not defined"
newFmpzMPolyFactor :: FmpzMPolyCtx -> IO FmpzMPolyFactor
newFmpzMPolyFactor ctx :: FmpzMPolyCtx
ctx@(FmpzMPolyCtx ForeignPtr CFmpzMPolyCtx
pctx) = do
ForeignPtr CFmpzMPolyFactor
x <- forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFmpzMPolyFactor
x forall a b. (a -> b) -> a -> b
$ \Ptr CFmpzMPolyFactor
x -> do
forall {a}.
FmpzMPolyCtx -> (Ptr CFmpzMPolyCtx -> IO a) -> IO (FmpzMPolyCtx, a)
withFmpzMPolyCtx FmpzMPolyCtx
ctx forall a b. (a -> b) -> a -> b
$ \Ptr CFmpzMPolyCtx
ctx -> do
Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO ()
fmpz_mpoly_factor_init Ptr CFmpzMPolyFactor
x Ptr CFmpzMPolyCtx
ctx
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FunPtr (Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO ())
p_fmpz_mpoly_factor_clear Ptr CFmpzMPolyFactor
x ForeignPtr CFmpzMPolyCtx
pctx
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ ForeignPtr CFmpzMPolyFactor -> FmpzMPolyFactor
FmpzMPolyFactor ForeignPtr CFmpzMPolyFactor
x
withFmpzMPolyFactor :: FmpzMPolyFactor
-> (Ptr CFmpzMPolyFactor -> IO a) -> IO (FmpzMPolyFactor, a)
withFmpzMPolyFactor (FmpzMPolyFactor ForeignPtr CFmpzMPolyFactor
p) Ptr CFmpzMPolyFactor -> IO a
f = do
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CFmpzMPolyFactor
p forall a b. (a -> b) -> a -> b
$ \Ptr CFmpzMPolyFactor
fp -> Ptr CFmpzMPolyFactor -> IO a
f Ptr CFmpzMPolyFactor
fp forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForeignPtr CFmpzMPolyFactor -> FmpzMPolyFactor
FmpzMPolyFactor ForeignPtr CFmpzMPolyFactor
p,)
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_init"
fmpz_mpoly_factor_init :: Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO ()
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_clear"
fmpz_mpoly_factor_clear :: Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO ()
foreign import ccall "fmpz_mpoly_factor.h &fmpz_mpoly_factor_clear"
p_fmpz_mpoly_factor_clear :: FunPtr (Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO ())
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_swap"
fmpz_mpoly_factor_swap :: Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO ()
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_length"
fmpz_mpoly_factor_length :: Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO CLong
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_get_constant_fmpz"
fmpz_mpoly_factor_get_constant_fmpz :: Ptr CFmpz -> Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO ()
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_get_base"
fmpz_mpoly_factor_get_base :: Ptr CFmpzMPoly -> Ptr CFmpzMPolyFactor -> CLong -> Ptr CFmpzMPolyCtx -> IO ()
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_get_exp_si"
fmpz_mpoly_factor_get_exp_si :: Ptr CFmpzMPolyFactor -> CLong -> Ptr CFmpzMPolyCtx -> IO CLong
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_sort"
fmpz_mpoly_factor_sort :: Ptr CFmpzMPolyFactor -> Ptr CFmpzMPolyCtx -> IO ()
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor_squarefree"
fmpz_mpoly_factor_squarefree :: Ptr CFmpzMPolyFactor -> Ptr CFmpzMPoly -> Ptr CFmpzMPolyCtx -> IO CInt
foreign import ccall "fmpz_mpoly_factor.h fmpz_mpoly_factor"
fmpz_mpoly_factor :: Ptr CFmpzMPolyFactor -> Ptr CFmpzMPoly -> Ptr CFmpzMPolyCtx -> IO CInt