File indexing completed on 2026-11-07 10:15:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef CA_H
0013 #define CA_H
0014
0015 #ifdef CA_INLINES_C
0016 #define CA_INLINE
0017 #else
0018 #define CA_INLINE static inline
0019 #endif
0020
0021 #include "fmpz_mpoly_q.h"
0022 #include "fexpr.h"
0023 #include "ca_types.h"
0024
0025 #ifdef __cplusplus
0026 extern "C" {
0027 #endif
0028
0029 #define CA_INFO(ctx, args) do { if (ctx->options[CA_OPT_VERBOSE]) \
0030 do { flint_printf("%s:%d: ", __FILE__, __LINE__); flint_printf args; } \
0031 while (0); } while (0);
0032
0033
0034
0035 #define CA_FMPQ(x) (&((x)->elem.q))
0036 #define CA_MPOLY_Q(x) (&(((x)->elem.mpoly_q)[0]))
0037 #define CA_NF_ELEM(x) (&((x)->elem.nf))
0038 #define CA_FMPQ_NUMREF(x) (fmpq_numref(CA_FMPQ(x)))
0039 #define CA_FMPQ_DENREF(x) (fmpq_denref(CA_FMPQ(x)))
0040
0041 #define CA_FIELD(x, ctx) ((ca_field_ptr) ((x)->field))
0042 #define CA_FIELD_ULONG(x) ((x)->field)
0043
0044
0045 #define CA_IS_QQ(x, ctx) (CA_FIELD(x, ctx) == (ctx)->field_qq)
0046 #define CA_IS_QQ_I(x, ctx) (CA_FIELD(x, ctx) == (ctx)->field_qq_i)
0047
0048
0049
0050
0051
0052 #define CA_UNKNOWN UWORD(1)
0053 #define CA_UNDEFINED UWORD(2)
0054 #define CA_INF UWORD(3)
0055 #define CA_SPECIAL (CA_UNKNOWN | CA_UNDEFINED | CA_INF)
0056
0057 #define CA_IS_SPECIAL(x) (CA_FIELD_ULONG(x) & CA_SPECIAL)
0058 #define CA_IS_UNKNOWN(x) (CA_FIELD_ULONG(x) == CA_UNKNOWN)
0059 #define CA_IS_UNDEFINED(x) (CA_FIELD_ULONG(x) == CA_UNDEFINED)
0060 #define CA_IS_INF(x) ((CA_FIELD_ULONG(x) & CA_SPECIAL) == CA_INF)
0061 #define CA_IS_UNSIGNED_INF(x) (CA_FIELD_ULONG(x) == CA_INF)
0062 #define CA_IS_SIGNED_INF(x) (CA_IS_INF(x) && !CA_IS_UNSIGNED_INF(x))
0063
0064 #define CA_FIELD_UNSPECIAL(x, ctx) ((ca_field_ptr) (CA_FIELD_ULONG(x) & ~CA_SPECIAL))
0065
0066
0067
0068 #define CA_EXT_HEAD(x) ((x)->head)
0069 #define CA_EXT_HASH(x) ((x)->hash)
0070 #define CA_EXT_DEPTH(x) ((x)->depth)
0071
0072 #define CA_EXT_IS_QQBAR(x) ((x)->head == CA_QQBar)
0073
0074 #define CA_EXT_QQBAR(_x) (&((_x)->data.qqbar.x))
0075 #define CA_EXT_QQBAR_NF(_x) ((_x)->data.qqbar.nf)
0076
0077 #define CA_EXT_FUNC_ARGS(x) ((x)->data.func_data.args)
0078 #define CA_EXT_FUNC_NARGS(x) ((x)->data.func_data.nargs)
0079 #define CA_EXT_FUNC_ENCLOSURE(x) (&((x)->data.func_data.enclosure))
0080 #define CA_EXT_FUNC_PREC(x) ((x)->data.func_data.prec)
0081
0082
0083
0084 #define CA_FIELD_LENGTH(K) ((K)->length)
0085 #define CA_FIELD_EXT(K) ((K)->ext)
0086 #define CA_FIELD_EXT_ELEM(K, i) ((K)->ext[i])
0087 #define CA_FIELD_HASH(K) ((K)->hash)
0088
0089 #define CA_FIELD_IS_QQ(K) ((K)->length == 0)
0090 #define CA_FIELD_IS_NF(K) ((K)->ideal.length == -1)
0091 #define CA_FIELD_IS_GENERIC(K) (!CA_FIELD_IS_QQ(K) && !CA_FIELD_IS_NF(K))
0092
0093 #define CA_FIELD_NF(K) (((K)->ext[0]->data.qqbar.nf))
0094 #define CA_FIELD_NF_QQBAR(K) (&((K)->ext[0]->data.qqbar.x))
0095
0096 #define CA_FIELD_IDEAL(K) (&((K)->ideal))
0097 #define CA_FIELD_IDEAL_ELEM(K, i) fmpz_mpoly_vec_entry(CA_FIELD_IDEAL(K), i)
0098 #define CA_FIELD_IDEAL_LENGTH(K) ((K)->ideal.length)
0099 #define CA_FIELD_IDEAL_ALLOC(K) ((K)->ideal.alloc)
0100 #define CA_FIELD_IDEAL_P(K) ((K)->ideal.p)
0101
0102 #define CA_MCTX_1(ctx) ((ctx)->mctx[0])
0103 #define CA_FIELD_MCTX(K, ctx) ((ctx)->mctx[CA_FIELD_LENGTH(K) - 1])
0104
0105
0106
0107 enum
0108 {
0109 CA_OPT_VERBOSE,
0110 CA_OPT_PRINT_FLAGS,
0111 CA_OPT_MPOLY_ORD,
0112 CA_OPT_PREC_LIMIT,
0113 CA_OPT_QQBAR_DEG_LIMIT,
0114 CA_OPT_LOW_PREC,
0115 CA_OPT_SMOOTH_LIMIT,
0116 CA_OPT_LLL_PREC,
0117 CA_OPT_POW_LIMIT,
0118 CA_OPT_USE_GROEBNER,
0119 CA_OPT_GROEBNER_LENGTH_LIMIT,
0120 CA_OPT_GROEBNER_POLY_LENGTH_LIMIT,
0121 CA_OPT_GROEBNER_POLY_BITS_LIMIT,
0122 CA_OPT_VIETA_LIMIT,
0123 CA_OPT_TRIG_FORM,
0124 CA_OPT_NUM_OPTIONS
0125 };
0126
0127 #define CA_TRIG_DIRECT 0
0128 #define CA_TRIG_EXPONENTIAL 1
0129 #define CA_TRIG_SINE_COSINE 2
0130 #define CA_TRIG_TANGENT 3
0131
0132 #define CA_CTX_EXT_CACHE(ctx) (&((ctx)->ext_cache))
0133 #define CA_CTX_FIELD_CACHE(ctx) (&((ctx)->field_cache))
0134
0135 #define CA_CTX_FIELD_WITH_INDEX(ctx, i) ((&((ctx)->field_cache))->items[i])
0136
0137
0138
0139 void ca_ctx_init(ca_ctx_t ctx);
0140 void ca_ctx_clear(ca_ctx_t ctx);
0141 void ca_ctx_print(ca_ctx_t ctx);
0142
0143 CA_INLINE slong ca_ctx_get_option(ca_ctx_t ctx, slong i)
0144 {
0145 return ctx->options[i];
0146 }
0147
0148 CA_INLINE void ca_ctx_set_option(ca_ctx_t ctx, slong i, slong value)
0149 {
0150 ctx->options[i] = value;
0151 }
0152
0153 ca_field_ptr _ca_ctx_get_field_const(ca_ctx_t ctx, calcium_func_code func);
0154 ca_field_ptr _ca_ctx_get_field_fx(ca_ctx_t ctx, calcium_func_code func, const ca_t x);
0155 ca_field_ptr _ca_ctx_get_field_fxy(ca_ctx_t ctx, calcium_func_code func, const ca_t x, const ca_t y);
0156
0157
0158
0159 void ca_init(ca_t x, ca_ctx_t ctx);
0160 void ca_clear(ca_t x, ca_ctx_t ctx);
0161 void ca_swap(ca_t x, ca_t y, ca_ctx_t ctx);
0162 void _ca_make_field_element(ca_t x, ca_field_srcptr field, ca_ctx_t ctx);
0163
0164 CA_INLINE void
0165 _ca_make_fmpq(ca_t x, ca_ctx_t ctx)
0166 {
0167 if (!CA_IS_QQ(x, ctx))
0168 _ca_make_field_element(x, ctx->field_qq, ctx);
0169 }
0170
0171 CA_INLINE void
0172 _ca_function_fx(ca_t res, calcium_func_code func, const ca_t x, ca_ctx_t ctx)
0173 {
0174 ca_field_srcptr field = _ca_ctx_get_field_fx(ctx, func, x);
0175 _ca_make_field_element(res, field, ctx);
0176 fmpz_mpoly_q_gen(CA_MPOLY_Q(res), 0, CA_FIELD_MCTX(field, ctx));
0177 }
0178
0179 CA_INLINE void
0180 _ca_function_fxy(ca_t res, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx)
0181 {
0182 ca_field_srcptr field = _ca_ctx_get_field_fxy(ctx, func, x, y);
0183 _ca_make_field_element(res, field, ctx);
0184 fmpz_mpoly_q_gen(CA_MPOLY_Q(res), 0, CA_FIELD_MCTX(field, ctx));
0185 }
0186
0187 void ca_set(ca_t res, const ca_t x, ca_ctx_t ctx);
0188 void ca_transfer(ca_t res, ca_ctx_t res_ctx, const ca_t src, ca_ctx_t src_ctx);
0189
0190 void ca_zero(ca_t x, ca_ctx_t ctx);
0191 void ca_one(ca_t x, ca_ctx_t ctx);
0192 void ca_neg_one(ca_t x, ca_ctx_t ctx);
0193
0194 void ca_set_si(ca_t x, slong v, ca_ctx_t ctx);
0195 void ca_set_ui(ca_t x, ulong v, ca_ctx_t ctx);
0196 void ca_set_fmpz(ca_t x, const fmpz_t v, ca_ctx_t ctx);
0197 void ca_set_fmpq(ca_t x, const fmpq_t v, ca_ctx_t ctx);
0198 void ca_set_d(ca_t res, double x, ca_ctx_t ctx);
0199 void ca_set_d_d(ca_t res, double x, double y, ca_ctx_t ctx);
0200
0201 void ca_i(ca_t x, ca_ctx_t ctx);
0202 void ca_neg_i(ca_t x, ca_ctx_t ctx);
0203 void ca_pi(ca_t res, ca_ctx_t ctx);
0204 void ca_pi_i(ca_t res, ca_ctx_t ctx);
0205 void ca_euler(ca_t res, ca_ctx_t ctx);
0206
0207 void ca_unknown(ca_t x, ca_ctx_t ctx);
0208
0209 void ca_undefined(ca_t x, ca_ctx_t ctx);
0210 void ca_uinf(ca_t x, ca_ctx_t ctx);
0211 void ca_pos_inf(ca_t x, ca_ctx_t ctx);
0212 void ca_neg_inf(ca_t x, ca_ctx_t ctx);
0213 void ca_pos_i_inf(ca_t x, ca_ctx_t ctx);
0214 void ca_neg_i_inf(ca_t x, ca_ctx_t ctx);
0215
0216 void ca_set_qqbar(ca_t res, const qqbar_t x, ca_ctx_t ctx);
0217 int ca_can_evaluate_qqbar(const ca_t x, ca_ctx_t ctx);
0218 int ca_get_qqbar(qqbar_t res, const ca_t x, ca_ctx_t ctx);
0219 int ca_get_fmpq(fmpq_t res, const ca_t x, ca_ctx_t ctx);
0220 int ca_get_fmpz(fmpz_t res, const ca_t x, ca_ctx_t ctx);
0221
0222
0223
0224 #define CA_FEXPR_SERIALIZATION 1
0225
0226 void ca_get_fexpr(fexpr_t res, const ca_t x, ulong flags, ca_ctx_t ctx);
0227 int ca_set_fexpr(ca_t res, const fexpr_t expr, ca_ctx_t ctx);
0228
0229
0230
0231 #define CA_PRINT_N UWORD(1)
0232 #define CA_PRINT_REPR UWORD(2)
0233 #define CA_PRINT_FIELD UWORD(4)
0234 #define CA_PRINT_DIGITS UWORD(16)
0235 #define CA_PRINT_DEFAULT (CA_PRINT_N | CA_PRINT_REPR)
0236 #define CA_PRINT_DEBUG (CA_PRINT_N | CA_PRINT_REPR | CA_PRINT_FIELD)
0237
0238 #ifdef FLINT_HAVE_FILE
0239 void ca_fprint(FILE * fp, const ca_t x, ca_ctx_t ctx);
0240 #endif
0241
0242 void ca_print(const ca_t x, ca_ctx_t ctx);
0243 void ca_printn(const ca_t x, slong n, ca_ctx_t ctx);
0244 char * ca_get_str(const ca_t x, ca_ctx_t ctx);
0245
0246
0247
0248 void ca_randtest_same_nf(ca_t res, flint_rand_t state, const ca_t x, slong bits, slong den_bits, ca_ctx_t ctx);
0249 void ca_randtest_rational(ca_t res, flint_rand_t state, slong bits, ca_ctx_t ctx);
0250 void ca_randtest(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx);
0251 void ca_randtest_special(ca_t res, flint_rand_t state, slong depth, slong bits, ca_ctx_t ctx);
0252
0253
0254
0255 CA_INLINE int ca_is_special(const ca_t x, ca_ctx_t FLINT_UNUSED(ctx))
0256 {
0257 return CA_IS_SPECIAL(x);
0258 }
0259
0260 CA_INLINE int ca_is_unknown(const ca_t x, ca_ctx_t FLINT_UNUSED(ctx))
0261 {
0262 return CA_IS_UNKNOWN(x);
0263 }
0264
0265 CA_INLINE int ca_is_qq_elem(const ca_t x, ca_ctx_t ctx)
0266 {
0267 return CA_IS_QQ(x, ctx);
0268 }
0269
0270 CA_INLINE int ca_is_qq_elem_zero(const ca_t x, ca_ctx_t ctx)
0271 {
0272 return CA_IS_QQ(x, ctx) && fmpq_is_zero(CA_FMPQ(x));
0273 }
0274
0275 CA_INLINE int ca_is_qq_elem_one(const ca_t x, ca_ctx_t ctx)
0276 {
0277 return CA_IS_QQ(x, ctx) && fmpq_is_one(CA_FMPQ(x));
0278 }
0279
0280 CA_INLINE int ca_is_qq_elem_integer(const ca_t x, ca_ctx_t ctx)
0281 {
0282 return CA_IS_QQ(x, ctx) && fmpz_is_one(CA_FMPQ_DENREF(x));
0283 }
0284
0285 CA_INLINE int ca_is_nf_elem(const ca_t x, ca_ctx_t ctx)
0286 {
0287 return !CA_IS_SPECIAL(x) && CA_FIELD_IS_NF(CA_FIELD(x, ctx));
0288 }
0289
0290 CA_INLINE int ca_is_generic_elem(const ca_t x, ca_ctx_t ctx)
0291 {
0292 return !CA_IS_SPECIAL(x) && CA_FIELD_IS_GENERIC(CA_FIELD(x, ctx));
0293 }
0294
0295 int
0296 ca_is_cyclotomic_nf_elem(slong * p, ulong * q, const ca_t x, ca_ctx_t ctx);
0297
0298
0299
0300 truth_t ca_is_zero_check_fast(const ca_t x, ca_ctx_t ctx);
0301
0302
0303 truth_t ca_check_is_number(const ca_t x, ca_ctx_t ctx);
0304 truth_t ca_check_is_zero(const ca_t x, ca_ctx_t ctx);
0305 truth_t ca_check_is_one(const ca_t x, ca_ctx_t ctx);
0306 truth_t ca_check_is_neg_one(const ca_t x, ca_ctx_t ctx);
0307 truth_t ca_check_is_i(const ca_t x, ca_ctx_t ctx);
0308 truth_t ca_check_is_neg_i(const ca_t x, ca_ctx_t ctx);
0309 truth_t ca_check_is_algebraic(const ca_t x, ca_ctx_t ctx);
0310 truth_t ca_check_is_rational(const ca_t x, ca_ctx_t ctx);
0311 truth_t ca_check_is_integer(const ca_t x, ca_ctx_t ctx);
0312 truth_t ca_check_is_real(const ca_t x, ca_ctx_t ctx);
0313 truth_t ca_check_is_negative_real(const ca_t x, ca_ctx_t ctx);
0314 truth_t ca_check_is_imaginary(const ca_t x, ca_ctx_t ctx);
0315 truth_t ca_check_is_undefined(const ca_t x, ca_ctx_t ctx);
0316 truth_t ca_check_is_infinity(const ca_t x, ca_ctx_t ctx);
0317 truth_t ca_check_is_uinf(const ca_t x, ca_ctx_t ctx);
0318 truth_t ca_check_is_signed_inf(const ca_t x, ca_ctx_t ctx);
0319 truth_t ca_check_is_pos_inf(const ca_t x, ca_ctx_t ctx);
0320 truth_t ca_check_is_neg_inf(const ca_t x, ca_ctx_t ctx);
0321 truth_t ca_check_is_pos_i_inf(const ca_t x, ca_ctx_t ctx);
0322 truth_t ca_check_is_neg_i_inf(const ca_t x, ca_ctx_t ctx);
0323
0324 truth_t ca_check_equal(const ca_t x, const ca_t y, ca_ctx_t ctx);
0325 truth_t ca_check_lt(const ca_t x, const ca_t y, ca_ctx_t ctx);
0326 truth_t ca_check_le(const ca_t x, const ca_t y, ca_ctx_t ctx);
0327 truth_t ca_check_gt(const ca_t x, const ca_t y, ca_ctx_t ctx);
0328 truth_t ca_check_ge(const ca_t x, const ca_t y, ca_ctx_t ctx);
0329
0330 int ca_equal_repr(const ca_t x, const ca_t y, ca_ctx_t ctx);
0331 int ca_cmp_repr(const ca_t x, const ca_t y, ca_ctx_t ctx);
0332 ulong ca_hash_repr(const ca_t x, ca_ctx_t ctx);
0333
0334
0335
0336 void ca_merge_fields(ca_t resx, ca_t resy, const ca_t x, const ca_t y, ca_ctx_t ctx);
0337 void ca_condense_field(ca_t res, ca_ctx_t ctx);
0338 ca_ext_ptr ca_is_gen_as_ext(const ca_t x, ca_ctx_t ctx);
0339
0340
0341
0342
0343 void _ca_mpoly_q_reduce_ideal(fmpz_mpoly_q_t res, ca_field_srcptr field, ca_ctx_t ctx);
0344 void _ca_mpoly_q_simplify_fraction_ideal(fmpz_mpoly_q_t res, ca_field_srcptr field, ca_ctx_t ctx);
0345
0346
0347 void ca_neg(ca_t res, const ca_t x, ca_ctx_t ctx);
0348
0349 void ca_add_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx);
0350 void ca_add_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx);
0351 void ca_add_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx);
0352 void ca_add_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx);
0353 void ca_add(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx);
0354
0355 void ca_sub_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx);
0356 void ca_sub_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx);
0357 void ca_sub_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx);
0358 void ca_sub_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx);
0359 void ca_fmpq_sub(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx);
0360 void ca_fmpz_sub(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx);
0361 void ca_ui_sub(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx);
0362 void ca_si_sub(ca_t res, slong x, const ca_t y, ca_ctx_t ctx);
0363 void ca_sub(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx);
0364
0365 void ca_mul_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx);
0366 void ca_mul_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx);
0367 void ca_mul_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx);
0368 void ca_mul_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx);
0369 void ca_mul(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx);
0370
0371 void ca_inv(ca_t res, const ca_t x, ca_ctx_t ctx);
0372
0373 void ca_fmpq_div(ca_t res, const fmpq_t x, const ca_t y, ca_ctx_t ctx);
0374 void ca_fmpz_div(ca_t res, const fmpz_t x, const ca_t y, ca_ctx_t ctx);
0375 void ca_ui_div(ca_t res, ulong x, const ca_t y, ca_ctx_t ctx);
0376 void ca_si_div(ca_t res, slong x, const ca_t y, ca_ctx_t ctx);
0377
0378 void ca_div_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx);
0379 void ca_div_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx);
0380 void ca_div_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx);
0381 void ca_div_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx);
0382 void ca_div(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx);
0383
0384 void ca_dot(ca_t res, const ca_t initial, int subtract,
0385 ca_srcptr x, slong xstep, ca_srcptr y, slong ystep, slong len, ca_ctx_t ctx);
0386
0387 void ca_fmpz_poly_evaluate(ca_t res, const fmpz_poly_t poly, const ca_t x, ca_ctx_t ctx);
0388 void ca_fmpq_poly_evaluate(ca_t res, const fmpq_poly_t poly, const ca_t x, ca_ctx_t ctx);
0389
0390 void ca_fmpz_mpoly_evaluate_horner(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx);
0391 void ca_fmpz_mpoly_evaluate_iter(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx);
0392 void ca_fmpz_mpoly_evaluate(ca_t res, const fmpz_mpoly_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx);
0393
0394 void ca_fmpz_mpoly_q_evaluate(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx);
0395
0396 void ca_fmpz_mpoly_q_evaluate_no_division_by_zero(ca_t res, const fmpz_mpoly_q_t f, ca_srcptr x, const fmpz_mpoly_ctx_t mctx, ca_ctx_t ctx);
0397 void ca_inv_no_division_by_zero(ca_t res, const ca_t x, ca_ctx_t ctx);
0398
0399
0400
0401
0402 CA_INLINE void
0403 ca_sqr(ca_t res, const ca_t x, ca_ctx_t ctx)
0404 {
0405 ca_mul(res, x, x, ctx);
0406 }
0407
0408 void ca_pow_fmpq(ca_t res, const ca_t x, const fmpq_t y, ca_ctx_t ctx);
0409 void ca_pow_fmpz(ca_t res, const ca_t x, const fmpz_t y, ca_ctx_t ctx);
0410 void ca_pow_ui(ca_t res, const ca_t x, ulong y, ca_ctx_t ctx);
0411 void ca_pow_si(ca_t res, const ca_t x, slong y, ca_ctx_t ctx);
0412 void ca_pow(ca_t res, const ca_t x, const ca_t y, ca_ctx_t ctx);
0413
0414 void ca_pow_si_arithmetic(ca_t res, const ca_t x, slong n, ca_ctx_t ctx);
0415
0416 void ca_sqrt_inert(ca_t res, const ca_t x, ca_ctx_t ctx);
0417 void ca_sqrt_nofactor(ca_t res, const ca_t x, ca_ctx_t ctx);
0418 void ca_sqrt_factor(ca_t res, const ca_t x, ulong flags, ca_ctx_t ctx);
0419 void ca_sqrt(ca_t res, const ca_t x, ca_ctx_t ctx);
0420
0421 CA_INLINE void
0422 ca_sqrt_ui(ca_t res, ulong n, ca_ctx_t ctx)
0423 {
0424 ca_set_ui(res, n, ctx);
0425 ca_sqrt(res, res, ctx);
0426 }
0427
0428
0429
0430 void ca_conj_shallow(ca_t res, const ca_t x, ca_ctx_t ctx);
0431 void ca_conj_deep(ca_t res, const ca_t x, ca_ctx_t ctx);
0432 void ca_conj(ca_t res, const ca_t x, ca_ctx_t ctx);
0433
0434 void ca_abs(ca_t res, const ca_t x, ca_ctx_t ctx);
0435 void ca_sgn(ca_t res, const ca_t x, ca_ctx_t ctx);
0436 void ca_csgn(ca_t res, const ca_t x, ca_ctx_t ctx);
0437 void ca_arg(ca_t res, const ca_t x, ca_ctx_t ctx);
0438 void ca_re(ca_t res, const ca_t x, ca_ctx_t ctx);
0439 void ca_im(ca_t res, const ca_t x, ca_ctx_t ctx);
0440 void ca_floor(ca_t res, const ca_t x, ca_ctx_t ctx);
0441 void ca_ceil(ca_t res, const ca_t x, ca_ctx_t ctx);
0442
0443
0444
0445 void ca_exp(ca_t res, const ca_t x, ca_ctx_t ctx);
0446 void ca_log(ca_t res, const ca_t x, ca_ctx_t ctx);
0447
0448 void ca_sin_cos_exponential(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx);
0449 void ca_sin_cos_direct_exp_hack(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx);
0450 void ca_sin_cos_direct(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx);
0451 void ca_sin_cos_tangent(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx);
0452 void ca_sin_cos(ca_t res1, ca_t res2, const ca_t x, ca_ctx_t ctx);
0453 void ca_sin(ca_t res, const ca_t x, ca_ctx_t ctx);
0454 void ca_cos(ca_t res, const ca_t x, ca_ctx_t ctx);
0455
0456 void ca_tan_sine_cosine(ca_t res, const ca_t x, ca_ctx_t ctx);
0457 void ca_tan_exponential(ca_t res, const ca_t x, ca_ctx_t ctx);
0458 void ca_tan_direct(ca_t res, const ca_t x, ca_ctx_t ctx);
0459 void ca_tan(ca_t res, const ca_t x, ca_ctx_t ctx);
0460
0461 void ca_cot(ca_t res, const ca_t x, ca_ctx_t ctx);
0462
0463 void ca_atan_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx);
0464 void ca_atan_direct(ca_t res, const ca_t x, ca_ctx_t ctx);
0465 void ca_atan(ca_t res, const ca_t x, ca_ctx_t ctx);
0466
0467 void ca_asin_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx);
0468 void ca_asin_direct(ca_t res, const ca_t x, ca_ctx_t ctx);
0469 void ca_asin(ca_t res, const ca_t x, ca_ctx_t ctx);
0470
0471 void ca_acos_logarithm(ca_t res, const ca_t x, ca_ctx_t ctx);
0472 void ca_acos_direct(ca_t res, const ca_t x, ca_ctx_t ctx);
0473 void ca_acos(ca_t res, const ca_t x, ca_ctx_t ctx);
0474
0475
0476
0477 void ca_erf(ca_t res, const ca_t x, ca_ctx_t ctx);
0478 void ca_erfc(ca_t res, const ca_t x, ca_ctx_t ctx);
0479 void ca_erfi(ca_t res, const ca_t x, ca_ctx_t ctx);
0480
0481 void ca_gamma(ca_t res, const ca_t x, ca_ctx_t ctx);
0482
0483
0484
0485 void ca_get_acb_raw(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx);
0486 void ca_get_acb(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx);
0487 void ca_get_acb_accurate_parts(acb_t res, const ca_t x, slong prec, ca_ctx_t ctx);
0488
0489 char * ca_get_decimal_str(const ca_t x, slong digits, ulong flags, ca_ctx_t ctx);
0490
0491
0492
0493 #define CA_FACTOR_ZZ_NONE 0
0494 #define CA_FACTOR_ZZ_SMOOTH 2
0495 #define CA_FACTOR_ZZ_FULL 4
0496 #define CA_FACTOR_POLY_NONE 0
0497 #define CA_FACTOR_POLY_CONTENT 64
0498 #define CA_FACTOR_POLY_SQF 128
0499 #define CA_FACTOR_POLY_FULL 256
0500
0501 void ca_factor_init(ca_factor_t fac, ca_ctx_t ctx);
0502 void ca_factor_clear(ca_factor_t fac, ca_ctx_t ctx);
0503 void ca_factor_one(ca_factor_t fac, ca_ctx_t ctx);
0504 void ca_factor_print(const ca_factor_t fac, ca_ctx_t ctx);
0505 void ca_factor_insert(ca_factor_t fac, const ca_t base, const ca_t exp, ca_ctx_t ctx);
0506 void ca_factor_get_ca(ca_t res, const ca_factor_t fac, ca_ctx_t ctx);
0507
0508 void ca_factor(ca_factor_t res, const ca_t x, ulong flags, ca_ctx_t ctx);
0509
0510
0511
0512 #define CA_TEST_PROPERTY(f, s, x, ctx, expected) \
0513 do { \
0514 truth_t t; \
0515 t = f(x, ctx); \
0516 if (t != expected) \
0517 { \
0518 flint_printf("FAIL\n"); \
0519 flint_printf("%s\n\n", s); \
0520 flint_printf("x = "); ca_print(x, ctx); flint_printf("\n\n"); \
0521 flint_printf("got = "); truth_print(t); flint_printf("\n\n"); \
0522 flint_printf("expected = "); truth_print(expected); flint_printf("\n\n"); \
0523 flint_abort(); \
0524 } \
0525 } while (0) \
0526
0527 #ifdef __cplusplus
0528 }
0529 #endif
0530
0531 #endif