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