{-# OPTIONS_GHC -optc-DACF_INLINES_C #-}
{-# LINE 1 "src/Data/Number/Flint/Acb/Acf/FFI.hsc" #-}
module Data.Number.Flint.Acb.Acf.FFI (
Acf (..)
, CAcf (..)
, newAcf
, withAcf
, withNewAcf
, acf_init
, acf_clear
, acf_swap
, acf_allocated_bytes
, acf_real_ptr
, acf_imag_ptr
, acf_set
, acf_equal
, acf_add
, acf_sub
, acf_mul
, acf_approx_inv
, acf_approx_div
, acf_approx_sqrt
, acf_approx_dot
) where
import Foreign.Ptr
import Foreign.ForeignPtr
import Foreign.Storable
import Foreign.Marshal.Alloc
import Foreign.C.Types
import Foreign.C.String
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Fmpq
import Data.Number.Flint.Arb.Types
import Data.Number.Flint.Acb.Types
newAcf :: IO Acf
newAcf = do
ForeignPtr CAcf
p <- IO (ForeignPtr CAcf)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CAcf -> (Ptr CAcf -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CAcf
p Ptr CAcf -> IO ()
acf_init
FinalizerPtr CAcf -> ForeignPtr CAcf -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CAcf
p_acf_clear ForeignPtr CAcf
p
Acf -> IO Acf
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Acf -> IO Acf) -> Acf -> IO Acf
forall a b. (a -> b) -> a -> b
$ ForeignPtr CAcf -> Acf
Acf ForeignPtr CAcf
p
{-# INLINE withAcf #-}
withAcf :: Acf -> (Ptr CAcf -> IO a) -> IO (Acf, a)
withAcf (Acf ForeignPtr CAcf
p) Ptr CAcf -> IO a
f = ForeignPtr CAcf -> (Ptr CAcf -> IO (Acf, a)) -> IO (Acf, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CAcf
p ((Ptr CAcf -> IO (Acf, a)) -> IO (Acf, a))
-> (Ptr CAcf -> IO (Acf, a)) -> IO (Acf, a)
forall a b. (a -> b) -> a -> b
$ (a -> (Acf, a)) -> IO a -> IO (Acf, a)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ForeignPtr CAcf -> Acf
Acf ForeignPtr CAcf
p,) (IO a -> IO (Acf, a))
-> (Ptr CAcf -> IO a) -> Ptr CAcf -> IO (Acf, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr CAcf -> IO a
f
withNewAcf :: (Ptr CAcf -> IO a) -> IO (Acf, a)
withNewAcf Ptr CAcf -> IO a
f = do
Acf
x <- IO Acf
newAcf
Acf -> (Ptr CAcf -> IO a) -> IO (Acf, a)
forall {a}. Acf -> (Ptr CAcf -> IO a) -> IO (Acf, a)
withAcf Acf
x ((Ptr CAcf -> IO a) -> IO (Acf, a))
-> (Ptr CAcf -> IO a) -> IO (Acf, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CAcf
x -> Ptr CAcf -> IO a
f Ptr CAcf
x
instance Storable CAcf where
{-# INLINE sizeOf #-}
sizeOf :: CAcf -> Int
sizeOf CAcf
_ = (Int
64)
{-# LINE 74 "src/Data/Number/Flint/Acb/Acf/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CAcf -> Int
alignment CAcf
_ = Int
8
{-# LINE 76 "src/Data/Number/Flint/Acb/Acf/FFI.hsc" #-}
peek = error "CAcf.peek: Not defined"
poke :: Ptr CAcf -> CAcf -> IO ()
poke = [Char] -> Ptr CAcf -> CAcf -> IO ()
forall a. HasCallStack => [Char] -> a
error [Char]
"CAcf.poke: Not defined"
foreign import ccall "acf.h acf_init"
acf_init :: Ptr CAcf -> IO ()
foreign import ccall "acf.h acf_clear"
acf_clear :: Ptr CAcf -> IO ()
foreign import ccall "acf.h &acf_clear"
p_acf_clear :: FunPtr (Ptr CAcf -> IO ())
foreign import ccall "acf.h acf_swap"
acf_swap :: Ptr CAcf -> Ptr CAcf -> IO ()
foreign import ccall "acf.h acf_allocated_bytes"
acf_allocated_bytes :: Ptr CAcf -> IO CLong
foreign import ccall "acf.h acf_real_ptr"
acf_real_ptr :: Ptr CAcf -> IO (Ptr CArf)
foreign import ccall "acf.h acf_imag_ptr"
acf_imag_ptr :: Ptr CAcf -> IO (Ptr CArf)
foreign import ccall "acf.h acf_set"
acf_set :: Ptr CAcf -> Ptr CAcf -> IO ()
foreign import ccall "acf.h acf_equal"
acf_equal :: Ptr CAcf -> Ptr CAcf -> IO CInt
foreign import ccall "acf.h acf_add"
acf_add :: Ptr CAcf -> Ptr CAcf -> Ptr CAcf -> CLong -> ArfRnd -> IO CInt
foreign import ccall "acf.h acf_sub"
acf_sub :: Ptr CAcf -> Ptr CAcf -> Ptr CAcf -> CLong -> ArfRnd -> IO CInt
foreign import ccall "acf.h acf_mul"
acf_mul :: Ptr CAcf -> Ptr CAcf -> Ptr CAcf -> CLong -> ArfRnd -> IO CInt
foreign import ccall "acf.h acf_approx_inv"
acf_approx_inv :: Ptr CAcf -> Ptr CAcf -> CLong -> ArfRnd -> IO ()
foreign import ccall "acf.h acf_approx_div"
acf_approx_div :: Ptr CAcf -> Ptr CAcf -> Ptr CAcf -> CLong -> ArfRnd -> IO ()
foreign import ccall "acf.h acf_approx_sqrt"
acf_approx_sqrt :: Ptr CAcf -> Ptr CAcf -> CLong -> ArfRnd -> IO ()
foreign import ccall "acf.h acf_approx_dot"
acf_approx_dot :: Ptr CAcf -> Ptr CAcf -> CInt -> Ptr CAcf -> CLong -> Ptr CAcf -> CLong -> CLong -> CLong -> ArfRnd -> IO ()