{-# LINE 1 "src/Data/Number/Flint/Qadic/FFI.hsc" #-}
module Data.Number.Flint.Qadic.FFI (
Qadic (..)
, CQadic (..)
, newQadic
, withQadic
, withNewQadic
, newQadicWithPrec
, withNewQadicWithPrec
, QadicCtx (..)
, CQadicCtx (..)
, newQadicCtx
, newQadicCtxConway
, withQadicCtx
, withNewQadicCtx
, withNewQadicCtxConway
, qadic_ctx_init
, qadic_ctx_init_conway
, qadic_ctx_clear
, qadic_ctx_degree
, qadic_ctx_print
, qadic_init
, qadic_init2
, qadic_clear
, _fmpz_poly_reduce
, _fmpz_mod_poly_reduce
, qadic_reduce
, qadic_val
, qadic_prec
, qadic_randtest
, qadic_randtest_not_zero
, qadic_randtest_val
, qadic_randtest_int
, qadic_set
, qadic_zero
, qadic_one
, qadic_gen
, qadic_set_ui
, qadic_get_padic
, qadic_is_zero
, qadic_is_one
, qadic_equal
, qadic_add
, qadic_sub
, qadic_neg
, qadic_mul
, _qadic_inv
, qadic_inv
, _qadic_pow
, qadic_pow
, qadic_sqrt
, _qadic_exp_rectangular
, qadic_exp_rectangular
, _qadic_exp_balanced
, qadic_exp_balanced
, _qadic_exp
, qadic_exp
, _qadic_log_rectangular
, qadic_log_rectangular
, _qadic_log_balanced
, qadic_log_balanced
, _qadic_log
, qadic_log
, _qadic_frobenius_a
, _qadic_frobenius
, qadic_frobenius
, _qadic_teichmuller
, qadic_teichmuller
, _qadic_trace
, _qadic_norm
, qadic_norm
, qadic_norm_analytic
, qadic_norm_resultant
, qadic_fprint_pretty
, qadic_print_pretty
) where
import Control.Monad
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 Foreign.Marshal.Array
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Fmpz.Vec
import Data.Number.Flint.Fmpq
import Data.Number.Flint.Padic
import Data.Number.Flint.Padic.Poly
data Qadic = Qadic {-# UNPACK #-} !(ForeignPtr CQadic)
type CQadic = CPadicPoly
newQadic :: IO Qadic
newQadic = do
ForeignPtr CQadic
x <- IO (ForeignPtr CQadic)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CQadic -> (Ptr CQadic -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CQadic
x Ptr CQadic -> IO ()
qadic_init
FinalizerPtr CQadic -> ForeignPtr CQadic -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CQadic
p_qadic_clear ForeignPtr CQadic
x
Qadic -> IO Qadic
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Qadic -> IO Qadic) -> Qadic -> IO Qadic
forall a b. (a -> b) -> a -> b
$ ForeignPtr CQadic -> Qadic
Qadic ForeignPtr CQadic
x
{-# INLINE withQadic #-}
withQadic :: Qadic -> (Ptr CQadic -> IO a) -> IO (Qadic, a)
withQadic (Qadic ForeignPtr CQadic
x) Ptr CQadic -> IO a
f = do
ForeignPtr CQadic -> (Ptr CQadic -> IO (Qadic, a)) -> IO (Qadic, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CQadic
x ((Ptr CQadic -> IO (Qadic, a)) -> IO (Qadic, a))
-> (Ptr CQadic -> IO (Qadic, a)) -> IO (Qadic, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CQadic
px -> Ptr CQadic -> IO a
f Ptr CQadic
px IO a -> (a -> IO (Qadic, a)) -> IO (Qadic, a)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Qadic, a) -> IO (Qadic, a)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Qadic, a) -> IO (Qadic, a))
-> (a -> (Qadic, a)) -> a -> IO (Qadic, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForeignPtr CQadic -> Qadic
Qadic ForeignPtr CQadic
x,)
{-# INLINE withNewQadic #-}
withNewQadic :: (Ptr CQadic -> IO a) -> IO (Qadic, a)
withNewQadic Ptr CQadic -> IO a
f = do
Qadic
x <- IO Qadic
newQadic
Qadic -> (Ptr CQadic -> IO a) -> IO (Qadic, a)
forall {a}. Qadic -> (Ptr CQadic -> IO a) -> IO (Qadic, a)
withQadic Qadic
x Ptr CQadic -> IO a
f
newQadicWithPrec :: CLong -> IO Qadic
newQadicWithPrec CLong
prec = do
ForeignPtr CQadic
x <- IO (ForeignPtr CQadic)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CQadic -> (Ptr CQadic -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CQadic
x ((Ptr CQadic -> IO ()) -> IO ()) -> (Ptr CQadic -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CQadic
x -> Ptr CQadic -> CLong -> IO ()
qadic_init2 Ptr CQadic
x CLong
prec
FinalizerPtr CQadic -> ForeignPtr CQadic -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CQadic
p_qadic_clear ForeignPtr CQadic
x
Qadic -> IO Qadic
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Qadic -> IO Qadic) -> Qadic -> IO Qadic
forall a b. (a -> b) -> a -> b
$ ForeignPtr CQadic -> Qadic
Qadic ForeignPtr CQadic
x
{-# INLINE withNewQadicWithPrec #-}
withNewQadicWithPrec :: CLong -> (Ptr CQadic -> IO a) -> IO (Qadic, a)
withNewQadicWithPrec CLong
prec Ptr CQadic -> IO a
f = do
Qadic
x <- CLong -> IO Qadic
newQadicWithPrec CLong
prec
Qadic -> (Ptr CQadic -> IO a) -> IO (Qadic, a)
forall {a}. Qadic -> (Ptr CQadic -> IO a) -> IO (Qadic, a)
withQadic Qadic
x Ptr CQadic -> IO a
f
data QadicCtx = QadicCtx {-# UNPACK #-} !(ForeignPtr CQadicCtx)
data CQadicCtx = CQadicCtx (Ptr CPadicCtx) (Ptr CFmpz) (Ptr CLong) CLong CString
instance Storable CQadicCtx where
{-# INLINE sizeOf #-}
sizeOf :: CQadicCtx -> Int
sizeOf CQadicCtx
_ = (Int
80)
{-# LINE 183 "src/Data/Number/Flint/Qadic/FFI.hsc" #-}
{-# INLINE alignment #-}
alignment :: CQadicCtx -> Int
alignment CQadicCtx
_ = Int
8
{-# LINE 185 "src/Data/Number/Flint/Qadic/FFI.hsc" #-}
peek ptr = return CQadicCtx
`ap` (return $ castPtr ptr)
`ap` (\hsc_ptr -> peekByteOff hsc_ptr 48) ptr
{-# LINE 188 "src/Data/Number/Flint/Qadic/FFI.hsc" #-}
`ap` (\hsc_ptr -> peekByteOff hsc_ptr 56) ptr
{-# LINE 189 "src/Data/Number/Flint/Qadic/FFI.hsc" #-}
`ap` (\hsc_ptr -> peekByteOff hsc_ptr 64) ptr
{-# LINE 190 "src/Data/Number/Flint/Qadic/FFI.hsc" #-}
`ap` (\hsc_ptr -> peekByteOff hsc_ptr 72) ptr
{-# LINE 191 "src/Data/Number/Flint/Qadic/FFI.hsc" #-}
poke = undefined
{-# INLINE _newQadicCtx #-}
_newQadicCtx :: (Ptr CQadicCtx -> Ptr CFmpz -> t -> t -> t -> CString -> t -> IO a)
-> Fmpz -> t -> t -> t -> String -> t -> IO QadicCtx
_newQadicCtx Ptr CQadicCtx -> Ptr CFmpz -> t -> t -> t -> CString -> t -> IO a
f Fmpz
p t
d t
min t
max String
var t
mode = do
ForeignPtr CQadicCtx
x <- IO (ForeignPtr CQadicCtx)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
ForeignPtr CQadicCtx
-> (Ptr CQadicCtx -> IO (Fmpz, a)) -> IO (Fmpz, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CQadicCtx
x ((Ptr CQadicCtx -> IO (Fmpz, a)) -> IO (Fmpz, a))
-> (Ptr CQadicCtx -> IO (Fmpz, a)) -> IO (Fmpz, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CQadicCtx
x -> do
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 -> do
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 CQadicCtx -> Ptr CFmpz -> t -> t -> t -> CString -> t -> IO a
f Ptr CQadicCtx
x Ptr CFmpz
p t
d t
min t
max CString
var t
mode
FinalizerPtr CQadicCtx -> ForeignPtr CQadicCtx -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr CQadicCtx
p_qadic_ctx_clear ForeignPtr CQadicCtx
x
QadicCtx -> IO QadicCtx
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (QadicCtx -> IO QadicCtx) -> QadicCtx -> IO QadicCtx
forall a b. (a -> b) -> a -> b
$ ForeignPtr CQadicCtx -> QadicCtx
QadicCtx ForeignPtr CQadicCtx
x
newQadicCtx :: Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> IO QadicCtx
newQadicCtx = (Ptr CQadicCtx
-> Ptr CFmpz
-> CLong
-> CLong
-> CLong
-> CString
-> PadicPrintMode
-> IO ())
-> Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> IO QadicCtx
forall {t} {t} {t} {t} {a}.
(Ptr CQadicCtx -> Ptr CFmpz -> t -> t -> t -> CString -> t -> IO a)
-> Fmpz -> t -> t -> t -> String -> t -> IO QadicCtx
_newQadicCtx Ptr CQadicCtx
-> Ptr CFmpz
-> CLong
-> CLong
-> CLong
-> CString
-> PadicPrintMode
-> IO ()
qadic_ctx_init
newQadicCtxConway :: Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> IO QadicCtx
newQadicCtxConway = (Ptr CQadicCtx
-> Ptr CFmpz
-> CLong
-> CLong
-> CLong
-> CString
-> PadicPrintMode
-> IO ())
-> Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> IO QadicCtx
forall {t} {t} {t} {t} {a}.
(Ptr CQadicCtx -> Ptr CFmpz -> t -> t -> t -> CString -> t -> IO a)
-> Fmpz -> t -> t -> t -> String -> t -> IO QadicCtx
_newQadicCtx Ptr CQadicCtx
-> Ptr CFmpz
-> CLong
-> CLong
-> CLong
-> CString
-> PadicPrintMode
-> IO ()
qadic_ctx_init_conway
{-# INLINE withQadicCtx #-}
withQadicCtx :: QadicCtx -> (Ptr CQadicCtx -> IO a) -> IO (QadicCtx, a)
withQadicCtx (QadicCtx ForeignPtr CQadicCtx
x) Ptr CQadicCtx -> IO a
f = do
ForeignPtr CQadicCtx
-> (Ptr CQadicCtx -> IO (QadicCtx, a)) -> IO (QadicCtx, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CQadicCtx
x ((Ptr CQadicCtx -> IO (QadicCtx, a)) -> IO (QadicCtx, a))
-> (Ptr CQadicCtx -> IO (QadicCtx, a)) -> IO (QadicCtx, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CQadicCtx
px -> Ptr CQadicCtx -> IO a
f Ptr CQadicCtx
px IO a -> (a -> IO (QadicCtx, a)) -> IO (QadicCtx, a)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (QadicCtx, a) -> IO (QadicCtx, a)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((QadicCtx, a) -> IO (QadicCtx, a))
-> (a -> (QadicCtx, a)) -> a -> IO (QadicCtx, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForeignPtr CQadicCtx -> QadicCtx
QadicCtx ForeignPtr CQadicCtx
x,)
_withNewQadicCtx :: (t -> t -> t -> t -> t -> t -> IO QadicCtx)
-> t
-> t
-> t
-> t
-> t
-> t
-> (Ptr CQadicCtx -> IO a)
-> IO (QadicCtx, a)
_withNewQadicCtx t -> t -> t -> t -> t -> t -> IO QadicCtx
initialize t
p t
d t
min t
max t
var t
mode Ptr CQadicCtx -> IO a
f = do
QadicCtx
x <- t -> t -> t -> t -> t -> t -> IO QadicCtx
initialize t
p t
d t
min t
max t
var t
mode
QadicCtx -> (Ptr CQadicCtx -> IO a) -> IO (QadicCtx, a)
forall {a}. QadicCtx -> (Ptr CQadicCtx -> IO a) -> IO (QadicCtx, a)
withQadicCtx QadicCtx
x Ptr CQadicCtx -> IO a
f
withNewQadicCtx :: Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> (Ptr CQadicCtx -> IO a)
-> IO (QadicCtx, a)
withNewQadicCtx = (Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> IO QadicCtx)
-> Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> (Ptr CQadicCtx -> IO a)
-> IO (QadicCtx, a)
forall {t} {t} {t} {t} {t} {t} {a}.
(t -> t -> t -> t -> t -> t -> IO QadicCtx)
-> t
-> t
-> t
-> t
-> t
-> t
-> (Ptr CQadicCtx -> IO a)
-> IO (QadicCtx, a)
_withNewQadicCtx Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> IO QadicCtx
newQadicCtx
withNewQadicCtxConway :: Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> (Ptr CQadicCtx -> IO a)
-> IO (QadicCtx, a)
withNewQadicCtxConway = (Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> IO QadicCtx)
-> Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> (Ptr CQadicCtx -> IO a)
-> IO (QadicCtx, a)
forall {t} {t} {t} {t} {t} {t} {a}.
(t -> t -> t -> t -> t -> t -> IO QadicCtx)
-> t
-> t
-> t
-> t
-> t
-> t
-> (Ptr CQadicCtx -> IO a)
-> IO (QadicCtx, a)
_withNewQadicCtx Fmpz
-> CLong
-> CLong
-> CLong
-> String
-> PadicPrintMode
-> IO QadicCtx
newQadicCtxConway
foreign import ccall "qadic.h qadic_ctx_init"
qadic_ctx_init :: Ptr CQadicCtx -> Ptr CFmpz -> CLong -> CLong -> CLong -> CString -> PadicPrintMode -> IO ()
foreign import ccall "qadic.h qadic_ctx_init_conway"
qadic_ctx_init_conway :: Ptr CQadicCtx -> Ptr CFmpz -> CLong -> CLong -> CLong -> CString -> PadicPrintMode -> IO ()
foreign import ccall "qadic.h qadic_ctx_clear"
qadic_ctx_clear :: Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h &qadic_ctx_clear"
p_qadic_ctx_clear :: FunPtr (Ptr CQadicCtx -> IO ())
foreign import ccall "qadic.h qadic_ctx_degree"
qadic_ctx_degree :: Ptr CQadicCtx -> IO CLong
qadic_ctx_print :: Ptr CQadicCtx -> IO ()
qadic_ctx_print Ptr CQadicCtx
ctx = do
CQadicCtx Ptr CPadicCtx
pctx Ptr CFmpz
a Ptr CLong
j CLong
len CString
var <- Ptr CQadicCtx -> IO CQadicCtx
forall a. Storable a => Ptr a -> IO a
peek Ptr CQadicCtx
ctx
CPadicCtx Ptr CFmpz
p CDouble
_ Ptr CFmpz
_ CLong
_ CLong
_ PadicPrintMode
mode <- Ptr CPadicCtx -> IO CPadicCtx
forall a. Storable a => Ptr a -> IO a
peek Ptr CPadicCtx
pctx
String -> IO ()
putStr String
"p = "
Ptr CFmpz -> IO CInt
fmpz_print Ptr CFmpz
p
String -> IO ()
putStr String
"\n"
CLong
d <- Ptr CLong -> IO CLong
forall a. Storable a => Ptr a -> IO a
peek (Ptr CLong
j Ptr CLong -> Int -> Ptr CLong
forall a. Storable a => Ptr a -> Int -> Ptr a
`advancePtr` (CLong -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CLong
len Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1))
String -> IO ()
putStrLn (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ String
"d = " String -> String -> String
forall a. [a] -> [a] -> [a]
++ CLong -> String
forall a. Show a => a -> String
show CLong
d
String -> IO ()
putStr String
"f(X) = "
Ptr CFmpz -> IO CInt
fmpz_print Ptr CFmpz
a
[Int] -> (Int -> IO ()) -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [Int
1 .. CLong -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CLong
len Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1] ((Int -> IO ()) -> IO ()) -> (Int -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Int
k -> do
CLong
i <- Ptr CLong -> IO CLong
forall a. Storable a => Ptr a -> IO a
peek (Ptr CLong
j Ptr CLong -> Int -> Ptr CLong
forall a. Storable a => Ptr a -> Int -> Ptr a
`advancePtr` Int
k)
CInt
flag1 <- Ptr CFmpz -> IO CInt
fmpz_is_zero (Ptr CFmpz
a Ptr CFmpz -> Int -> Ptr CFmpz
forall a. Storable a => Ptr a -> Int -> Ptr a
`advancePtr` Int
k)
case CInt
flag1 of
CInt
1 -> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
CInt
_ -> do
String -> IO ()
putStr String
" + "
CInt
flag <- Ptr CFmpz -> IO CInt
fmpz_is_one (Ptr CFmpz
a Ptr CFmpz -> Int -> Ptr CFmpz
forall a. Storable a => Ptr a -> Int -> Ptr a
`advancePtr` Int
k)
case CInt
flag of
CInt
1 -> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
CInt
_ -> do
Ptr CFmpz -> IO CInt
fmpz_print (Ptr CFmpz
a Ptr CFmpz -> Int -> Ptr CFmpz
forall a. Storable a => Ptr a -> Int -> Ptr a
`advancePtr` Int
k)
String -> IO ()
putStr String
"*"
String -> IO ()
putStr String
"X"
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ( CLong
i CLong -> CLong -> Bool
forall a. Eq a => a -> a -> Bool
/= CLong
1 ) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
putStr (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ String
"^" String -> String -> String
forall a. [a] -> [a] -> [a]
++ CLong -> String
forall a. Show a => a -> String
show CLong
i
foreign import ccall "qadic.h qadic_init"
qadic_init :: Ptr CQadic -> IO ()
foreign import ccall "qadic.h qadic_init2"
qadic_init2 :: Ptr CQadic -> CLong -> IO ()
foreign import ccall "qadic.h qadic_clear"
qadic_clear :: Ptr CQadic -> IO ()
foreign import ccall "qadic.h &qadic_clear"
p_qadic_clear :: FunPtr (Ptr CQadic -> IO ())
foreign import ccall "qadic.h _fmpz_poly_reduce"
_fmpz_poly_reduce :: Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> IO ()
foreign import ccall "qadic.h _fmpz_mod_poly_reduce"
_fmpz_mod_poly_reduce :: Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> IO ()
foreign import ccall "qadic.h qadic_reduce"
qadic_reduce :: Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_val"
qadic_val :: Ptr CQadic -> IO CLong
foreign import ccall "qadic.h qadic_prec"
qadic_prec :: Ptr CQadic -> IO CLong
foreign import ccall "qadic.h qadic_randtest"
qadic_randtest :: Ptr CQadic -> Ptr CFRandState -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_randtest_not_zero"
qadic_randtest_not_zero :: Ptr CQadic -> Ptr CFRandState -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_randtest_val"
qadic_randtest_val :: Ptr CQadic -> Ptr CFRandState -> CLong -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_randtest_int"
qadic_randtest_int :: Ptr CQadic -> Ptr CFRandState -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_set"
qadic_set :: Ptr CQadic -> Ptr CQadic -> IO ()
foreign import ccall "qadic.h qadic_zero"
qadic_zero :: Ptr CQadic -> IO ()
foreign import ccall "qadic.h qadic_one"
qadic_one :: Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_gen"
qadic_gen :: Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_set_ui"
qadic_set_ui :: Ptr CQadic -> CULong -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_get_padic"
qadic_get_padic :: Ptr CPadic -> Ptr CQadic -> Ptr CQadicCtx -> IO CInt
foreign import ccall "qadic.h qadic_is_zero"
qadic_is_zero :: Ptr CQadic -> IO CInt
foreign import ccall "qadic.h qadic_is_one"
qadic_is_one :: Ptr CQadic -> Ptr CQadicCtx -> IO CInt
foreign import ccall "qadic.h qadic_equal"
qadic_equal :: Ptr CQadic -> Ptr CQadic -> IO CInt
foreign import ccall "qadic.h qadic_add"
qadic_add :: Ptr CQadic -> Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_sub"
qadic_sub :: Ptr CQadic -> Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_neg"
qadic_neg :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_mul"
qadic_mul :: Ptr CQadic -> Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h _qadic_inv"
_qadic_inv :: Ptr CFmpz -> Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> IO ()
foreign import ccall "qadic.h qadic_inv"
qadic_inv :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h _qadic_pow"
_qadic_pow :: Ptr CFmpz -> Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> IO ()
foreign import ccall "qadic.h qadic_pow"
qadic_pow :: Ptr CQadic -> Ptr CQadic -> Ptr CFmpz -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_sqrt"
qadic_sqrt :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO CInt
foreign import ccall "qadic.h _qadic_exp_rectangular"
_qadic_exp_rectangular :: Ptr CFmpz -> Ptr CFmpz -> CLong -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> Ptr CFmpz -> IO ()
foreign import ccall "qadic.h qadic_exp_rectangular"
qadic_exp_rectangular :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO CInt
foreign import ccall "qadic.h _qadic_exp_balanced"
_qadic_exp_balanced :: Ptr CFmpz -> Ptr CFmpz -> CLong -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> Ptr CFmpz -> IO ()
foreign import ccall "qadic.h qadic_exp_balanced"
qadic_exp_balanced :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO CInt
foreign import ccall "qadic.h _qadic_exp"
_qadic_exp :: Ptr CFmpz -> Ptr CFmpz -> CLong -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> IO ()
foreign import ccall "qadic.h qadic_exp"
qadic_exp :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO CInt
foreign import ccall "qadic.h _qadic_log_rectangular"
_qadic_log_rectangular :: Ptr CFmpz -> Ptr CFmpz -> CLong -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> Ptr CFmpz -> IO ()
foreign import ccall "qadic.h qadic_log_rectangular"
qadic_log_rectangular :: Ptr CQadic -> Ptr CQadic -> Ptr CPadicCtx -> IO CInt
foreign import ccall "qadic.h _qadic_log_balanced"
_qadic_log_balanced :: Ptr CFmpz -> Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> Ptr CFmpz -> IO ()
foreign import ccall "qadic.h qadic_log_balanced"
qadic_log_balanced :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO CInt
foreign import ccall "qadic.h _qadic_log"
_qadic_log :: Ptr CFmpz -> Ptr CFmpz -> CLong -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> Ptr CFmpz -> IO ()
foreign import ccall "qadic.h qadic_log"
qadic_log :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO CInt
foreign import ccall "qadic.h _qadic_frobenius_a"
_qadic_frobenius_a :: Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> IO ()
foreign import ccall "qadic.h _qadic_frobenius"
_qadic_frobenius :: Ptr CFmpz -> Ptr CFmpz -> CLong -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> IO ()
foreign import ccall "qadic.h qadic_frobenius"
qadic_frobenius :: Ptr CQadic -> Ptr CQadic -> CLong -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h _qadic_teichmuller"
_qadic_teichmuller :: Ptr CFmpz -> Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> IO ()
foreign import ccall "qadic.h qadic_teichmuller"
qadic_teichmuller :: Ptr CQadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h _qadic_trace"
_qadic_trace :: Ptr CFmpz -> Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> IO ()
foreign import ccall "qadic.h _qadic_norm"
_qadic_norm :: Ptr CFmpz -> Ptr CFmpz -> CLong -> Ptr CFmpz -> Ptr CLong -> CLong -> Ptr CFmpz -> CLong -> IO ()
foreign import ccall "qadic.h qadic_norm"
qadic_norm :: Ptr CPadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_norm_analytic"
qadic_norm_analytic :: Ptr CPadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_norm_resultant"
qadic_norm_resultant :: Ptr CPadic -> Ptr CQadic -> Ptr CQadicCtx -> IO ()
foreign import ccall "qadic.h qadic_fprint_pretty"
qadic_fprint_pretty :: Ptr CFile -> Ptr CQadic -> Ptr CQadicCtx -> IO CInt
qadic_print_pretty :: Ptr CQadic -> Ptr CQadicCtx -> IO CInt
qadic_print_pretty Ptr CQadic
x Ptr CQadicCtx
ctx = (Ptr CQadic -> IO CString) -> Ptr CQadic -> IO CInt
forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr ((Ptr CQadic -> Ptr CQadicCtx -> IO CString)
-> Ptr CQadicCtx -> Ptr CQadic -> IO CString
forall a b c. (a -> b -> c) -> b -> a -> c
flip Ptr CQadic -> Ptr CQadicCtx -> IO CString
qadic_get_str_pretty Ptr CQadicCtx
ctx) Ptr CQadic
x
foreign import ccall "qadic_get_str_pretty"
qadic_get_str_pretty :: Ptr CQadic -> Ptr CQadicCtx -> IO CString