{-# LINE 1 "src/Data/Number/Flint/Arb/Mag/FFI.hsc" #-}
module Data.Number.Flint.Arb.Mag.FFI (
Mag (..)
, CMag (..)
, newMag
, withMag
, withNewMag
, mag_init
, mag_clear
, mag_swap
, _mag_vec_init
, _mag_vec_clear
, mag_allocated_bytes
, mag_zero
, mag_one
, mag_inf
, mag_is_special
, mag_is_zero
, mag_is_inf
, mag_is_finite
, mag_d_log_lower_bound
, mag_d_log_upper_bound
, mag_init_set
, mag_set
, mag_set_d
, mag_set_ui
, mag_set_fmpz
, mag_set_d_lower
, mag_set_ui_lower
, mag_set_fmpz_lower
, mag_set_d_2exp_fmpz
, mag_set_fmpz_2exp_fmpz
, mag_set_ui_2exp_si
, mag_set_d_2exp_fmpz_lower
, mag_set_fmpz_2exp_fmpz_lower
, mag_get_d
, mag_get_d_log2_approx
, mag_get_fmpq
, mag_get_fmpz
, mag_get_fmpz_lower
, mag_equal
, mag_cmp
, mag_cmp_2exp_si
, mag_min
, mag_max
, mag_get_str
, mag_print
, mag_fprint
, mag_dump_str
, mag_load_str
, mag_dump_file
, mag_load_file
, mag_randtest
, mag_randtest_special
, mag_add
, mag_add_ui
, mag_add_lower
, mag_add_ui_lower
, mag_add_2exp_fmpz
, mag_add_ui_2exp_si
, mag_sub
, mag_sub_lower
, mag_mul_2exp_si
, mag_mul_2exp_fmpz
, mag_mul
, mag_mul_ui
, mag_mul_fmpz
, mag_mul_lower
, mag_mul_ui_lower
, mag_mul_fmpz_lower
, mag_addmul
, mag_div
, mag_div_ui
, mag_div_fmpz
, mag_div_lower
, mag_inv
, mag_inv_lower
, mag_fast_init_set
, mag_fast_zero
, mag_fast_is_zero
, mag_fast_mul
, mag_fast_addmul
, mag_fast_add_2exp_si
, mag_fast_mul_2exp_si
, mag_pow_ui
, mag_pow_fmpz
, mag_pow_ui_lower
, mag_pow_fmpz_lower
, mag_sqrt
, mag_sqrt_lower
, mag_rsqrt
, mag_rsqrt_lower
, mag_hypot
, mag_root
, mag_log
, mag_log_lower
, mag_neg_log
, mag_neg_log_lower
, mag_log_ui
, mag_log1p
, mag_exp
, mag_exp_lower
, mag_expinv
, mag_expinv_lower
, mag_expm1
, mag_exp_tail
, mag_binpow_uiui
, mag_geom_series
, mag_const_pi
, mag_const_pi_lower
, mag_atan
, mag_atan_lower
, mag_cosh
, mag_cosh_lower
, mag_sinh
, mag_sinh_lower
, mag_fac_ui
, mag_rfac_ui
, mag_bin_uiui
, mag_bernoulli_div_fac_ui
, mag_polylog_tail
, mag_hurwitz_zeta_uiui
) where
import Foreign.Ptr
import Foreign.ForeignPtr
import Foreign.C.Types
import Foreign.C.String
import Foreign.Storable
import Foreign.Marshal.Alloc (free)
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Fmpq
import Data.Number.Flint.Arb.Types
newMag :: IO Mag
newMag = do
ForeignPtr CMag
x <- IO (ForeignPtr CMag)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CMag -> (Ptr CMag -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CMag
x Ptr CMag -> IO ()
mag_init
FinalizerPtr CMag -> ForeignPtr CMag -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CMag
p_mag_clear ForeignPtr CMag
x
Mag -> IO Mag
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Mag -> IO Mag) -> Mag -> IO Mag
forall a b. (a -> b) -> a -> b
$ ForeignPtr CMag -> Mag
Mag ForeignPtr CMag
x
withMag :: Mag -> (Ptr CMag -> IO a) -> IO (Mag, a)
withMag (Mag ForeignPtr CMag
p) Ptr CMag -> IO a
f = do
ForeignPtr CMag -> (Ptr CMag -> IO (Mag, a)) -> IO (Mag, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CMag
p ((Ptr CMag -> IO (Mag, a)) -> IO (Mag, a))
-> (Ptr CMag -> IO (Mag, a)) -> IO (Mag, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CMag
fp -> (ForeignPtr CMag -> Mag
Mag ForeignPtr CMag
p,) (a -> (Mag, a)) -> IO a -> IO (Mag, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr CMag -> IO a
f Ptr CMag
fp
withNewMag :: (Ptr CMag -> IO a) -> IO (Mag, a)
withNewMag Ptr CMag -> IO a
f = do
Mag
x <- IO Mag
newMag
Mag -> (Ptr CMag -> IO a) -> IO (Mag, a)
forall {a}. Mag -> (Ptr CMag -> IO a) -> IO (Mag, a)
withMag Mag
x Ptr CMag -> IO a
f
foreign import ccall "mag.h mag_init"
mag_init :: Ptr CMag -> IO ()
foreign import ccall "mag.h mag_clear"
mag_clear :: Ptr CMag -> IO ()
foreign import ccall "mag.h &mag_clear"
p_mag_clear :: FunPtr (Ptr CMag -> IO ())
foreign import ccall "mag.h mag_swap"
mag_swap :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h _mag_vec_init"
_mag_vec_init :: CLong -> IO (Ptr CMag)
foreign import ccall "mag.h _mag_vec_clear"
_mag_vec_clear :: (Ptr CMag) -> CLong -> IO ()
foreign import ccall "mag.h mag_allocated_bytes"
mag_allocated_bytes :: Ptr CMag -> IO CLong
foreign import ccall "mag.h mag_zero"
mag_zero :: Ptr CMag -> IO ()
foreign import ccall "mag.h mag_one"
mag_one :: Ptr CMag -> IO ()
foreign import ccall "mag.h mag_inf"
mag_inf :: Ptr CMag -> IO ()
foreign import ccall "mag.h mag_is_special"
mag_is_special :: Ptr CMag -> IO CInt
foreign import ccall "mag.h mag_is_zero"
mag_is_zero :: Ptr CMag -> IO CInt
foreign import ccall "mag.h mag_is_inf"
mag_is_inf :: Ptr CMag -> IO CInt
foreign import ccall "mag.h mag_is_finite"
mag_is_finite :: Ptr CMag -> IO CInt
foreign import ccall "mag.h mag_d_log_lower_bound"
mag_d_log_lower_bound :: CDouble -> CDouble
foreign import ccall "mag.h mag_d_log_upper_bound"
mag_d_log_upper_bound :: CDouble -> CDouble
foreign import ccall "mag.h mag_init_set"
mag_init_set :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_set"
mag_set :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_set_d"
mag_set_d :: Ptr CMag -> CDouble -> IO ()
foreign import ccall "mag.h mag_set_ui"
mag_set_ui :: Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_set_fmpz"
mag_set_fmpz :: Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_set_d_lower"
mag_set_d_lower :: Ptr CMag -> CDouble -> IO ()
foreign import ccall "mag.h mag_set_ui_lower"
mag_set_ui_lower :: Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_set_fmpz_lower"
mag_set_fmpz_lower :: Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_set_d_2exp_fmpz"
mag_set_d_2exp_fmpz :: Ptr CMag -> CDouble -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_set_fmpz_2exp_fmpz"
mag_set_fmpz_2exp_fmpz :: Ptr CMag -> Ptr CFmpz -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_set_ui_2exp_si"
mag_set_ui_2exp_si :: Ptr CMag -> CULong -> CLong -> IO ()
foreign import ccall "mag.h mag_set_d_2exp_fmpz_lower"
mag_set_d_2exp_fmpz_lower :: Ptr CMag -> CDouble -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_set_fmpz_2exp_fmpz_lower"
mag_set_fmpz_2exp_fmpz_lower :: Ptr CMag -> Ptr CFmpz -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_get_d"
mag_get_d :: Ptr CMag -> IO CDouble
foreign import ccall "mag.h mag_get_d_log2_approx"
mag_get_d_log2_approx :: Ptr CMag -> IO CDouble
foreign import ccall "mag.h mag_get_fmpq"
mag_get_fmpq :: Ptr CFmpq -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_get_fmpz"
mag_get_fmpz :: Ptr CFmpz -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_get_fmpz_lower"
mag_get_fmpz_lower :: Ptr CFmpz -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_equal"
mag_equal :: Ptr CMag -> Ptr CMag -> IO CInt
foreign import ccall "mag.h mag_cmp"
mag_cmp :: Ptr CMag -> Ptr CMag -> IO CInt
foreign import ccall "mag.h mag_cmp_2exp_si"
mag_cmp_2exp_si :: Ptr CMag -> CLong -> IO CInt
foreign import ccall "mag.h mag_min"
mag_min :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_max"
mag_max :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
mag_print :: Ptr CMag -> IO ()
mag_print Ptr CMag
x = do
CString
cs <- Ptr CMag -> IO CString
mag_get_str Ptr CMag
x
String
s <- CString -> IO String
peekCString CString
cs
CString -> IO ()
forall a. Ptr a -> IO ()
free CString
cs
String -> IO ()
putStr String
s
foreign import ccall "mag.h mag_fprint"
mag_fprint :: Ptr CFile -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_get_str"
mag_get_str :: Ptr CMag -> IO CString
foreign import ccall "mag.h mag_dump_str"
mag_dump_str :: Ptr CMag -> IO CString
foreign import ccall "mag.h mag_load_str"
mag_load_str :: Ptr CMag -> CString -> IO CInt
foreign import ccall "mag.h mag_dump_file"
mag_dump_file :: Ptr CFile -> Ptr CMag -> IO CInt
foreign import ccall "mag.h mag_load_file"
mag_load_file :: Ptr CMag -> Ptr CFile -> IO CInt
foreign import ccall "mag.h mag_randtest"
mag_randtest :: Ptr CMag -> Ptr CFRandState -> CLong -> IO ()
foreign import ccall "mag.h mag_randtest_special"
mag_randtest_special :: Ptr CMag -> Ptr CFRandState -> CLong -> IO ()
foreign import ccall "mag.h mag_add"
mag_add :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_add_ui"
mag_add_ui :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_add_lower"
mag_add_lower :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_add_ui_lower"
mag_add_ui_lower :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_add_2exp_fmpz"
mag_add_2exp_fmpz :: Ptr CMag -> Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_add_ui_2exp_si"
mag_add_ui_2exp_si :: Ptr CMag -> Ptr CMag -> CULong -> CLong -> IO ()
foreign import ccall "mag.h mag_sub"
mag_sub :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_sub_lower"
mag_sub_lower :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_mul_2exp_si"
mag_mul_2exp_si :: Ptr CMag -> Ptr CMag -> CLong -> IO ()
foreign import ccall "mag.h mag_mul_2exp_fmpz"
mag_mul_2exp_fmpz :: Ptr CMag -> Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_mul"
mag_mul :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_mul_ui"
mag_mul_ui :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_mul_fmpz"
mag_mul_fmpz :: Ptr CMag -> Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_mul_lower"
mag_mul_lower :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_mul_ui_lower"
mag_mul_ui_lower :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_mul_fmpz_lower"
mag_mul_fmpz_lower :: Ptr CMag -> Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_addmul"
mag_addmul :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_div"
mag_div :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_div_ui"
mag_div_ui :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_div_fmpz"
mag_div_fmpz :: Ptr CMag -> Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_div_lower"
mag_div_lower :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_inv"
mag_inv :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_inv_lower"
mag_inv_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_fast_init_set"
mag_fast_init_set :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_fast_zero"
mag_fast_zero :: Ptr CMag -> IO ()
foreign import ccall "mag.h mag_fast_is_zero"
mag_fast_is_zero :: Ptr CMag -> IO CInt
foreign import ccall "mag.h mag_fast_mul"
mag_fast_mul :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_fast_addmul"
mag_fast_addmul :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_fast_add_2exp_si"
mag_fast_add_2exp_si :: Ptr CMag -> Ptr CMag -> CLong -> IO ()
foreign import ccall "mag.h mag_fast_mul_2exp_si"
mag_fast_mul_2exp_si :: Ptr CMag -> Ptr CMag -> CLong -> IO ()
foreign import ccall "mag.h mag_pow_ui"
mag_pow_ui :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_pow_fmpz"
mag_pow_fmpz :: Ptr CMag -> Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_pow_ui_lower"
mag_pow_ui_lower :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_pow_fmpz_lower"
mag_pow_fmpz_lower :: Ptr CMag -> Ptr CMag -> Ptr CFmpz -> IO ()
foreign import ccall "mag.h mag_sqrt"
mag_sqrt :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_sqrt_lower"
mag_sqrt_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_rsqrt"
mag_rsqrt :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_rsqrt_lower"
mag_rsqrt_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_hypot"
mag_hypot :: Ptr CMag -> Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_root"
mag_root :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_log"
mag_log :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_log_lower"
mag_log_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_neg_log"
mag_neg_log :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_neg_log_lower"
mag_neg_log_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_log_ui"
mag_log_ui :: Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_log1p"
mag_log1p :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_exp"
mag_exp :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_exp_lower"
mag_exp_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_expinv"
mag_expinv :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_expinv_lower"
mag_expinv_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_expm1"
mag_expm1 :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_exp_tail"
mag_exp_tail :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_binpow_uiui"
mag_binpow_uiui :: Ptr CMag -> CULong -> CULong -> IO ()
foreign import ccall "mag.h mag_geom_series"
mag_geom_series :: Ptr CMag -> Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_const_pi"
mag_const_pi :: Ptr CMag -> IO ()
foreign import ccall "mag.h mag_const_pi_lower"
mag_const_pi_lower :: Ptr CMag -> IO ()
foreign import ccall "mag.h mag_atan"
mag_atan :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_atan_lower"
mag_atan_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_cosh"
mag_cosh :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_cosh_lower"
mag_cosh_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_sinh"
mag_sinh :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_sinh_lower"
mag_sinh_lower :: Ptr CMag -> Ptr CMag -> IO ()
foreign import ccall "mag.h mag_fac_ui"
mag_fac_ui :: Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_rfac_ui"
mag_rfac_ui :: Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_bin_uiui"
mag_bin_uiui :: Ptr CMag -> CULong -> CULong -> IO ()
foreign import ccall "mag.h mag_bernoulli_div_fac_ui"
mag_bernoulli_div_fac_ui :: Ptr CMag -> CULong -> IO ()
foreign import ccall "mag.h mag_polylog_tail"
mag_polylog_tail :: Ptr CMag -> Ptr CMag -> CLong -> CULong -> CULong -> IO ()
foreign import ccall "mag.h mag_hurwitz_zeta_uiui"
mag_hurwitz_zeta_uiui :: Ptr CMag -> CULong -> CULong -> IO ()