{-# LINE 1 "src/Data/Number/Flint/Calcium/Ca/Ext/FFI.hsc" #-}
module Data.Number.Flint.Calcium.Ca.Ext.FFI (
  -- * Real and complex extension numbers
  -- * Type and macros
    CaExt (..)
  , CCaExt (..)
  , newCaExtQQbar
  , newCaExtConst
  , newCaExtFx
  , newCaExtFxy
  , newCaExtFxn
  , withCaExt
  -- * Memory management
  , ca_ext_init_qqbar
  , ca_ext_init_const
  , ca_ext_init_fx
  , ca_ext_init_fxy
  , ca_ext_init_fxn
  , ca_ext_init_set
  , ca_ext_clear
  -- * Structure
  , ca_ext_nargs
  , ca_ext_get_arg
  , ca_ext_hash
  , ca_ext_equal_repr
  , ca_ext_cmp_repr
  -- * Input and output
  , ca_ext_print
  -- * Numerical evaluation
  , ca_ext_get_acb_raw
  -- * Cache
  , ca_ext_cache_init
  , ca_ext_cache_clear
  , ca_ext_cache_insert
) where 

-- Real and complex extension numbers ------------------------------------------

import Foreign.Ptr
import Foreign.ForeignPtr
import Foreign.C.Types
import Foreign.C.String
import Foreign.Storable
import Foreign.Marshal.Array

import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Acb.Types
import Data.Number.Flint.NF.QQbar
import Data.Number.Flint.Calcium
import Data.Number.Flint.Calcium.Ca
import Data.Number.Flint.Calcium.Ca.Types



-- ca_ext_t --------------------------------------------------------------------

instance Storable CCaExt where
  {-# INLINE sizeOf #-}
  sizeOf :: CCaExt -> Int
sizeOf CCaExt
_ = (Int
152)
{-# LINE 60 "src/Data/Number/Flint/Calcium/Ca/Ext/FFI.hsc" #-}
  {-# INLINE alignment #-}
  alignment :: CCaExt -> Int
alignment CCaExt
_ = Int
8
{-# LINE 62 "src/Data/Number/Flint/Calcium/Ca/Ext/FFI.hsc" #-}
  peek = error "CCaExt.peek: Not defined"
  poke :: Ptr CCaExt -> CCaExt -> IO ()
poke = [Char] -> Ptr CCaExt -> CCaExt -> IO ()
forall a. HasCallStack => [Char] -> a
error [Char]
"CCaExt.poke: Not defined"

newCaExtQQbar :: QQbar -> CaCtx -> IO CaExt
newCaExtQQbar QQbar
x ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
  ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
  ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
    CaCtx -> (Ptr CCaCtx -> IO (QQbar, ())) -> IO (CaCtx, (QQbar, ()))
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO (QQbar, ())) -> IO (CaCtx, (QQbar, ())))
-> (Ptr CCaCtx -> IO (QQbar, ())) -> IO (CaCtx, (QQbar, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
      QQbar -> (Ptr CQQbar -> IO ()) -> IO (QQbar, ())
forall {a}. QQbar -> (Ptr CQQbar -> IO a) -> IO (QQbar, a)
withQQbar QQbar
x ((Ptr CQQbar -> IO ()) -> IO (QQbar, ()))
-> (Ptr CQQbar -> IO ()) -> IO (QQbar, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CQQbar
xp -> do
        Ptr CCaExt -> Ptr CQQbar -> Ptr CCaCtx -> IO ()
ca_ext_init_qqbar Ptr CCaExt
resp Ptr CQQbar
xp Ptr CCaCtx
ctxp
    FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
  CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res

newCaExtConst :: CCalciumFunctionCode -> CaCtx -> IO CaExt
newCaExtConst CCalciumFunctionCode
fc ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
  ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
  ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
    CaCtx -> (Ptr CCaCtx -> IO ()) -> IO (CaCtx, ())
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO ()) -> IO (CaCtx, ()))
-> (Ptr CCaCtx -> IO ()) -> IO (CaCtx, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
      Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCaCtx -> IO ()
ca_ext_init_const Ptr CCaExt
resp CCalciumFunctionCode
fc Ptr CCaCtx
ctxp
    FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
  CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res

newCaExtFx :: CCalciumFunctionCode -> Ca -> CaCtx -> IO CaExt
newCaExtFx CCalciumFunctionCode
fx Ca
x ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
  ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
  ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
    CaCtx -> (Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ()))
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ())))
-> (Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
      Ca -> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall {a}. Ca -> (Ptr CCa -> IO a) -> IO (Ca, a)
withCa Ca
x ((Ptr CCa -> IO ()) -> IO (Ca, ()))
-> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CCa
x -> do
        Ptr CCaExt
-> CCalciumFunctionCode -> Ptr CCa -> Ptr CCaCtx -> IO ()
ca_ext_init_fx Ptr CCaExt
resp CCalciumFunctionCode
fx Ptr CCa
x Ptr CCaCtx
ctxp
    FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
  CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res

newCaExtFxy :: CCalciumFunctionCode -> Ca -> Ca -> CaCtx -> IO CaExt
newCaExtFxy CCalciumFunctionCode
fxy Ca
x Ca
y ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
  ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
  ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
    CaCtx
-> (Ptr CCaCtx -> IO (Ca, (Ca, ()))) -> IO (CaCtx, (Ca, (Ca, ())))
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO (Ca, (Ca, ()))) -> IO (CaCtx, (Ca, (Ca, ()))))
-> (Ptr CCaCtx -> IO (Ca, (Ca, ()))) -> IO (CaCtx, (Ca, (Ca, ())))
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
      Ca -> (Ptr CCa -> IO (Ca, ())) -> IO (Ca, (Ca, ()))
