Flint2-0.1.0.5: Haskell bindings for the flint library for number theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Number.Flint.Calcium.Ca.Ext

Description

A CaExt represents a fixed real or complex number a.

The CaExt structure is heavy-weight object, not just meant to act as a node in a symbolic expression. It will cache various data to support repeated computation with this particular number, including its numerical enclosure and number field data in the case of algebraic numbers.

Extension numbers are used internally by the Ca type to define the embeddings \(\mathbb{Q}(a) \to \mathbb{C}\) of formal fields. The user does not normally need to create ca_ext_t instances directly; the intended way for the user to work with the extension number a is to create a ca_t representing the field element \(1 \cdot a\). The underlying CaExt may be accessed to determine symbolic and numerical properties of this number.

Since extension numbers may depend recursively on nontrivial fields for function arguments, CaExt operations require a CaCtx context object.

Synopsis

Real and complex extension numbers

Type and macros

data CaExt Source #

Constructors

CaExt !(ForeignPtr CCaExt) 

Instances

Instances details
Storable CCaExt Source # 
Instance details

Defined in Data.Number.Flint.Calcium.Ca.Ext.FFI

withCaExt :: CaExt -> (Ptr CCaExt -> IO a) -> IO (CaExt, a) Source #

Memory management

ca_ext_init_qqbar :: Ptr CCaExt -> Ptr CQQbar -> Ptr CCaCtx -> IO () Source #

ca_ext_init_qqbar res x ctx

Initializes res and sets it to the algebraic constant x.

ca_ext_init_const :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCaCtx -> IO () Source #

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\)).

ca_ext_init_fx :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

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\)).

ca_ext_init_fxy :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

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\)).

ca_ext_init_fxn :: Ptr CCaExt -> CCalciumFunctionCode -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

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.

ca_ext_init_set :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO () Source #

ca_ext_init_set res x ctx

Initializes res and sets it to a copy of x.

ca_ext_clear :: Ptr CCaExt -> Ptr CCaCtx -> IO () Source #

ca_ext_clear res ctx

Clears res.

Structure

ca_ext_nargs :: Ptr CCaExt -> Ptr CCaCtx -> IO CLong Source #

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\).

ca_ext_get_arg :: Ptr CCa -> Ptr CCaExt -> CLong -> Ptr CCaCtx -> IO () Source #

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.

ca_ext_hash :: Ptr CCaExt -> Ptr CCaCtx -> IO CULong Source #

ca_ext_hash x ctx

Returns a hash of the structural representation of x.

ca_ext_equal_repr :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO CInt Source #

ca_ext_equal_repr x y ctx

Tests x and y for structural equality, returning 0 (false) or 1 (true).

ca_ext_cmp_repr :: Ptr CCaExt -> Ptr CCaExt -> Ptr CCaCtx -> IO CInt Source #

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.

Input and output

ca_ext_print :: Ptr CCaExt -> Ptr CCaCtx -> IO () Source #

ca_ext_print x ctx

Prints a description of x to standard output.

Numerical evaluation

ca_ext_get_acb_raw :: Ptr CAcb -> Ptr CCaExt -> CLong -> Ptr CCaCtx -> IO () Source #

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.

Cache

ca_ext_cache_init :: Ptr CCaExtCache -> Ptr CCaCtx -> IO () Source #

ca_ext_cache_init cache ctx

Initializes cache for use.

ca_ext_cache_clear :: Ptr CCaExtCache -> Ptr CCaCtx -> IO () Source #

ca_ext_cache_clear cache ctx

Clears cache, freeing the memory allocated internally.

ca_ext_cache_insert :: Ptr CCaExtCache -> Ptr CCaExt -> Ptr CCaCtx -> IO (Ptr CCaExt) Source #

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.