Annotation of OpenXM_contrib2/asir2000/builtin/parif.c, Revision 1.27
1.27 ! noro 1: /* $OpenXM: OpenXM_contrib2/asir2000/builtin/parif.c,v 1.26 2015/08/18 02:26:05 noro Exp $ */
1.1 noro 2: #include "ca.h"
3: #include "parse.h"
1.19 noro 4: #include "ox.h"
1.1 noro 5:
1.19 noro 6: Q ox_pari_stream;
7: int ox_pari_stream_initialized = 0;
1.1 noro 8:
1.24 noro 9: typedef void (*mpfr_func)(NODE,Obj *);
10:
11: void Pmpfr_ai();
12: void Pmpfr_eint(), Pmpfr_erf(),Pmpfr_li2();
13: void Pmpfr_zeta();
14: void Pmpfr_j0(), Pmpfr_j1();
15: void Pmpfr_y0(), Pmpfr_y1();
16: void Pmpfr_gamma(), Pmpfr_lngamma(), Pmpfr_digamma();
17: void Pmpfr_floor(), Pmpfr_round(), Pmpfr_ceil();
18:
19: struct mpfr_tab_rec {
20: char *name;
21: mpfr_func func;
22: } mpfr_tab[] = {
23: {"ai",Pmpfr_ai},
24: {"zeta",Pmpfr_zeta},
25: {"j0",Pmpfr_j0},
26: {"j1",Pmpfr_j1},
27: {"y0",Pmpfr_y0},
28: {"y1",Pmpfr_y1},
29: {"eint",Pmpfr_eint},
30: {"erf",Pmpfr_erf},
31: {"li2",Pmpfr_li2},
32: {"gamma",Pmpfr_gamma},
33: {"lngamma",Pmpfr_gamma},
34: {"digamma",Pmpfr_gamma},
35: {"floor",Pmpfr_floor},
36: {"ceil",Pmpfr_ceil},
37: {"round",Pmpfr_round},
38: };
39:
40: mpfr_func mpfr_search(char *name)
41: {
42: int i,n;
43:
44: n = sizeof(mpfr_tab)/sizeof(struct mpfr_tab_rec);
45: for ( i = 0; i < n; i++ )
46: if ( !strcmp(name,mpfr_tab[i].name) )
47: return mpfr_tab[i].func;
48: return 0;
49: }
50:
1.19 noro 51: pointer evalparif(FUNC f,NODE arg)
1.1 noro 52: {
1.19 noro 53: int ac,intarg,opt,prec;
54: Q q,r,narg;
1.25 noro 55: NODE nd,oxarg,t,t1,n;
1.19 noro 56: STRING name;
57: USINT ui;
58: Obj ret,dmy;
1.24 noro 59: mpfr_func mpfr_function;
1.19 noro 60:
1.24 noro 61: if ( mpfr_function = mpfr_search(f->name) ) {
62: (*mpfr_function)(arg,&ret);
63: return (pointer) ret;
1.20 takayama 64: }
1.24 noro 65:
1.19 noro 66: if ( !ox_pari_stream_initialized ) {
67: MKSTR(name,"ox_pari");
68: nd = mknode(2,NULL,name);
1.27 ! noro 69: Pox_launch_nox(nd,&r);
1.19 noro 70: ox_pari_stream = r;
71: ox_pari_stream_initialized = 1;
72: }
1.25 noro 73:
74: ac = argc(arg);
75: /* reverse the arg list */
76: for ( n = arg, t = 0; n; n = NEXT(n) ) {
77: MKNODE(t1,BDY(n),t); t = t1;
78: }
79: /* push the reversed arg list */
80: for ( ; t; t = NEXT(t) ) {
81: oxarg = mknode(2,ox_pari_stream,BDY(t));
82: Pox_push_cmo(oxarg,&dmy);
83: }
84: MKSTR(name,f->name);
85: STOQ(ac,narg);
86: oxarg = mknode(3,ox_pari_stream,name,narg);
87: Pox_execute_function(oxarg,&dmy);
88: oxarg = mknode(1,ox_pari_stream);
89: Pox_pop_cmo(oxarg,&r);
90: return r;
1.1 noro 91: }
92:
93: struct pariftab {
94: char *name;
1.19 noro 95: int dmy;
1.1 noro 96: int type;
97: };
98:
1.8 noro 99: /*
100: * type = 1 => argc = 1, second arg = precision
101: * type = 2 => argc = 1, second arg = optional (long int)
102: *
103: */
1.19 noro 104: /*
105: {"abs",0,1},
106: {"adj",0,1},
107: */
1.8 noro 108:
1.1 noro 109: struct pariftab pariftab[] = {
1.19 noro 110: {"arg",0,1},
111: {"bigomega",0,1},
112: {"binary",0,1},
113: {"ceil",0,1},
114: {"centerlift",0,1},
115: {"cf",0,1},
116: {"classno",0,1},
117: {"classno2",0,1},
118: {"conj",0,1},
119: {"content",0,1},
120: {"denom",0,1},
121: {"det",0,1},
122: {"det2",0,1},
123: {"dilog",0,1},
124: {"disc",0,1},
125: {"discf",0,1},
126: {"divisors",0,1},
127: {"eigen",0,1},
128: {"eintg1",0,1},
129: {"erfc",0,1},
130: {"eta",0,1},
131: {"floor",0,1},
132: {"frac",0,1},
133: {"galois",0,1},
134: {"galoisconj",0,1},
135: {"gamh",0,1},
136: {"gamma",0,1},
137: {"hclassno",0,1},
138: {"hermite",0,1},
139: {"hess",0,1},
140: {"imag",0,1},
141: {"image",0,1},
142: {"image2",0,1},
143: {"indexrank",0,1},
144: {"indsort",0,1},
145: {"initalg",0,1},
146: {"isfund",0,1},
147: {"ispsp",0,1},
148: {"isqrt",0,1},
149: {"issqfree",0,1},
150: {"issquare",0,1},
151: {"jacobi",0,1},
152: {"jell",0,1},
153: {"ker",0,1},
154: {"keri",0,1},
155: {"kerint",0,1},
156: {"kerintg1",0,1},
157: {"length",0,1},
158: {"lexsort",0,1},
159: {"lift",0,1},
160: {"lindep",0,1},
161: {"lll",0,1},
162: {"lllgen",0,1},
163: {"lllgram",0,1},
164: {"lllgramgen",0,1},
165: {"lllgramint",0,1},
166: {"lllgramkerim",0,1},
167: {"lllgramkerimgen",0,1},
168: {"lllint",0,1},
169: {"lllkerim",0,1},
170: {"lllkerimgen",0,1},
171: {"lngamma",0,1},
172: {"logagm",0,1},
173: {"mat",0,1},
174: {"matrixqz2",0,1},
175: {"matrixqz3",0,1},
176: {"matsize",0,1},
177: {"modreverse",0,1},
178: {"mu",0,1},
179: {"nextprime",0,1},
180: {"norm",0,1},
181: {"norml2",0,1},
182: {"numdiv",0,1},
183: {"numer",0,1},
184: {"omega",0,1},
185: {"order",0,1},
186: {"ordred",0,1},
187: {"phi",0,1},
188: {"pnqn",0,1},
189: {"polred",0,1},
190: {"polred2",0,1},
191: {"primroot",0,1},
192: {"psi",0,1},
193: {"quadgen",0,1},
194: {"quadpoly",0,1},
195: {"real",0,1},
196: {"recip",0,1},
197: {"redreal",0,1},
198: {"regula",0,1},
199: {"reorder",0,1},
200: {"reverse",0,1},
201: {"rhoreal",0,1},
202: {"roots",0,1},
203: {"round",0,1},
204: {"sigma",0,1},
205: {"signat",0,1},
206: {"simplify",0,1},
207: {"smalldiscf",0,1},
208: {"smallfact",0,1},
209: {"smallpolred",0,1},
210: {"smallpolred2",0,1},
211: {"smith",0,1},
212: {"smith2",0,1},
213: {"sort",0,1},
214: {"sqr",0,1},
215: {"sqred",0,1},
216: {"sqrt",0,1},
217: {"supplement",0,1},
218: {"trace",0,1},
219: {"trans",0,1},
220: {"trunc",0,1},
221: {"unit",0,1},
222: {"vec",0,1},
223: {"wf",0,1},
224: {"wf2",0,1},
225: {"zeta",0,1},
226: {"factor",0,1},
227:
228: {"allocatemem",0,0},
229:
230: {"isprime",0,2},
231: {"factorint",0,2},
1.1 noro 232: {0,0,0},
233: };
234:
235: void parif_init() {
236: int i;
237:
238: for ( i = 0, parif = 0; pariftab[i].name; i++ )
1.19 noro 239: appendparif(&parif,pariftab[i].name, 0,pariftab[i].type);
1.1 noro 240: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>