forall {a}. Ca -> (Ptr CCa -> IO a) -> IO (Ca, a)
withCa Ca
x ((Ptr CCa -> IO (Ca, ())) -> IO (Ca, (Ca, ())))
-> (Ptr CCa -> IO (Ca, ())) -> IO (Ca, (Ca, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CCa
x -> do
        Ca -> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall {a}. Ca -> (Ptr CCa -> IO a) -> IO (Ca, a)
withCa Ca
y ((Ptr CCa -> IO ()) -> IO (Ca, ()))
-> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CCa
y -> do
          Ptr CCaExt
-> CCalciumFunctionCode
-> Ptr CCa
-> Ptr CCa
-> Ptr CCaCtx
-> IO ()
ca_ext_init_fxy Ptr CCaExt
resp CCalciumFunctionCode
fxy Ptr CCa
x Ptr CCa
y Ptr CCaCtx
ctxp
    FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
  CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res

newCaExtFxn :: CCalciumFunctionCode -> Ca -> CLong -> CaCtx -> IO CaExt
newCaExtFxn CCalciumFunctionCode
fxn Ca
x CLong
nargs ctx :: CaCtx
ctx@(CaCtx ForeignPtr CCaCtx
ctxf) = do
  ForeignPtr CCaExt
res <- IO (ForeignPtr CCaExt)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
  ForeignPtr CCaExt -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
res ((Ptr CCaExt -> IO ()) -> IO ()) -> (Ptr CCaExt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
resp -> do
    CaCtx -> (Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ()))
forall {a}. CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a)
withCaCtx CaCtx
ctx ((Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ())))
-> (Ptr CCaCtx -> IO (Ca, ())) -> IO (CaCtx, (Ca, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CCaCtx
ctxp -> do
      Ca -> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall {a}. Ca -> (Ptr CCa -> IO a) -> IO (Ca, a)
withCa Ca
x ((Ptr CCa -> IO ()) -> IO (Ca, ()))
-> (Ptr CCa -> IO ()) -> IO (Ca, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CCa
x -> do
        Ptr CCaExt
-> CCalciumFunctionCode -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()
ca_ext_init_fxn Ptr CCaExt
resp CCalciumFunctionCode
fxn Ptr CCa
x CLong
nargs Ptr CCaCtx
ctxp
    FinalizerEnvPtr CCaExt CCaCtx
-> Ptr CCaExt -> ForeignPtr CCaCtx -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
addForeignPtrFinalizerEnv FinalizerEnvPtr CCaExt CCaCtx
p_ca_ext_clear Ptr CCaExt
resp ForeignPtr CCaCtx
ctxf
  CaExt -> IO CaExt
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CaExt -> IO CaExt) -> CaExt -> IO CaExt
forall a b. (a -> b) -> a -> b
$ ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
res

withCaExt :: CaExt -> (Ptr CCaExt -> IO a) -> IO (CaExt, a)
withCaExt (CaExt ForeignPtr CCaExt
x) Ptr CCaExt -> IO a
f = do
  ForeignPtr CCaExt -> (Ptr CCaExt -> IO (CaExt, a)) -> IO (CaExt, a)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr CCaExt
x ((Ptr CCaExt -> IO (CaExt, a)) -> IO (CaExt, a))
-> (Ptr CCaExt -> IO (CaExt, a)) -> IO (CaExt, a)
forall a b. (a -> b) -> a -> b
$ \Ptr CCaExt
px -> Ptr CCaExt -> IO a
f Ptr CCaExt
px IO a -> (a -> IO (CaExt, a)) -> IO (CaExt, a)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (CaExt, a) -> IO (CaExt, a)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((CaExt, a) -> IO (CaExt, a))
-> (a -> (CaExt, a)) -> a -> IO (CaExt, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForeignPtr CCaExt -> CaExt
CaExt ForeignPtr CCaExt
x,)

-- Memory management -----------------------------------------------------------

-- | /ca_ext_init_qqbar/ /res/ /x/ /ctx/ 
--
-- Initializes /res/ and sets it to the algebraic constant /x/.
foreign import ccall "ca_ext.h ca_ext_init_qqbar"
  ca_ext_init_qqbar :: Ptr CCaExt -> Ptr CQQbar -> Ptr CCaCtx -> IO ()

-- | /ca_ext_init_const/ /res/ /func/ /ctx/ 
--
-- Initializes /res/ and sets it to the constant defined by /func/
-- (example: /func/ = /CA_Pi/ for \(x = \pi\)).
foreign import ccall "ca_ext.h ca_ext_init_const"
  ca_ext_init_const :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCaCtx -> IO ()

-- | /ca_ext_init_fx/ /res/ /func/ /x/ /ctx/ 
--
-- Initializes /res/ and sets it to the univariate function value \(f(x)\)
-- where /f/ is defined by /func/ (example: /func/ = /CA_Exp/ for \(e^x\)).
foreign import ccall "ca_ext.h ca_ext_init_fx"
  ca_ext_init_fx :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> Ptr CCaCtx -> IO ()

-- | /ca_ext_init_fxy/ /res/ /func/ /x/ /y/ /ctx/ 
--
-- Initializes /res/ and sets it to the bivariate function value
-- \(f(x, y)\) where /f/ is defined by /func/ (example: /func/ = /CA_Pow/
-- for \(x^y\)).
foreign import ccall "ca_ext.h ca_ext_init_fxy"
  ca_ext_init_fxy :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO ()

-- | /ca_ext_init_fxn/ /res/ /func/ /x/ /nargs/ /ctx/ 
--
-- Initializes /res/ and sets it to the multivariate function value
-- \(f(x_1, \ldots, x_n)\) where /f/ is defined by /func/ and /n/ is given
-- by /nargs/.
foreign import ccall "ca_ext.h ca_ext_init_fxn"
  ca_ext_init_fxn :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO ()

-- | /ca_ext_init_set/ /res/ /x/ /ctx/ 
--
-- Initializes /res/ and sets it to a copy of /x/.
foreign import ccall "ca_ext.h ca_ext_init_set"
  ca_ext_init_set :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO ()

-- | /ca_ext_clear/ /res/ /ctx/ 
--
-- Clears /res/.
foreign import ccall "ca_ext.h ca_ext_clear"
  ca_ext_clear :: Ptr CCaExt -> Ptr CCaCtx -> IO ()

foreign import ccall "ca_ext.h &ca_ext_clear"
  p_ca_ext_clear :: FunPtr (Ptr CCaExt -> Ptr CCaCtx -> IO ())

-- Structure -------------------------------------------------------------------

-- | /ca_ext_nargs/ /x/ /ctx/ 
--
-- Returns the number of function arguments of /x/. The return value is 0
-- for any algebraic constant and for any built-in symbolic constant such
-- as \(\pi\).
foreign import ccall "ca_ext.h ca_ext_nargs"
  ca_ext_nargs :: Ptr CCaExt -> Ptr CCaCtx -> IO CLong

-- | /ca_ext_get_arg/ /res/ /x/ /i/ /ctx/ 
--
-- Sets /res/ to argument /i/ (indexed from zero) of /x/. This calls
-- /flint_abort/ if /i/ is out of range.
foreign import ccall "ca_ext.h ca_ext_get_arg"
  ca_ext_get_arg :: Ptr CCa -> Ptr CCaExt -> CLong -> Ptr CCaCtx -> IO ()

-- | /ca_ext_hash/ /x/ /ctx/ 
--
-- Returns a hash of the structural representation of /x/.
foreign import ccall "ca_ext.h ca_ext_hash"
  ca_ext_hash :: Ptr CCaExt -> Ptr CCaCtx -> IO CULong

-- | /ca_ext_equal_repr/ /x/ /y/ /ctx/ 
--
-- Tests /x/ and /y/ for structural equality, returning 0 (false) or 1
-- (true).
foreign import ccall "ca_ext.h ca_ext_equal_repr"
  ca_ext_equal_repr :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO CInt

-- | /ca_ext_cmp_repr/ /x/ /y/ /ctx/ 
--
-- Compares the representations of /x/ and /y/ in a canonical sort order,
-- returning -1, 0 or 1. This only performs a structural comparison of the
-- symbolic representations; the return value does not say anything
-- meaningful about the numbers represented by /x/ and /y/.
foreign import ccall "ca_ext.h ca_ext_cmp_repr"
  ca_ext_cmp_repr :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO CInt

-- Input and output ------------------------------------------------------------

foreign import ccall "ca_ext.h ca_ext_get_str"
  ca_ext_get_str :: Ptr CCaExt -> Ptr CCaCtx -> IO CString

foreign import ccall "ca_ext.h ca_ext_fprint"
  ca_ext_fprint :: Ptr CFile -> Ptr CCaExt -> Ptr CCaCtx -> IO ()

-- | /ca_ext_print/ /x/ /ctx/ 
--
-- Prints a description of /x/ to standard output.
ca_ext_print :: Ptr CCaExt -> Ptr CCaCtx -> IO ()
ca_ext_print :: Ptr CCaExt -> Ptr CCaCtx -> IO ()
ca_ext_print Ptr CCaExt
x Ptr CCaCtx
ctx = do
  (Ptr CCaExt -> IO CString) -> Ptr CCaExt -> IO CInt
forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr ((Ptr CCaExt -> Ptr CCaCtx -> IO CString)
-> Ptr CCaCtx -> Ptr CCaExt -> IO CString
forall a b c. (a -> b -> c) -> b -> a -> c
flip Ptr CCaExt -> Ptr CCaCtx -> IO CString
ca_ext_get_str Ptr CCaCtx
ctx) Ptr CCaExt
x
  () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- Numerical evaluation --------------------------------------------------------

-- | /ca_ext_get_acb_raw/ /res/ /x/ /prec/ /ctx/ 
--
-- Sets /res/ to an enclosure of the numerical value of /x/. A working
-- precision of /prec/ bits is used for the evaluation, without adaptive
-- refinement.
foreign import ccall "ca_ext.h ca_ext_get_acb_raw"
  ca_ext_get_acb_raw :: Ptr CAcb -> Ptr CCaExt -> CLong -> Ptr CCaCtx -> IO ()

-- Cache -----------------------------------------------------------------------







-- | /ca_ext_cache_init/ /cache/ /ctx/ 
--
-- Initializes /cache/ for use.
foreign import ccall "ca_ext.h ca_ext_cache_init"
  ca_ext_cache_init :: Ptr CCaExtCache -> Ptr CCaCtx -> IO ()

-- | /ca_ext_cache_clear/ /cache/ /ctx/ 
--
-- Clears /cache/, freeing the memory allocated internally.
foreign import ccall "ca_ext.h ca_ext_cache_clear"
  ca_ext_cache_clear :: Ptr CCaExtCache -> Ptr CCaCtx -> IO ()

-- | /ca_ext_cache_insert/ /cache/ /x/ /ctx/ 
--
-- Adds /x/ to /cache/ without duplication. If a structurally identical
-- instance already exists in /cache/, a pointer to that instance is
-- returned. Otherwise, a copy of /x/ is inserted into /cache/ and a
-- pointer to that new instance is returned.
foreign import ccall "ca_ext.h ca_ext_cache_insert"
  ca_ext_cache_insert :: Ptr CCaExtCache -> Ptr CCaExt -> Ptr CCaCtx -> IO (Ptr CCaExt)