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