Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:15:09

0001 /*
0002     Copyright (C) 2024 Albin Ahlbäck
0003 
0004     This file is part of FLINT.
0005 
0006     FLINT is free software: you can redistribute it and/or modify it under
0007     the terms of the GNU Lesser General Public License (LGPL) as published
0008     by the Free Software Foundation; either version 3 of the License, or
0009     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
0010 */
0011 
0012 #ifndef CA_TYPES_H
0013 #define CA_TYPES_H
0014 
0015 #include "gr_types.h"
0016 #include "fmpz_types.h"
0017 #include "fmpz_mpoly.h" /* FIXME: Move fmpz_mpoly_vec_struct to fmpz_types? */
0018 #include "qqbar.h" /* FIXME: Would be nice to remove */
0019 #include "nf_elem.h" /* FIXME: Would be nice to remove */
0020 
0021 #ifdef __cplusplus
0022 extern "C" {
0023 #endif
0024 
0025 /* I/O ***********************************************************************/
0026 
0027 #ifndef calcium_stream_struct
0028 # define calcium_stream_struct gr_stream_struct
0029 # define calcium_stream_t gr_stream_t
0030 #endif
0031 
0032 /* IDs for builtin mathematical functions and constants **********************/
0033 
0034 typedef enum
0035 {
0036     /* Special case for representing qqbar instances */
0037     CA_QQBar,
0038     /* Arithmetic */
0039     CA_Neg,
0040     CA_Add,
0041     CA_Sub,
0042     CA_Mul,
0043     CA_Div,
0044     /* Roots */
0045     CA_Sqrt,
0046     CA_Cbrt,
0047     CA_Root,
0048     /* Complex parts */
0049     CA_Floor,
0050     CA_Ceil,
0051     CA_Abs,
0052     CA_Sign,
0053     CA_Re,
0054     CA_Im,
0055     CA_Arg,
0056     CA_Conjugate,
0057     /* Elementary constants */
0058     CA_Pi,
0059     /* Elementary functions */
0060     CA_Sin,
0061     CA_Cos,
0062     CA_Exp,
0063     CA_Log,
0064     CA_Pow,
0065     CA_Tan,
0066     CA_Cot,
0067     CA_Cosh,
0068     CA_Sinh,
0069     CA_Tanh,
0070     CA_Coth,
0071     CA_Atan,
0072     CA_Acos,
0073     CA_Asin,
0074     CA_Acot,
0075     CA_Atanh,
0076     CA_Acosh,
0077     CA_Asinh,
0078     CA_Acoth,
0079     /* Euler's constant */
0080     CA_Euler,
0081     /* Gamma and related functions */
0082     CA_Gamma,
0083     CA_LogGamma,
0084     CA_Psi,
0085     CA_Erf,
0086     CA_Erfc,
0087     CA_Erfi,
0088     CA_RiemannZeta,
0089     CA_HurwitzZeta,
0090     CA_FUNC_CODE_LENGTH
0091 } calcium_func_code;
0092 
0093 /* element object ************************************************************/
0094 
0095 typedef union
0096 {
0097     fmpq q;                           /* rational number */
0098     nf_elem_struct nf;                /* algebraic number field element */
0099     fmpz_mpoly_q_struct * mpoly_q;    /* generic field element */
0100 }
0101 ca_elem_struct;
0102 
0103 typedef struct
0104 {
0105     ulong field;
0106     ca_elem_struct elem;
0107 }
0108 ca_struct;
0109 
0110 typedef ca_struct ca_t[1];
0111 typedef ca_struct * ca_ptr;
0112 typedef const ca_struct * ca_srcptr;
0113 
0114 /* extension object **********************************************************/
0115 
0116 typedef struct
0117 {
0118     qqbar_struct x;        /* qqbar_t element */
0119     nf_struct * nf;        /* antic number field for fast arithmetic */
0120 }
0121 ca_ext_qqbar;
0122 
0123 typedef struct
0124 {
0125     ca_struct * args;       /* Function arguments x1, ..., xn. */
0126     slong nargs;            /* Number of function arguments n. */
0127     acb_struct enclosure;   /* Cached numerical enclosure of f(x1,...,xn) */
0128     slong prec;             /* Working precision of cached enclosure */
0129     qqbar_struct * qqbar;   /* Cached qqbar */
0130 }
0131 ca_ext_func_data;
0132 
0133 typedef struct
0134 {
0135     calcium_func_code head;   /* f = F_Pi, F_Exp, ... */
0136     ulong hash;
0137     slong depth;
0138     union {
0139         ca_ext_qqbar qqbar;
0140         ca_ext_func_data func_data;
0141     } data;
0142 } ca_ext_struct;
0143 
0144 typedef ca_ext_struct ca_ext_t[1];
0145 typedef ca_ext_struct * ca_ext_ptr;
0146 typedef const ca_ext_struct * ca_ext_srcptr;
0147 
0148 typedef struct
0149 {
0150     ca_ext_struct ** items;
0151     slong length;
0152     slong alloc;
0153 
0154     slong hash_size;
0155     slong * hash_table;
0156 }
0157 ca_ext_cache_struct;
0158 
0159 typedef ca_ext_cache_struct ca_ext_cache_t[1];
0160 
0161 /* field object **************************************************************/
0162 
0163 typedef struct
0164 {
0165     slong length;                /* Number of generators              */
0166     ca_ext_struct ** ext;        /* Generators                        */
0167     fmpz_mpoly_vec_struct ideal; /* Algebraic relations for reduction */
0168     ulong hash;
0169 }
0170 ca_field_struct;
0171 
0172 typedef ca_field_struct ca_field_t[1];
0173 typedef ca_field_struct * ca_field_ptr;
0174 typedef const ca_field_struct * ca_field_srcptr;
0175 
0176 typedef struct
0177 {
0178     ca_field_struct ** items;
0179     slong length;
0180     slong alloc;
0181 
0182     slong hash_size;
0183     slong * hash_table;
0184 }
0185 ca_field_cache_struct;
0186 
0187 typedef ca_field_cache_struct ca_field_cache_t[1];
0188 
0189 /* context object ************************************************************/
0190 
0191 typedef struct
0192 {
0193     ca_ext_cache_struct ext_cache;              /* Cached extension objects */
0194     ca_field_cache_struct field_cache;          /* Cached extension fields  */
0195     ca_field_struct * field_qq;                 /* Quick access to QQ      */
0196     ca_field_struct * field_qq_i;               /* Quick access to QQ(i)   */
0197     fmpz_mpoly_ctx_struct ** mctx;              /* Cached contexts for multivariate polys */
0198     slong mctx_len;
0199     slong * options;
0200 }
0201 ca_ctx_struct;
0202 
0203 typedef ca_ctx_struct ca_ctx_t[1];
0204 
0205 /* factor object *************************************************************/
0206 
0207 typedef struct
0208 {
0209     ca_ptr base;
0210     ca_ptr exp;
0211     slong length;
0212     slong alloc;
0213 }
0214 ca_factor_struct;
0215 
0216 typedef ca_factor_struct ca_factor_t[1];
0217 
0218 /* vector object *************************************************************/
0219 
0220 typedef struct
0221 {
0222     ca_ptr entries;
0223     slong alloc;
0224     slong length;
0225 }
0226 ca_vec_struct;
0227 
0228 typedef ca_vec_struct ca_vec_t[1];
0229 
0230 /* matrix object *************************************************************/
0231 
0232 typedef struct
0233 {
0234     ca_ptr entries;
0235     slong r;
0236     slong c;
0237     slong stride;
0238 }
0239 ca_mat_struct;
0240 
0241 typedef ca_mat_struct ca_mat_t[1];
0242 
0243 /* polynomial object *********************************************************/
0244 
0245 typedef struct
0246 {
0247     ca_struct * coeffs;
0248     slong alloc;
0249     slong length;
0250 }
0251 ca_poly_struct;
0252 
0253 typedef ca_poly_struct ca_poly_t[1];
0254 
0255 #ifdef __cplusplus
0256 }
0257 #endif
0258 
0259 #endif /* CA_TYPES_H */