-
Notifications
You must be signed in to change notification settings - Fork 11
/
ca_ext.h
98 lines (76 loc) · 2.66 KB
/
ca_ext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
Copyright (C) 2020 Fredrik Johansson
This file is part of Calcium.
Calcium is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#ifndef CA_EXT_H
#define CA_EXT_H
#ifdef CA_EXT_INLINES_C
#define CA_EXT_INLINE
#else
#define CA_EXT_INLINE static __inline__
#endif
#include "calcium.h"
#include "qqbar.h"
#include "ca.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Types *********************************************************************/
/* note: types and macros are defined in ca.h since they are needed there */
void ca_ext_init_qqbar(ca_ext_t res, const qqbar_t x, ca_ctx_t ctx);
void ca_ext_init_const(ca_ext_t res, calcium_func_code func, ca_ctx_t ctx);
void ca_ext_init_fx(ca_ext_t res, calcium_func_code func, const ca_t x, ca_ctx_t ctx);
void ca_ext_init_fxy(ca_ext_t res, calcium_func_code func, const ca_t x, const ca_t y, ca_ctx_t ctx);
void ca_ext_init_fxn(ca_ext_t res, calcium_func_code func, ca_srcptr x, slong nargs, ca_ctx_t ctx);
/* todo: this could avoid rehashing, ... */
CA_EXT_INLINE void
ca_ext_init_set(ca_ext_t res, const ca_ext_t x, ca_ctx_t ctx)
{
if (CA_EXT_HEAD(x) == CA_QQBar)
{
ca_ext_init_qqbar(res, CA_EXT_QQBAR(x), ctx);
}
else
{
ca_ext_init_fxn(res, CA_EXT_HEAD(x), CA_EXT_FUNC_ARGS(x), CA_EXT_FUNC_NARGS(x), ctx);
}
}
void ca_ext_clear(ca_ext_t res, ca_ctx_t ctx);
CA_EXT_INLINE slong ca_ext_nargs(const ca_ext_t x, ca_ctx_t ctx)
{
if (CA_EXT_HEAD(x) == CA_QQBar)
return 0;
else
return CA_EXT_FUNC_NARGS(x);
}
CA_EXT_INLINE void ca_ext_get_arg(ca_t res, const ca_ext_t x, slong i, ca_ctx_t ctx)
{
if (CA_EXT_HEAD(x) == CA_QQBar || i < 0 || i >= CA_EXT_FUNC_NARGS(x))
{
flint_printf("ca_ext_get_arg: index out of range\n");
flint_abort();
}
else
{
ca_set(res, CA_EXT_FUNC_ARGS(x) + i, ctx);
}
}
CA_EXT_INLINE ulong ca_ext_hash(const ca_ext_t x, ca_ctx_t ctx)
{
return CA_EXT_HASH(x);
}
int ca_ext_equal_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx);
int ca_ext_cmp_repr(const ca_ext_t x, const ca_ext_t y, ca_ctx_t ctx);
void ca_ext_print(const ca_ext_t x, ca_ctx_t ctx);
void ca_ext_get_acb_raw(acb_t res, ca_ext_t x, slong prec, ca_ctx_t ctx);
void ca_ext_cache_init(ca_ext_cache_t cache, ca_ctx_t ctx);
void ca_ext_cache_clear(ca_ext_cache_t cache, ca_ctx_t ctx);
ca_ext_ptr ca_ext_cache_insert(ca_ext_cache_t cache, const ca_ext_t x, ca_ctx_t ctx);
#ifdef __cplusplus
}
#endif
#endif