Line data Source code
1 : /* Copyright (C) 2004 The PARI group.
2 :
3 : This file is part of the PARI/GP package.
4 :
5 : PARI/GP is free software; you can redistribute it and/or modify it under the
6 : terms of the GNU General Public License as published by the Free Software
7 : Foundation; either version 2 of the License, or (at your option) any later
8 : version. It is distributed in the hope that it will be useful, but WITHOUT
9 : ANY WARRANTY WHATSOEVER.
10 :
11 : Check the License for details. You should have received a copy of it, along
12 : with the package; see the file 'COPYING'. If not, write to the Free Software
13 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
14 :
15 : BEGINEXTERN
16 :
17 : /* for qsort */
18 : typedef int (*QSCOMP)(const void *, const void *);
19 :
20 : #define uel(a,i) (((ulong*)(a))[i])
21 : #define ucoeff(a,i,j) (((ulong**)(a))[j][i])
22 : #define umael(a,i,j) (((ulong**)(a))[i][j])
23 : #define umael2(a,i,j) (((ulong**)(a))[i][j])
24 : #define umael3(a,i,j,k) (((ulong***)(a))[i][j][k])
25 : #define umael4(a,i,j,k,l) (((ulong****)(a))[i][j][k][l])
26 : #define umael5(a,i,j,k,l,m) (((ulong*****)(a))[i][j][k][l][m])
27 :
28 : #define numberof(x) (sizeof(x) / sizeof((x)[0]))
29 :
30 : /* to manipulate 'blocs' */
31 : #define BL_HEAD 8
32 : #define bl_base(x) (void*)((x) - BL_HEAD)
33 : #define bl_height(x) (((GEN)x)[-8])
34 : #define bl_left(x) (((GEN*)x)[-7])
35 : #define bl_right(x) (((GEN*)x)[-6])
36 : #define bl_size(x) (((GEN)x)[-5])
37 : #define bl_refc(x) (((GEN)x)[-4])
38 : #define bl_next(x) (((GEN*)x)[-3])
39 : #define bl_prev(x) (((GEN*)x)[-2])
40 : #define bl_num(x) (((GEN)x)[-1])
41 :
42 : void clone_lock(GEN C);
43 : void clone_unlock(GEN C);
44 : void clone_unlock_deep(GEN C);
45 :
46 : /* swap */
47 : #define lswap(x,y) {long _z=x; x=y; y=_z;}
48 : #define pswap(x,y) {GEN *_z=x; x=y; y=_z;}
49 : #define swap(x,y) {GEN _z=x; x=y; y=_z;}
50 : #define dswap(x,y) { double _t=x; x=y; y=_t; }
51 : #define pdswap(x,y) { double* _t=x; x=y; y=_t; }
52 : #define swapspec(x,y, nx,ny) {swap(x,y); lswap(nx,ny);}
53 :
54 : /* loops */
55 : GEN incloop(GEN a);
56 : GEN resetloop(GEN a, GEN b);
57 : GEN setloop(GEN a);
58 :
59 : /* parser */
60 :
61 : /* GP control structures */
62 : #define EXPR_WRAP(code, call) \
63 : { GEN z; GEN __E = code; \
64 : push_lex(gen_0, __E); z = call; pop_lex(1); return z; }
65 : #define EXPRVOID_WRAP(code, call) \
66 : { GEN __E = code; \
67 : push_lex(gen_0, __E); call; pop_lex(1); }
68 : #define EXPR_ARG __E, &gp_eval
69 : #define EXPR_ARGPREC __E, &gp_evalprec
70 : #define EXPR_ARGUPTO __E, &gp_evalupto
71 : #define EXPR_ARGBOOL __E, &gp_evalbool
72 : #define EXPR_ARGVOID __E, &gp_evalvoid
73 :
74 : GEN andpari(GEN a, GEN b);
75 : GEN orpari(GEN a, GEN b);
76 : void ifpari_void(GEN g, GEN a, GEN b);
77 : GEN ifpari_multi(GEN g, GEN a);
78 :
79 : GEN gadde(GEN *x, GEN y);
80 : GEN gadd1e(GEN *x);
81 : GEN gdive(GEN *x, GEN y);
82 : GEN gdivente(GEN *x, GEN y);
83 : GEN gdivrounde(GEN *x, GEN y);
84 : GEN gmode(GEN *x, GEN y);
85 : GEN gmule(GEN *x, GEN y);
86 : GEN gshiftle(GEN *x, long n);
87 : GEN gshiftre(GEN *x, long n);
88 : GEN gsube(GEN *x, GEN y);
89 : GEN gsub1e(GEN *x);
90 : GEN gshift_right(GEN x, long n);
91 :
92 : GEN derivfun0(GEN args, GEN def, GEN code, long k, long prec);
93 : GEN direuler_bad(void *E, GEN (*eval)(void *, GEN, long), GEN a, GEN b, GEN c, GEN Sbad);
94 : GEN vecexpr0(GEN nmax, GEN code, GEN pred);
95 : GEN vecexpr1(GEN nmax, GEN code, GEN pred);
96 :
97 : /* mt */
98 : void mt_sigint(void);
99 : void mt_err_recover(long er);
100 : void mt_break_recover(void);
101 : void mt_export_add(const char *str, GEN val);
102 : void mt_export_del(const char *str);
103 : void mt_init_stack(size_t s);
104 : int mt_is_thread(void);
105 : void mt_thread_init(void);
106 :
107 : GEN eisker_worker(GEN Ei, GEN M, GEN D, GEN co, GEN CD);
108 : GEN pareval_worker(GEN code);
109 : GEN parfor_worker(GEN i, GEN C);
110 : GEN parvector_worker(GEN i, GEN C);
111 : GEN polmodular_worker(GEN pt, ulong L, GEN hilb, GEN factu,
112 : GEN vne, GEN vinfo, long compute_derivs, GEN j_powers, GEN G_surface,
113 : GEN G_floor, GEN fdb);
114 : GEN polclass_worker(GEN p, GEN G, GEN db);
115 : GEN nf_L2_bound(GEN nf, GEN den, GEN *pL);
116 : GEN nmV_polint_center_tree_worker(GEN Va, GEN T, GEN R, GEN xa, GEN m2);
117 : GEN nmV_chinese_center_tree_seq(GEN A, GEN P, GEN T, GEN R);
118 : GEN nxMV_polint_center_tree_worker(GEN Va, GEN T, GEN R, GEN xa, GEN m2);
119 : GEN nxMV_chinese_center_tree_seq(GEN A, GEN P, GEN T, GEN R);
120 : GEN F2xq_log_Coppersmith_worker(GEN u, long i, GEN V, GEN R);
121 : GEN Flxq_log_Coppersmith_worker(GEN u, long i, GEN V, GEN R);
122 : GEN Fp_log_sieve_worker(long a, long prmax, GEN C, GEN c, GEN Ci, GEN ci, GEN pr, GEN sz);
123 : GEN QM_charpoly_ZX_worker(GEN P, GEN M, GEN dM);
124 : GEN QXQ_div_worker(GEN P, GEN A, GEN B, GEN C);
125 : GEN QXQ_inv_worker(GEN P, GEN A, GEN B);
126 : GEN RgM_ZM_mul_worker(GEN y, GEN x);
127 : GEN ZX_resultant_worker(GEN P, GEN A, GEN B, GEN dB);
128 : GEN ZXQX_resultant_worker(GEN P, GEN A, GEN B, GEN T, GEN dB);
129 : GEN ZX_ZXY_resultant_worker(GEN P, GEN A, GEN B, GEN dB, GEN v);
130 : GEN ZX_composedsum_worker(GEN P, GEN A, GEN B);
131 : GEN ZXQX_composedsum_worker(GEN P, GEN A, GEN B, GEN C);
132 : GEN ZX_gcd_worker(GEN P, GEN A, GEN B, GEN g);
133 : GEN ZXQ_minpoly_worker(GEN P, GEN A, GEN B, long d);
134 : GEN ZM_det_worker(GEN P, GEN A);
135 : GEN ZM_inv_worker(GEN P, GEN A);
136 : GEN ZM_ker_worker(GEN P, GEN A);
137 : GEN ZM_mul_worker(GEN P, GEN A, GEN B);
138 : GEN ZM_sqr_worker(GEN P, GEN A);
139 : GEN ZM_gauss_worker(GEN P, GEN A, GEN B);
140 : GEN ZabM_inv_worker(GEN P, GEN A, GEN Q);
141 : GEN aprcl_step4_worker(ulong q, GEN pC, GEN N, GEN v);
142 : GEN aprcl_step6_worker(GEN r, long t, GEN N, GEN N1, GEN et);
143 : GEN ecpp_sqrt_worker(GEN g, GEN N, GEN p);
144 : GEN ecpp_ispsp_worker(GEN N);
145 : GEN ecpp_step2_worker(GEN S, GEN HD, GEN primelist, long dbg);
146 : GEN primecertisvalid_ecpp_worker(GEN certi);
147 : GEN lfuninit_worker(long r, GEN K, GEN L, GEN peh2d, GEN vroots, GEN dr, GEN di, GEN an, GEN bn);
148 : GEN lfuninit_theta2_worker(long r, GEN L, GEN qk, GEN a, GEN di, GEN an, GEN bn);
149 : GEN gen_parapply(GEN worker, GEN D);
150 : GEN gen_parapply_percent(GEN worker, GEN D, long percent);
151 : GEN parapply_slice_worker(GEN worker, GEN D);
152 : GEN gen_parapply_slice(GEN worker, GEN D, long mmin);
153 : GEN gen_crt(const char *str, GEN worker, forprime_t *S, GEN dB, ulong bound, long mmin, GEN *pt_mod,
154 : GEN crt(GEN, GEN, GEN*), GEN center(GEN, GEN, GEN));
155 : void gen_inccrt(const char *str, GEN worker, GEN dB, long n, long mmin,
156 : forprime_t *S, GEN *pt_H, GEN *pt_mod, GEN crt(GEN, GEN, GEN*),
157 : GEN center(GEN, GEN, GEN));
158 : void gen_inccrt_i(const char *str, GEN worker, GEN dB, long n, long mmin,
159 : forprime_t *S, GEN *pH, GEN *pmod, GEN crt(GEN, GEN, GEN*),
160 : GEN center(GEN, GEN, GEN));
161 : GEN direllnf_worker(GEN P, ulong X, GEN E);
162 : GEN dirartin_worker(GEN P, ulong X, GEN nf, GEN G, GEN V, GEN aut);
163 : GEN direllsympow_worker(GEN P, ulong X, GEN E, ulong m);
164 : GEN dirgenus2_worker(GEN P, ulong X, GEN Q);
165 : GEN dirhgm_worker(GEN P, ulong X, GEN hgm, GEN t);
166 : GEN pardireuler(GEN worker, GEN a, GEN b, GEN c, GEN Sbad);
167 : GEN FpM_ratlift_worker(GEN A, GEN mod, GEN B);
168 : GEN ellQ_factorback_worker(GEN P, GEN E, GEN A, GEN L, ulong l);
169 : GEN chinese_unit_worker(GEN P, GEN A, GEN U, GEN B, GEN D, GEN C);
170 : GEN partmap_reverse_frac_worker(GEN t, GEN a, GEN b, GEN la, GEN lb, long v);
171 : GEN parsum_slice_worker(GEN a, GEN b, GEN m, GEN worker);
172 :
173 : /* Relative number fields */
174 : enum { rnf_NFABS = 1, rnf_MAPS };
175 :
176 : /* Finite fields */
177 : enum { t_FF_FpXQ = 0, t_FF_Flxq = 1, t_FF_F2xq = 2 };
178 : GEN FF_ellinit(GEN E, GEN fg);
179 : GEN FF_elldata(GEN E, GEN fg);
180 :
181 : /* L functions */
182 : enum { t_LFUN_GENERIC, t_LFUN_ZETA, t_LFUN_NF, t_LFUN_ELL, t_LFUN_KRONECKER,
183 : t_LFUN_CHIZ, t_LFUN_CHIGEN, t_LFUN_ETA,
184 : t_LFUN_DIV, t_LFUN_MUL, t_LFUN_CONJ,
185 : t_LFUN_SYMPOW_ELL, t_LFUN_QF, t_LFUN_ARTIN, t_LFUN_MFCLOS,
186 : t_LFUN_GENUS2, t_LFUN_TWIST, t_LFUN_CLOSURE0, t_LFUN_SHIFT,
187 : t_LFUN_HGM, t_LFUN_HECKE,t_LFUN_ABELREL};
188 : enum { t_LDESC_INIT, t_LDESC_THETA, t_LDESC_PRODUCT };
189 :
190 : /* Elliptic curves */
191 : /* common to Q and Rg */
192 : enum { R_PERIODS = 1, R_ETA, R_ROOTS, R_AB };
193 :
194 : enum { Qp_ROOT = 1, Qp_TATE };
195 : enum { Q_GROUPGEN = 5, Q_GLOBALRED, Q_ROOTNO, Q_MINIMALMODEL };
196 : enum { NF_MINIMALMODEL = 1, NF_GLOBALRED, NF_MINIMALPRIMES, NF_ROOTNO, NF_NF };
197 :
198 : /* common to Fp and Fq */
199 : enum { FF_CARD = 1, FF_GROUP, FF_GROUPGEN, FF_O };
200 :
201 : /* for Buchall_param */
202 : enum { fupb_NONE = 0, fupb_RELAT, fupb_LARGE, fupb_PRECI };
203 :
204 : /* Represents the data in the equation(s)
205 : * 4p = t^2 - v^2 D = t^2 - v^2 u^2 D_K = w^2 D_K.
206 : * t is the absolute trace, so always > 0.
207 : * T is a twisting parameter, which satisfies (T|p) == -1. */
208 : typedef struct {
209 : GEN faw; /* factor(u*v) */
210 : long D, t, u, v;
211 : ulong p, pi, s2, T;
212 : } norm_eqn_struct;
213 : typedef norm_eqn_struct norm_eqn_t[1];
214 : void norm_eqn_set(norm_eqn_t ne, long D,long t,long u,long v,GEN faw,ulong p);
215 :
216 : #define zv_to_longptr(v) (&((v)[1]))
217 : #define zv_to_ulongptr(v) ((ulong *)&((v)[1]))
218 :
219 : /* Modular invariants */
220 : #define INV_J 0
221 : #define INV_F 1
222 : #define INV_F2 2
223 : #define INV_F3 3
224 : #define INV_F4 4
225 : #define INV_G2 5
226 : #define INV_W2W3 6
227 : #define INV_F8 8
228 : #define INV_W3W3 9
229 : #define INV_W2W5 10
230 : #define INV_W2W7 14
231 : #define INV_W3W5 15
232 : #define INV_W3W7 21
233 : #define INV_W2W3E2 23
234 : #define INV_W2W5E2 24
235 : #define INV_W2W13 26
236 : #define INV_W2W7E2 27
237 : #define INV_W3W3E2 28
238 : #define INV_W5W7 35
239 : #define INV_W3W13 39
240 :
241 : /* Get coefficient of x^d in f, assuming f is nonzero. */
242 16938389 : INLINE ulong Flx_coeff(GEN f, long d) { return f[d + 2]; }
243 : /* Return the root of f, assuming deg(f) = 1. */
244 295206 : INLINE ulong Flx_deg1_root(GEN f, ulong p) {
245 295206 : if (degpol(f) != 1) pari_err_BUG("Flx_deg1_root");
246 295213 : return Fl_div(Fl_neg(Flx_coeff(f, 0), p), Flx_coeff(f, 1), p);
247 : }
248 :
249 : /* Allocation / gerepile */
250 : long getdebugvar(void);
251 : void setdebugvar(long n);
252 : void debug_stack(void);
253 : void minim_alloc(long n, double ***q, GEN *x, double **y, double **z, double **v);
254 : int pop_entree_block(entree *ep, long loc);
255 : int pop_val_if_newer(entree *ep, long loc);
256 :
257 : /* general printing */
258 : void print_errcontext(PariOUT *out, const char *msg, const char *s, const char *entry);
259 : void print_prefixed_text(PariOUT *out, const char *s, const char *prefix, const char *str);
260 : INLINE void
261 76 : print_text(const char *s) { print_prefixed_text(pariOut, s,NULL,NULL); }
262 : INLINE void
263 5327 : out_print_text(PariOUT *out, const char *s) { print_prefixed_text(out, s,NULL,NULL); }
264 : INLINE long
265 2537731 : is_keyword_char(char c) { return (isalnum((unsigned char)c) || c=='_'); }
266 :
267 : /* Interfaces (GP, etc.) */
268 : hashtable *hash_from_link(GEN e, GEN names, int use_stack);
269 : void gen_relink(GEN x, hashtable *table);
270 : entree* do_alias(entree *ep);
271 : char* get_sep(const char *t);
272 : long get_int(const char *s, long dflt);
273 : void gp_initrc(pari_stack *p_A);
274 :
275 : void pari_sigint(const char *s);
276 : void* get_stack(double fraction, long min);
277 : void free_graph(void);
278 : void initout(int initerr);
279 : void resetout(int initerr);
280 : void init_linewrap(long w);
281 : void print_functions_hash(const char *s);
282 : GEN readbin(const char *name, FILE *f, int *vector);
283 : int term_height(void);
284 : int term_width(void);
285 : /* gp_colors */
286 : void decode_color(long n, long *c);
287 :
288 : /* defaults */
289 : extern long precreal;
290 :
291 : void gen_output(GEN x);
292 : void fputGEN_pariout(GEN x, pariout_t *T, FILE *out);
293 :
294 : void parsestate_reset(void);
295 : void parsestate_save(struct pari_parsestate *state);
296 : void parsestate_restore(struct pari_parsestate *state);
297 :
298 : void compilestate_reset(void);
299 : void compilestate_save(struct pari_compilestate *comp);
300 : void compilestate_restore(struct pari_compilestate *comp);
301 :
302 : void filestate_save(struct pari_filestate *file);
303 : void filestate_restore(struct pari_filestate *file);
304 : void tmp_restore(pariFILE *F);
305 :
306 : long evalstate_get_trace(void);
307 : void evalstate_set_trace(long lvl);
308 : void evalstate_clone(void);
309 : void evalstate_reset(void);
310 : void evalstate_restore(struct pari_evalstate *state);
311 : GEN evalstate_restore_err(struct pari_evalstate *state);
312 : void evalstate_save(struct pari_evalstate *state);
313 : void varstate_save(struct pari_varstate *s);
314 : void varstate_restore(struct pari_varstate *s);
315 :
316 : void mtstate_save(struct pari_mtstate *s);
317 : void mtstate_reset(void);
318 : void mtstate_restore(struct pari_mtstate *s);
319 :
320 : void debug_context(void);
321 :
322 : typedef struct {
323 : const char *s;
324 : size_t ls;
325 : char **dir;
326 : } forpath_t;
327 : void forpath_init(forpath_t *T, gp_path *path, const char *s);
328 : char *forpath_next(forpath_t *T);
329 :
330 : /* GP output && output format */
331 : extern char *current_logfile;
332 :
333 : /* colors */
334 : extern long gp_colors[];
335 : extern int disable_color;
336 :
337 : /* entrees */
338 : #define EpVALENCE(ep) ((ep)->valence & 0xFF)
339 : #define EpSTATIC(ep) ((ep)->valence & 0x100)
340 : #define EpSETSTATIC(ep) ((ep)->valence |= 0x100)
341 : enum { EpNEW = 100, EpALIAS, EpVAR, EpINSTALL };
342 : #define initial_value(ep) ((ep)+1)
343 :
344 : /* functions lists */
345 : extern const long functions_tblsz; /* hashcodes table size */
346 : extern entree **functions_hash; /* functions hashtable */
347 : extern entree **defaults_hash; /* defaults hashtable */
348 :
349 : /* buffers */
350 : typedef struct Buffer {
351 : char *buf;
352 : ulong len;
353 : jmp_buf env;
354 : } Buffer;
355 : Buffer *new_buffer(void);
356 : void delete_buffer(Buffer *b);
357 : void fix_buffer(Buffer *b, long newlbuf);
358 :
359 : typedef struct {
360 : const char *s; /* source */
361 : char *t, *end; /* target, last char read */
362 : int in_string, in_comment, more_input, wait_for_brace;
363 : Buffer *buf;
364 : } filtre_t;
365 : void init_filtre(filtre_t *F, Buffer *buf);
366 : Buffer *filtered_buffer(filtre_t *F);
367 : void kill_buffers_upto_including(Buffer *B);
368 : void pop_buffer(void);
369 : void kill_buffers_upto(Buffer *B);
370 : int gp_read_line(filtre_t *F, const char *PROMPT);
371 : void parse_key_val(char *src, char **ps, char **pt);
372 : extern int (*cb_pari_get_line_interactive)(const char*, const char*, filtre_t *F);
373 : extern char *(*cb_pari_fgets_interactive)(char *s, int n, FILE *f);
374 : int get_line_from_file(const char *prompt, filtre_t *F, FILE *file);
375 : void pari_skip_space(char **s);
376 : void pari_skip_alpha(char **s);
377 : char *pari_translate_string(const char *src, char *s, char *entry);
378 :
379 : gp_data *default_gp_data(void);
380 :
381 : typedef char *(*fgets_t)(char *, int, void*);
382 :
383 : typedef struct input_method {
384 : /* optional */
385 : fgets_t myfgets; /* like libc fgets() but last argument is (void*) */
386 : /* mandatory */
387 : char * (*getline)(char**, int f, struct input_method*, filtre_t *F);
388 : int free; /* boolean: must we free the output of getline() ? */
389 : /* optional */
390 : const char *prompt, *prompt_cont;
391 : void *file; /* can be used as last argument for fgets() */
392 : } input_method;
393 :
394 : int input_loop(filtre_t *F, input_method *IM);
395 : char *file_input(char **s0, int junk, input_method *IM, filtre_t *F);
396 : char *file_getline(Buffer *b, char **s0, input_method *IM);
397 :
398 : /* readline */
399 : typedef struct {
400 : /* pointers to readline variables/functions */
401 : char **line_buffer;
402 : int *point;
403 : int *end;
404 : char **(*completion_matches)(const char *, char *(*)(const char*, int));
405 : char *(*filename_completion_function)(const char *, int);
406 : char *(*username_completion_function)(const char *, int);
407 : int (*insert)(int, int);
408 : int *completion_append_character;
409 :
410 : /* PARI-specific */
411 : int back; /* rewind the cursor by this number of chars */
412 : } pari_rl_interface;
413 :
414 : /* Code which wants to use readline needs to do the following:
415 :
416 : #include <readline/readline.h>
417 : #include <pari/paripriv.h>
418 : pari_rl_interface pari_rl;
419 : pari_use_readline(pari_rl);
420 :
421 : This will initialize the pari_rl structure. A pointer to this structure
422 : must be given as first argument to all PARI readline functions. */
423 :
424 : /* IMPLEMENTATION NOTE: this really must be a macro (not a function),
425 : * since we refer to readline symbols. */
426 : #define pari_use_readline(pari_rl) do {\
427 : (pari_rl).line_buffer = &rl_line_buffer; \
428 : (pari_rl).point = &rl_point; \
429 : (pari_rl).end = &rl_end; \
430 : (pari_rl).completion_matches = &rl_completion_matches; \
431 : (pari_rl).filename_completion_function = &rl_filename_completion_function; \
432 : (pari_rl).username_completion_function = &rl_username_completion_function; \
433 : (pari_rl).insert = &rl_insert; \
434 : (pari_rl).completion_append_character = &rl_completion_append_character; \
435 : (pari_rl).back = 0; } while(0)
436 :
437 : /* FIXME: EXPORT AND DOCUMENT THE FOLLOWING */
438 :
439 : /* PROBABLY NOT IN THE RIGHT FILE, SORT BY THEME */
440 :
441 : /* multiprecision */
442 : GEN adduispec_offset(ulong s, GEN x, long offset, long nx);
443 : int lgcdii(ulong* d, ulong* d1, ulong* u, ulong* u1, ulong* v, ulong* v1, ulong vmax);
444 : ulong rgcduu(ulong d, ulong d1, ulong vmax, ulong* u, ulong* u1, ulong* v, ulong* v1, long *s);
445 : ulong xgcduu(ulong d, ulong d1, int f, ulong* v, ulong* v1, long *s);
446 : ulong xxgcduu(ulong d, ulong d1, int f, ulong* u, ulong* u1, ulong* v, ulong* v1, long *s);
447 : GEN muliispec(GEN x, GEN y, long nx, long ny);
448 : GEN red_montgomery(GEN T, GEN N, ulong inv);
449 : GEN sqrispec(GEN x, long nx);
450 : ulong *convi(GEN x, long *l);
451 :
452 : /* powers */
453 : GEN rpowuu(ulong a, ulong n, long prec);
454 :
455 : /* floats */
456 : double dabs(double s, double t);
457 : double darg(double s, double t);
458 : void dcxlog(double s, double t, double *a, double *b);
459 : double dnorm(double s, double t);
460 : double dbllog2(GEN z);
461 : double dbllambertW0(double a);
462 : double dbllambertW_1(double a);
463 :
464 : /* hnf */
465 : GEN hnfadd(GEN m,GEN p,GEN* ptdep,GEN* ptA,GEN* ptC,GEN extramat,GEN extraC);
466 : GEN hnfadd_i(GEN m,GEN p,GEN* ptdep,GEN* ptA,GEN* ptC,GEN extramat,GEN extraC);
467 : GEN hnfspec_i(GEN m,GEN p,GEN* ptdep,GEN* ptA,GEN* ptC,long k0);
468 : GEN hnfspec(GEN m,GEN p,GEN* ptdep,GEN* ptA,GEN* ptC,long k0);
469 : GEN mathnfspec(GEN x, GEN *ptperm, GEN *ptdep, GEN *ptB, GEN *ptC);
470 : GEN ZM_hnfmodall_i(GEN x, GEN dm, long flag);
471 :
472 : GEN LLL_check_progress(GEN Bnorm, long n0, GEN m, int final, long *ti_LLL);
473 :
474 : /* integer factorization / discrete log */
475 : ulong is_kth_power(GEN x, ulong p, GEN *pt);
476 : GEN mpqs(GEN N);
477 :
478 : /* Polynomials */
479 : /* a) Arithmetic/conversions */
480 : GEN lift_if_rational(GEN x);
481 : GEN monomial(GEN a, long degpol, long v);
482 : GEN monomialcopy(GEN a, long degpol, long v);
483 : GEN ser2pol_i(GEN x, long lx);
484 : GEN ser2pol_i_normalize(GEN x, long l, long *v);
485 : GEN ser2rfrac_i(GEN x);
486 : GEN swap_vars(GEN b0, long v);
487 : GEN RgX_recipspec_shallow(GEN x, long l, long n);
488 :
489 : /* b) Modular */
490 : GEN bezout_lift_fact(GEN T, GEN Tmod, GEN p, long e);
491 : GEN polsym_gen(GEN P, GEN y0, long n, GEN T, GEN N);
492 : GEN ZXQ_charpoly_sqf(GEN A, GEN B, long *lambda, long v);
493 : GEN ZX_disc_all(GEN,ulong);
494 : GEN ZX_resultant_all(GEN A, GEN B, GEN dB, ulong bound);
495 : GEN ZX_ZXY_resultant_all(GEN A, GEN B, long *lambda, GEN *LPRS);
496 :
497 : GEN FlxqM_mul_Kronecker(GEN A, GEN B, GEN T, ulong p);
498 : GEN FqM_mul_Kronecker(GEN x, GEN y, GEN T, GEN p);
499 :
500 : /* c) factorization */
501 : GEN chk_factors_get(GEN lt, GEN famod, GEN c, GEN T, GEN N);
502 : long cmbf_maxK(long nb);
503 : GEN ZX_DDF(GEN x);
504 : GEN ZX_DDF_max(GEN x, long dmax);
505 : GEN initgaloisborne(GEN T, GEN dn, long prec, GEN *pL, GEN *pprep, GEN *pdis);
506 :
507 : /* number fields */
508 : GEN nflist_C3_worker(GEN gv, GEN T);
509 : GEN nflist_C4vec_worker(GEN gm, GEN X, GEN Xinf, GEN gs);
510 : GEN nflist_V4_worker(GEN D1, GEN X, GEN Xinf, GEN gs);
511 : GEN nflist_D4_worker(GEN D, GEN X, GEN Xinf, GEN listarch);
512 : GEN nflist_A4S4_worker(GEN P3, GEN X, GEN Xinf, GEN cards);
513 : GEN nflist_C5_worker(GEN N, GEN bnfC5);
514 : GEN nflist_CL_worker(GEN Fcond, GEN bnf, GEN ellprec);
515 : GEN nflist_DL_worker(GEN P2, GEN X1pow, GEN X0pow, GEN X, GEN Xinf, GEN ells);
516 : GEN nflist_Mgen_worker(GEN field, GEN X, GEN Xinf, GEN ella);
517 : GEN nflist_C6_worker(GEN P3, GEN X, GEN Xinf, GEN M, GEN T);
518 : GEN nflist_D612_worker(GEN P3, GEN X, GEN Xinf, GEN limd2s2);
519 : GEN nflist_A46S46P_worker(GEN P3, GEN Xinf, GEN sqX, GEN cards);
520 : GEN nflist_S46M_worker(GEN P3, GEN X, GEN Xinf, GEN gs);
521 : GEN nflist_A462_worker(GEN P3, GEN X, GEN Xinf, GEN listarch, GEN GAL);
522 : GEN nflist_S3C3_worker(GEN D2, GEN X, GEN Xinf);
523 : GEN nflist_S462_worker(GEN P3, GEN X, GEN Xinf, GEN listarch13, GEN GAL);
524 : GEN nflist_S36_worker(GEN pol, GEN X, GEN Xinf);
525 : GEN nflist_C32C4_worker(GEN P4, GEN X, GEN Xinf, GEN GAL);
526 : GEN nflist_C32D4_worker(GEN P, GEN X, GEN Xinf, GEN gs);
527 : GEN nflist_C9_worker(GEN P, GEN X, GEN Xinf);
528 : GEN nflist_C3C3_worker(GEN gi, GEN V3, GEN V3D, GEN X);
529 : GEN nflist_S3R_worker(GEN ga, GEN ALLCTS);
530 : GEN nflist_S3I_worker(GEN ga, GEN ALLCTS);
531 : GEN nflist_D9_worker(GEN P2, GEN X, GEN Xinf);
532 : GEN nflist_S32_worker(GEN all1, GEN X, GEN Xinf, GEN V3, GEN gs);
533 :
534 : /* pari_init / pari_close */
535 : void pari_close_compiler(void);
536 : void pari_close_evaluator(void);
537 : void pari_close_files(void);
538 : void pari_close_floats(void);
539 : void pari_close_homedir(void);
540 : void pari_close_parser(void);
541 : void pari_close_paths(void);
542 : void pari_close_primes(void);
543 : void pari_init_buffers(void);
544 : void pari_init_compiler(void);
545 : void pari_init_defaults(void);
546 : void pari_init_ellcondfile(void);
547 : void pari_init_evaluator(void);
548 : void pari_init_files(void);
549 : void pari_init_floats(void);
550 : void pari_close_hgm(void);
551 : void pari_init_hgm(void);
552 : void pari_init_homedir(void);
553 : void pari_init_graphics(void);
554 : void pari_init_parser(void);
555 : void pari_init_rand(void);
556 : void pari_init_paths(void);
557 : void pari_init_primetab(void);
558 : void pari_init_seadata(void);
559 : GEN pari_get_seadata(void);
560 : void pari_set_primetab(GEN global_primetab);
561 : void pari_set_seadata(GEN seadata);
562 : void pari_set_varstate(long *vp, struct pari_varstate *vs);
563 : void pari_thread_close_files(void);
564 :
565 : void export_add(const char *str, GEN val);
566 : void export_del(const char *str);
567 : GEN export_get(const char *str);
568 :
569 : /* BY FILES */
570 :
571 : /* parinf.h */
572 :
573 : GEN coltoalg(GEN nf,GEN x);
574 : GEN fincke_pohst(GEN a,GEN BOUND,long stockmax,long PREC, FP_chk_fun *CHECK);
575 : void init_zlog(zlog_S *S, GEN bid);
576 : GEN log_gen_arch(zlog_S *S, long index);
577 : GEN log_gen_pr(zlog_S *S, long index, GEN nf, long e);
578 : GEN make_integral(GEN nf, GEN L0, GEN f, GEN listpr);
579 : GEN poltobasis(GEN nf,GEN x);
580 : GEN rnfdisc_get_T(GEN nf, GEN P, GEN *lim);
581 : GEN rnfallbase(GEN nf, GEN pol, GEN lim, GEN eq, GEN *pD, GEN *pfi, GEN *pdKP);
582 : GEN sprk_log_gen_pr(GEN nf, GEN sprk, long e);
583 : GEN sprk_log_gen_pr2(GEN nf, GEN sprk, long e);
584 : GEN sprk_log_prk1(GEN nf, GEN a, GEN sprk);
585 : GEN sprk_to_bid(GEN nf, GEN L, long flag);
586 : GEN subgroupcondlist(GEN cyc, GEN bound, GEN listKer);
587 :
588 : /* Qfb.c */
589 :
590 : GEN redimagsl2(GEN q, GEN *U);
591 :
592 : /* alglin1.c */
593 :
594 : typedef long (*pivot_fun)(GEN,GEN,long,GEN);
595 : GEN ZM_pivots(GEN x0, long *rr);
596 : GEN RgM_pivots(GEN x0, GEN data, long *rr, pivot_fun pivot);
597 : void RgMs_structelim_col(GEN M, long nbcol, long nbrow, GEN A, GEN *p_col, GEN *p_lin);
598 :
599 : /* arith1.c */
600 :
601 : int is_gener_Fp(GEN x, GEN p, GEN p_1, GEN L);
602 : int is_gener_Fl(ulong x, ulong p, ulong p_1, GEN L);
603 :
604 : /* arith2.c */
605 :
606 : int divisors_init(GEN n, GEN *pP, GEN *pE);
607 : long set_optimize(long what, GEN g);
608 :
609 : /* base1.c */
610 :
611 : GEN zk_galoisapplymod(GEN nf, GEN z, GEN S, GEN p);
612 : int ZX_canon_neg(GEN z);
613 :
614 : /* base2.c */
615 :
616 : GEN dim1proj(GEN prh);
617 : GEN gen_if_principal(GEN bnf, GEN x);
618 :
619 : /* base3.c */
620 :
621 : void check_nfelt(GEN x, GEN *den);
622 : GEN zk_ei_mul(GEN nf, GEN x, long i);
623 : GEN log_prk(GEN nf, GEN a, GEN sprk, GEN mod);
624 : GEN log_prk_units(GEN nf, GEN D, GEN sprk);
625 : GEN log_prk_units_init(GEN bnf);
626 : GEN veclog_prk(GEN nf, GEN v, GEN sprk);
627 : GEN log_prk_init(GEN nf, GEN pr, long k, GEN mod);
628 : GEN check_mod_factored(GEN nf, GEN ideal, GEN *fa, GEN *fa2, GEN *archp, GEN MOD);
629 : GEN sprk_get_cyc(GEN s);
630 : GEN sprk_get_expo(GEN s);
631 : GEN sprk_get_gen(GEN s);
632 : GEN sprk_get_prk(GEN s);
633 : GEN sprk_get_ff(GEN s);
634 : GEN sprk_get_pr(GEN s);
635 : void sprk_get_AgL2(GEN s, GEN *A, GEN *g, GEN *L2);
636 : void sprk_get_U2(GEN s, GEN *U1, GEN *U2);
637 : GEN famat_zlog_pr(GEN nf, GEN g, GEN e, GEN sprk, GEN mod);
638 :
639 : /* base4.c */
640 :
641 : GEN factorbackprime(GEN nf, GEN L, GEN e);
642 :
643 : /* base5.c */
644 :
645 : GEN condliftA4(GEN nf);
646 : GEN condliftA5(GEN nf);
647 : GEN condliftS4(GEN nf);
648 :
649 : /* bb_group.c */
650 :
651 : GEN producttree_scheme(long n);
652 :
653 : /* bern.c */
654 : long bernbitprec(long N);
655 :
656 : /* bibli2.c */
657 :
658 : GEN sort_factor_pol(GEN y, int (*cmp)(GEN,GEN));
659 :
660 : /* buch1.c */
661 :
662 : ulong bnf_increase_LIMC(ulong LIMC, ulong LIMCMAX);
663 :
664 : /* buch2.c */
665 :
666 : typedef struct GRHprime_t { ulong p; double logp; GEN dec; } GRHprime_t;
667 : typedef struct GRHcheck_t { double cD, cN; GRHprime_t *primes; long clone, nprimes, maxprimes; ulong limp; forprime_t P; } GRHcheck_t;
668 : void free_GRHcheck(GRHcheck_t *S);
669 : void init_GRHcheck(GRHcheck_t *S, long N, long R1, double LOGD);
670 : void GRH_ensure(GRHcheck_t *S, long nb);
671 : ulong GRH_last_prime(GRHcheck_t *S);
672 : int GRHok(GRHcheck_t *S, double L, double SA, double SB);
673 : GEN extract_full_lattice(GEN x);
674 : GEN init_red_mod_units(GEN bnf, long prec);
675 : GEN isprincipalarch(GEN bnf, GEN col, GEN kNx, GEN e, GEN dx, long *pe);
676 : GEN red_mod_units(GEN col, GEN z);
677 :
678 : /* buch3.c */
679 :
680 : GEN minkowski_bound(GEN D, long N, long r2, long prec);
681 : int subgroup_conductor_ok(GEN H, GEN L);
682 : GEN subgrouplist_cond_sub(GEN bnr, GEN C, GEN bound);
683 :
684 : /* crvwtors.c */
685 :
686 : void random_curves_with_m_torsion(ulong *a4, ulong *a6, ulong *tx, ulong *ty, long ncurves, long m, ulong p, ulong pi);
687 :
688 : /* dirichlet.c */
689 :
690 : GEN direuler_factor(GEN s, long n);
691 : GEN parsqf_worker(GEN gk, GEN vR, GEN data);
692 : GEN parsumprimefun_worker(GEN gk, GEN s, GEN zerf, GEN data, GEN vW, GEN f);
693 :
694 : /* ellanal.c */
695 :
696 : GEN hnaive_max(GEN ell, GEN ht);
697 :
698 : /* elliptic.c */
699 :
700 : GEN ellQ_genreduce(GEN E, GEN G, GEN M, long prec);
701 : GEN ellQ_isdivisible(GEN E, GEN P, ulong l);
702 : GEN ellminimalbmodel(GEN E, GEN *ptv);
703 : GEN ellintegralbmodel(GEN e, GEN *pv);
704 : void ellprint(GEN e);
705 :
706 : /* ellrank.c */
707 :
708 : GEN ell2selmer_basis(GEN ell, GEN *cb, long prec);
709 :
710 : /* es.c */
711 :
712 : void killallfiles(void);
713 : pariFILE* newfile(FILE *f, const char *name, int type);
714 : int popinfile(void);
715 : pariFILE* try_pipe(const char *cmd, int flag);
716 :
717 : /* F2m.c */
718 :
719 : GEN F2m_gauss_pivot(GEN x, long *rr);
720 : GEN F2m_gauss_sp(GEN a, GEN b);
721 : GEN F2m_invimage_i(GEN A, GEN B);
722 :
723 : /* Fle.c */
724 :
725 : void FleV_add_pre_inplace(GEN P, GEN Q, GEN a4, ulong p, ulong pi);
726 : void FleV_dbl_pre_inplace(GEN P, GEN a4, ulong p, ulong pi);
727 : void FleV_mulu_pre_inplace(GEN P, ulong n, GEN a4, ulong p, ulong pi);
728 : void FleV_sub_pre_inplace(GEN P, GEN Q, GEN a4, ulong p, ulong pi);
729 :
730 : /* Flv.c */
731 :
732 : GEN Flm_gauss_sp(GEN a, GEN b, ulong *detp, ulong p);
733 : GEN Flm_invimage_i(GEN A, GEN B, ulong p);
734 : GEN Flm_inv_sp(GEN a, ulong *detp, ulong p);
735 : GEN Flm_pivots(GEN x, ulong p, long *rr, long inplace);
736 :
737 : /* Flxq_log.c */
738 :
739 : GEN Flxq_log_index(GEN a0, GEN b0, GEN m, GEN T0, ulong p);
740 : int Flxq_log_use_index(GEN m, GEN T0, ulong p);
741 :
742 : /* FlxqE.c */
743 :
744 : GEN ZpXQ_norm_pcyc(GEN x, GEN T, GEN q, GEN p);
745 : long zx_is_pcyc(GEN T);
746 :
747 : /* FpV.c */
748 :
749 : GEN FpMs_leftkernel_elt_col(GEN M, long nbcol, long nbrow, GEN p);
750 : GEN FpX_to_mod_raw(GEN z, GEN p);
751 :
752 : /* FpX.c */
753 :
754 : GEN ZlXQXn_expint(GEN h, long e, GEN T, GEN p, ulong pp);
755 :
756 : /* FpX_factor.c */
757 :
758 : GEN ddf_to_ddf2(GEN V);
759 : long ddf_to_nbfact(GEN D);
760 : GEN vddf_to_simplefact(GEN V, long d);
761 :
762 : /* FpXQX_factor.c */
763 :
764 : GEN FpXQX_factor_Berlekamp(GEN x, GEN T, GEN p);
765 :
766 : /* forprime.c*/
767 :
768 : void init_modular_big(forprime_t *S);
769 : void init_modular_small(forprime_t *S);
770 :
771 : /* galconj.c */
772 :
773 : GEN galoiscosets(GEN O, GEN perm);
774 : GEN galoisinitfromaut(GEN T, GEN aut, ulong l);
775 : GEN matrixnorm(GEN M, long prec);
776 :
777 : /* gen1.c */
778 :
779 : GEN gred_rfrac_simple(GEN n, GEN d);
780 : GEN sqr_ser_part(GEN x, long l1, long l2);
781 :
782 : /* hash.c */
783 :
784 : hashtable *hashstr_import_static(hashentry *e, ulong size);
785 :
786 : /* hyperell.c */
787 :
788 : GEN ZlXQX_hyperellpadicfrobenius(GEN H, GEN T, ulong p, long n);
789 : GEN hyperellextremalmodels(GEN F, long g, GEN p);
790 :
791 : /* intnum.c */
792 :
793 : GEN contfraceval_inv(GEN CF, GEN tinv, long nlim);
794 : GEN contfracinit_i(GEN M, long n);
795 :
796 : /* lfunlarge.c */
797 :
798 : GEN int_h0_worker(GEN j, GEN sel, GEN s, GEN chi, GEN gprec);
799 :
800 : /* FIXME: delete */
801 : GEN lerchzetalarge(GEN s, GEN a, GEN lam, long prec);
802 : GEN lfunloglambdalarge(GEN CHI, GEN s, long bitprec);
803 : GEN lfunlambdalarge(GEN CHI, GEN s, long bitprec);
804 : GEN lfunlarge(GEN CHI, GEN s, long bitprec);
805 : GEN zetahurwitzlarge(GEN s, GEN a, long prec);
806 : GEN serh_worker(GEN gk, GEN V, GEN a, GEN ns, GEN gprec);
807 :
808 : /* mftrace.c */
809 :
810 : void pari_close_mf(void);
811 : long polishomogeneous(GEN P);
812 : GEN sertocol(GEN S);
813 : GEN mfrhopol(long n);
814 : GEN mfrhopol_u_eval(GEN Q, ulong t2);
815 : GEN mfrhopol_eval(GEN Q, GEN t2);
816 :
817 : /* prime.c */
818 :
819 : long BPSW_psp_nosmalldiv(GEN N);
820 : int MR_Jaeschke(GEN n);
821 : long Z_isanypower_nosmalldiv(GEN N, ulong cutoff, GEN *px);
822 :
823 : /* perm.c */
824 :
825 : long cosets_perm_search(GEN C, GEN p);
826 : GEN perm_generate(GEN S, GEN H, long o);
827 : long perm_relorder(GEN p, GEN S);
828 : GEN vecperm_extendschreier(GEN C, GEN v, long n);
829 :
830 : /* polclass.c */
831 :
832 : GEN polclass0(long D, long inv, long vx, GEN *db);
833 :
834 : /* polmodular.c */
835 :
836 : GEN polmodular0_ZM(long L, long inv, GEN J, GEN Q, int compute_derivs, GEN *db);
837 : GEN Flm_Fl_polmodular_evalx(GEN phi, long L, ulong j, ulong p, ulong pi);
838 : GEN polmodular_db_init(long inv);
839 : void polmodular_db_clear(GEN db);
840 : void polmodular_db_add_level(GEN *db, long L, long inv);
841 : void polmodular_db_add_levels(GEN *db, long *levels, long k, long inv);
842 : GEN polmodular_db_for_inv(GEN db, long inv);
843 : GEN polmodular_db_getp(GEN fdb, long L, ulong p);
844 :
845 : long modinv_level(long inv);
846 : long modinv_degree(long *p1, long *p2, long inv);
847 : long modinv_ramified(long D, long inv, long *pN);
848 : long modinv_j_from_2double_eta(GEN F, long inv, ulong x0, ulong x1, ulong p, ulong pi);
849 : GEN double_eta_raw(long inv);
850 : ulong modfn_root(ulong j, norm_eqn_t ne, long inv);
851 : long modfn_unambiguous_root(ulong *r, long inv, ulong j0, norm_eqn_t ne, GEN jdb);
852 : GEN qfb_nform(long D, long n);
853 :
854 : /* Fle.c */
855 :
856 : ulong Flj_order_ufact(GEN P, ulong n, GEN F, ulong a4, ulong p, ulong pi);
857 :
858 : /* polarit3.c */
859 :
860 : GEN Flm_Frobenius_pow(GEN M, long d, GEN T, ulong p);
861 : GEN FpM_Frobenius_pow(GEN M, long d, GEN T, GEN p);
862 : GEN RgXQ_charpoly_i(GEN x, GEN T, long v);
863 : ulong ZX_ZXY_ResBound(GEN A, GEN B, GEN dB);
864 : GEN ffinit_Artin_Schreier(ulong p, long l);
865 : GEN ffinit_rand(GEN p, long n);
866 : GEN nf_direct_compositum(GEN nf, GEN A, GEN B);
867 :
868 : /* nflist.c */
869 :
870 : GEN veccond_to_A5(GEN L, long s);
871 : long ceilsqrtdiv(GEN x, GEN y);
872 :
873 : /* nflistQT.c */
874 :
875 : GEN nflistQT(long n, long k, long v);
876 :
877 : /* ramanujantau.c */
878 : GEN ramanujantau_worker(GEN gt, GEN p2_7, GEN p_9, GEN p);
879 : GEN taugen_n_worker(GEN t, GEN pol, GEN p4);
880 :
881 : /* readline.c */
882 :
883 : char** pari_completion(pari_rl_interface *pari_rl, char *text, int START, int END);
884 : char** pari_completion_matches(pari_rl_interface *pari_rl, const char *s, long pos, long *wordpos);
885 :
886 : /* subcyclo.c */
887 :
888 : GEN galoiscyclo(long n, long v);
889 : long subcyclo_nH(const char *fun, GEN N, GEN *psg);
890 : GEN znstar_bits(long n, GEN H);
891 : long znstar_conductor(GEN H);
892 : long znstar_conductor_bits(GEN bits);
893 : GEN znstar_cosets(long n, long phi_n, GEN H);
894 : GEN znstar_elts(long n, GEN H);
895 : GEN znstar_generate(long n, GEN V);
896 : GEN znstar_hnf(GEN Z, GEN M);
897 : GEN znstar_hnf_elts(GEN Z, GEN H);
898 : GEN znstar_hnf_generators(GEN Z, GEN M);
899 : GEN znstar_reduce_modulus(GEN H, long n);
900 : GEN znstar_small(GEN zn);
901 :
902 : /* trans1.c */
903 :
904 : struct abpq { GEN *a, *b, *p, *q; };
905 : struct abpq_res { GEN P, Q, B, T; };
906 : void abpq_init(struct abpq *A, long n);
907 : void abpq_sum(struct abpq_res *r, long n1, long n2, struct abpq *A);
908 : GEN logagmcx(GEN q, long prec);
909 : GEN zellagmcx(GEN a0, GEN b0, GEN r, GEN t, long prec);
910 :
911 : /* trans2.c */
912 :
913 : GEN trans_fix_arg(long *prec, GEN *s0, GEN *sig, GEN *tau, pari_sp *av, GEN *res);
914 :
915 : /* trans3.c */
916 :
917 : GEN double_eta_quotient(GEN a, GEN w, GEN D, long p, long q, GEN pq, GEN sqrtD);
918 : GEN inv_szeta_euler(long n, long prec);
919 : GEN lerch_worker(GEN t, GEN E);
920 :
921 : /* volcano.c */
922 :
923 : long j_level_in_volcano(GEN phi, ulong j, ulong p, ulong pi, long L, long depth);
924 : ulong ascend_volcano(GEN phi, ulong j, ulong p, ulong pi, long level, long L, long depth, long steps);
925 : ulong descend_volcano(GEN phi, ulong j, ulong p, ulong pi, long level, long L, long depth, long steps);
926 : long next_surface_nbr(ulong *nJ, GEN phi, long L, long h, ulong J, const ulong *pJ, ulong p, ulong pi);
927 : GEN enum_roots(ulong j, norm_eqn_t ne, GEN fdb, GEN G, GEN vshape);
928 :
929 : ENDEXTERN
|