Annotation of OpenXM_contrib2/asir2018/builtin/itvnum.c, Revision 1.4
1.1 noro 1: /*
1.4 ! kondoh 2: * $OpenXM: OpenXM_contrib2/asir2018/builtin/itvnum.c,v 1.3 2019/06/04 07:11:23 kondoh Exp $
1.1 noro 3: */
4:
5: #include "ca.h"
6: #include "parse.h"
7: #include "version.h"
8: #if !defined(ANDROID)
9: #include "../plot/ifplot.h"
10: #endif
11:
1.3 kondoh 12: // in engine/bf.c
13: Num tobf(Num,int);
14:
1.1 noro 15: #if defined(INTERVAL)
16: static void Pitv(NODE, Obj *);
17: static void Pitvd(NODE, Obj *);
18: static void Pitvbf(NODE, Obj *);
19: static void Pinf(NODE, Obj *);
20: static void Psup(NODE, Obj *);
21: static void Pmid(NODE, Obj *);
22: static void Pabsitv(NODE, Obj *);
23: static void Pdisjitv(NODE, Obj *);
24: static void Pinitv(NODE, Obj *);
25: static void Pcup(NODE, Obj *);
26: static void Pcap(NODE, Obj *);
27: static void Pwidth(NODE, Obj *);
28: static void Pdistance(NODE, Obj *);
1.3 kondoh 29: static void Pitvversion(NODE, Q *);
30: static void PzeroRewriteMode(NODE, Obj *);
31: static void PzeroRewriteCountClear(NODE, Obj *);
32: static void PzeroRewriteCount(NODE, Obj *);
33: //void miditvp(Itv,Num *);
34: //void absitvp(Itv,Num *);
35: //int initvd(Num,IntervalDouble);
36: //int initvp(Num,Itv);
37: //int itvinitvp(Itv,Itv);
1.1 noro 38: #endif
39: static void Pprintmode(NODE, Obj *);
40:
41: /* plot time check func */
42: static void ccalc(double **, struct canvas *, int);
43: static void Pifcheck(NODE, Obj *);
44:
45: #if defined(__osf__) && 0
46: int end;
47: #endif
48:
49: struct ftab interval_tab[] = {
50: {"printmode",Pprintmode,1},
51: #if defined(INTERVAL)
52: {"itvd",Pitvd,-2},
53: {"intvald",Pitvd,-2},
54: {"itv",Pitv,-2},
55: {"intval",Pitv,-2},
56: {"itvbf",Pitvbf,-2},
57: {"intvalbf",Pitvbf,-2},
58: {"inf",Pinf,1},
59: {"sup",Psup,1},
60: {"absintval",Pabsitv,1},
61: {"disintval",Pdisjitv,2},
62: {"inintval",Pinitv,2},
63: {"cup",Pcup,2},
64: {"cap",Pcap,2},
65: {"mid",Pmid,1},
66: {"width",Pwidth,1},
67: {"diam",Pwidth,1},
68: {"distance",Pdistance,2},
1.3 kondoh 69: {"iversion",Pitvversion,-1},
70: {"intvalversion",Pitvversion,-1},
71: {"zerorewritemode",PzeroRewriteMode,-1},
72: {"zeroRewriteMode",PzeroRewriteMode,-1},
73: {"zeroRewriteCountClear",PzeroRewriteCountClear,-1},
74: {"zeroRewriteCount",PzeroRewriteCount,-1},
1.1 noro 75: /* plot time check */
76: {"ifcheck",Pifcheck,-7},
77: #endif
78: {0,0,0},
79: };
80:
1.3 kondoh 81: extern int mpfr_roundmode;
82:
1.1 noro 83: #if defined(INTERVAL)
84:
85: /* plot time check */
86: static void
87: Pifcheck(NODE arg, Obj *rp)
88: {
1.4 ! kondoh 89: Z m2,p2,s_id;
1.1 noro 90: NODE defrange;
91: LIST xrange,yrange,range[2],list,geom;
92: VL vl,vl0;
93: V v[2],av[2];
94: int ri,i,j,sign;
95: P poly;
96: P var;
97: NODE n,n0;
98: Obj t;
99:
100: struct canvas *can;
101: MAT m;
102: pointer **mb;
103: double **tabe, *px, *px1, *px2;
1.4 ! kondoh 104: Z one;
1.1 noro 105: int width, height, ix, iy;
106: int id;
107:
1.4 ! kondoh 108: STOZ(-2,m2); STOZ(2,p2);
! 109: STOZ(1,one);
1.1 noro 110: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
111: poly = 0; vl = 0; geom = 0; ri = 0;
112: v[0] = v[1] = 0;
113: for ( ; arg; arg = NEXT(arg) ){
114: switch ( OID(BDY(arg)) ) {
115: case O_P:
116: poly = (P)BDY(arg);
117: get_vars_recursive((Obj)poly,&vl);
118: for(vl0=vl,i=0;vl0;vl0=NEXT(vl0)){
119: if(vl0->v->attr==(pointer)V_IND){
120: if(i>=2){
121: error("ifplot : invalid argument");
122: } else {
123: v[i++]=vl0->v;
124: }
125: }
126: }
127: break;
128: case O_LIST:
129: list = (LIST)BDY(arg);
130: if ( OID(BDY(BDY(list))) == O_P )
131: if ( ri > 1 )
132: error("ifplot : invalid argument");
133: else
134: range[ri++] = list;
135: else
136: geom = list;
137: break;
138: default:
139: error("ifplot : invalid argument"); break;
140: }
141: }
142: if ( !poly ) error("ifplot : invalid argument");
143: switch ( ri ) {
144: case 0:
145: if ( !v[1] ) error("ifplot : please specify all variables");
146: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
147: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
148: break;
149: case 1:
150: if ( !v[1] ) error("ifplot : please specify all variables");
151: av[0] = VR((P)BDY(BDY(range[0])));
152: if ( v[0] == av[0] ) {
153: xrange = range[0];
154: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
155: } else if ( v[1] == av[0] ) {
156: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
157: yrange = range[0];
158: } else
159: error("ifplot : invalid argument");
160: break;
161: case 2:
162: av[0] = VR((P)BDY(BDY(range[0])));
163: av[1] = VR((P)BDY(BDY(range[1])));
164: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
165: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
166: xrange = range[0]; yrange = range[1];
167: } else error("ifplot : invalid argument");
168: break;
169: default:
170: error("ifplot : cannot happen"); break;
171: }
172: can = canvas[id = search_canvas()];
173: if ( !geom ) {
174: width = 300;
175: height = 300;
176: can->width = 300;
177: can->height = 300;
178: } else {
1.4 ! kondoh 179: can->width = ZTOS((Z)BDY(BDY(geom)));
! 180: can->height = ZTOS((Z)BDY(NEXT(BDY(geom))));
1.1 noro 181: width = can->width;
182: height = can->height;
183: }
184: if ( xrange ) {
185: n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
186: can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
187: can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
188: }
189: if ( yrange ) {
190: n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
191: can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
192: can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
193: }
194: can->wname = "ifcheck";
195: can->formula = poly;
196: tabe = (double **)ALLOCA((width+1)*sizeof(double *));
197: for ( i = 0; i <= width; i++ )
198: tabe[i] = (double *)ALLOCA((height+1)*sizeof(double));
199: for(i=0;i<=width;i++)for(j=0;j<=height;j++)tabe[i][j]=0;
200: ccalc(tabe,can,0);
201: MKMAT(m,width,height);
202: mb = BDY(m);
203: for( ix=0; ix<width; ix++ ){
204: for( iy=0; iy<height; iy++){
205: if ( tabe[ix][iy] >= 0 ){
206: if ( (tabe[ix+1][iy] <= 0) ||
207: (tabe[ix][iy+1] <= 0 ) ||
208: (tabe[ix+1][iy+1] <= 0 ) ) mb[ix][iy] = (Obj)one;
209: } else {
210: if ( (tabe[ix+1][iy] >= 0 ) ||
211: ( tabe[ix][iy+1] >= 0 ) ||
212: ( tabe[ix+1][iy+1] >= 0 )) mb[ix][iy] = (Obj)one;
213: }
214: }
215: }
216: *rp = (Obj)m;
217: }
218:
219: void ccalc(double **tab,struct canvas *can,int nox)
220: {
221: double x,y,xmin,ymin,xstep,ystep;
222: int ix,iy;
223: Real r,rx,ry;
224: Obj fr,g;
225: int w,h;
226: V vx,vy;
227: Obj t,s;
228:
229: MKReal(1.0,r); mulr(CO,(Obj)can->formula,(Obj)r,&fr);
230: vx = can->vx;
231: vy = can->vy;
232: w = can->width; h = can->height;
233: xmin = can->xmin; xstep = (can->xmax-can->xmin)/w;
234: ymin = can->ymin; ystep = (can->ymax-can->ymin)/h;
235: MKReal(1.0,rx); MKReal(1.0,ry);
236: for( ix = 0, x = xmin; ix < w+1 ; ix++, x += xstep ) {
237: BDY(rx) = x; substr(CO,0,fr,vx,x?(Obj)rx:0,&t);
238: devalr(CO,t,&g);
239: for( iy = 0, y = ymin; iy < h+1 ; iy++, y += ystep ) {
240: BDY(ry) = y;
241: substr(CO,0,g,vy,y?(Obj)ry:0,&t);
242: devalr(CO,t,&s);
243: tab[ix][iy] = ToReal(s);
244: }
245: }
246: }
247: /* end plot time check */
248:
249: static void
1.3 kondoh 250: Pitvversion(NODE arg, Q *rp)
1.1 noro 251: {
1.4 ! kondoh 252: Z r;
! 253: STOZ(INT_ASIR_VERSION, r);
! 254: *rp = (Q)r;
1.1 noro 255: }
256:
257: extern int bigfloat;
258:
259: static void
260: Pitv(NODE arg, Obj *rp)
261: {
262: Num a, i, s;
263: Itv c;
264: double inf, sup;
265:
266: #if 1
267: if ( bigfloat )
268: Pitvbf(arg, rp);
269: else
270: Pitvd(arg,rp);
271: #else
272: asir_assert(ARG0(arg),O_N,"itv");
273: if ( argc(arg) > 1 ) {
274: asir_assert(ARG1(arg),O_N,"itv");
275: istoitv((Num)ARG0(arg),(Num)ARG1(arg),&c);
276: } else {
277: a = (Num)ARG0(arg);
278: if ( ! a ) {
279: *rp = 0;
280: return;
281: }
282: else if ( NID(a) == N_IP || NID(a) == N_IntervalBigFloat) {
283: *rp = (Obj)a;
284: return;
285: }
286: else if ( NID(a) == N_IntervalDouble ) {
287: inf = INF((IntervalDouble)a);
288: sup = SUP((IntervalDouble)a);
289: double2bf(inf, (BF *)&i);
290: double2bf(sup, (BF *)&s);
291: istoitv(i,s,&c);
292: }
293: else istoitv(a,a,&c);
294: }
295: if ( NID( c ) == N_IntervalBigFloat )
296: addulp((IntervalBigFloat)c, (IntervalBigFloat *)rp);
297: else *rp = (Obj)c;
298: #endif
299: }
300:
301: static void
302: Pitvbf(NODE arg, Obj *rp)
303: {
304: Num a, i, s;
1.3 kondoh 305: IntervalBigFloat c;
306: Num ii,ss;
307: Real di, ds;
1.1 noro 308: double inf, sup;
1.3 kondoh 309: int current_roundmode;
1.1 noro 310:
311: asir_assert(ARG0(arg),O_N,"intvalbf");
312: a = (Num)ARG0(arg);
313: if ( argc(arg) > 1 ) {
314: asir_assert(ARG1(arg),O_N,"intvalbf");
1.3 kondoh 315:
1.1 noro 316: i = (Num)ARG0(arg);
317: s = (Num)ARG1(arg);
1.3 kondoh 318: current_roundmode = mpfr_roundmode;
319: mpfr_roundmode = MPFR_RNDD;
320: ii = tobf(i, DEFAULTPREC);
321: mpfr_roundmode = MPFR_RNDU;
322: ss = tobf(s, DEFAULTPREC);
323: istoitv(ii,ss,(Itv *)&c);
324: // MKIntervalBigFloat((BF)ii,(BF)ss,c);
325: // ToBf(s, &ss);
326: mpfr_roundmode = current_roundmode;
1.1 noro 327: } else {
328: if ( ! a ) {
329: *rp = 0;
330: return;
331: }
332: else if ( NID(a) == N_IP ) {
333: itvtois((Itv)a, &i, &s);
1.3 kondoh 334: current_roundmode = mpfr_roundmode;
335: mpfr_roundmode = MPFR_RNDD;
336: ii = tobf(i, DEFAULTPREC);
337: mpfr_roundmode = MPFR_RNDU;
338: ss = tobf(s, DEFAULTPREC);
339: istoitv(ii,ss,(Itv *)&c);
340: // MKIntervalBigFloat((BF)ii,(BF)ss,c);
341: mpfr_roundmode = current_roundmode;
1.1 noro 342: }
343: else if ( NID(a) == N_IntervalBigFloat) {
344: *rp = (Obj)a;
345: return;
346: }
347: else if ( NID(a) == N_IntervalDouble ) {
348: inf = INF((IntervalDouble)a);
349: sup = SUP((IntervalDouble)a);
1.3 kondoh 350: current_roundmode = mpfr_roundmode;
351: //double2bf(inf, (BF *)&i);
352: //double2bf(sup, (BF *)&s);
353: mpfr_roundmode = MPFR_RNDD;
354: MKReal(inf,di);
355: ii = tobf((Num)di, DEFAULTPREC);
356: mpfr_roundmode = MPFR_RNDU;
357: MKReal(sup,ds);
358: ss = tobf((Num)ds, DEFAULTPREC);
359: istoitv(ii,ss,(Itv *)&c);
360: // MKIntervalBigFloat((BF)ii,(BF)ss,c);
361: mpfr_roundmode = current_roundmode;
1.1 noro 362: }
363: else {
1.3 kondoh 364: current_roundmode = mpfr_roundmode;
365: mpfr_roundmode = MPFR_RNDD;
366: ii = tobf(a, DEFAULTPREC);
367: mpfr_roundmode = MPFR_RNDU;
368: ss = tobf(a, DEFAULTPREC);
369: //ToBf(a, (BF *)&i);
370: istoitv(ii,ss,(Itv *)&c);
371: // MKIntervalBigFloat((BF)ii,(BF)ss,c);
372: mpfr_roundmode = current_roundmode;
1.1 noro 373: }
374: }
1.3 kondoh 375: // if ( c && OID( c ) == O_N && NID( c ) == N_IntervalBigFloat )
376: // addulp((IntervalBigFloat)c, (IntervalBigFloat *)rp);
377: // else *rp = (Obj)c;
378: *rp = (Obj)c;
1.1 noro 379: }
380:
381: static void
382: Pitvd(NODE arg, Obj *rp)
383: {
384: double inf, sup;
385: Num a, a0, a1, t;
386: Itv ia;
387: IntervalDouble d;
388:
389: asir_assert(ARG0(arg),O_N,"intvald");
390: a0 = (Num)ARG0(arg);
391: if ( argc(arg) > 1 ) {
392: asir_assert(ARG1(arg),O_N,"intvald");
393: a1 = (Num)ARG1(arg);
394: } else {
395: if ( a0 && OID(a0)==O_N && NID(a0)==N_IntervalDouble ) {
396: inf = INF((IntervalDouble)a0);
397: sup = SUP((IntervalDouble)a0);
398: MKIntervalDouble(inf,sup,d);
399: *rp = (Obj)d;
400: return;
401: }
402: a1 = (Num)ARG0(arg);
403: }
404: if ( compnum(0,a0,a1) > 0 ) {
405: t = a0; a0 = a1; a1 = t;
406: }
407: inf = ToRealDown(a0);
408: sup = ToRealUp(a1);
409: MKIntervalDouble(inf,sup,d);
410: *rp = (Obj)d;
411: }
412:
413: static void
414: Pinf(NODE arg, Obj *rp)
415: {
416: Num a, i, s;
417: Real r;
418: double d;
419:
420: a = (Num)ARG0(arg);
421: if ( ! a ) {
422: *rp = 0;
423: } else if ( OID(a) == O_N ) {
424: switch ( NID(a) ) {
425: case N_IntervalDouble:
426: d = INF((IntervalDouble)a);
427: MKReal(d, r);
428: *rp = (Obj)r;
429: break;
430: case N_IP:
431: case N_IntervalBigFloat:
432: case N_IntervalQuad:
433: itvtois((Itv)ARG0(arg),&i,&s);
434: *rp = (Obj)i;
435: break;
436: default:
437: *rp = (Obj)a;
438: break;
439: }
440: } else {
441: *rp = (Obj)a;
442: }
443: }
444:
445: static void
446: Psup(NODE arg, Obj *rp)
447: {
448: Num a, i, s;
449: Real r;
450: double d;
451:
452: a = (Num)ARG0(arg);
453: if ( ! a ) {
454: *rp = 0;
455: } else if ( OID(a) == O_N ) {
456: switch ( NID(a) ) {
457: case N_IntervalDouble:
458: d = SUP((IntervalDouble)a);
459: MKReal(d, r);
460: *rp = (Obj)r;
461: break;
462: case N_IP:
463: case N_IntervalBigFloat:
464: case N_IntervalQuad:
465: itvtois((Itv)ARG0(arg),&i,&s);
466: *rp = (Obj)s;
467: break;
468: default:
469: *rp = (Obj)a;
470: break;
471: }
472: } else {
473: *rp = (Obj)a;
474: }
475: }
476:
477: static void
478: Pmid(NODE arg, Obj *rp)
479: {
480: Num a, s;
481: Real r;
482: double d;
483:
484: a = (Num)ARG0(arg);
485: if ( ! a ) {
486: *rp = 0;
487: } else switch (OID(a)) {
488: case O_N:
489: if ( NID(a) == N_IntervalDouble ) {
490: d = ( INF((IntervalDouble)a)+SUP((IntervalDouble)a) ) / 2.0;
491: MKReal(d, r);
492: *rp = (Obj)r;
493: } else if ( NID(a) == N_IntervalQuad ) {
494: error("mid: not supported operation");
495: *rp = 0;
496: } else if ( NID(a) == N_IP || NID(a) == N_IntervalBigFloat ) {
497: miditvp((Itv)ARG0(arg),&s);
498: *rp = (Obj)s;
499: } else {
500: *rp = (Obj)a;
501: }
502: break;
503: #if 0
504: case O_P:
505: case O_R:
506: case O_LIST:
507: case O_VECT:
508: case O_MAT:
509: #endif
510: default:
511: *rp = (Obj)a;
512: break;
513: }
514: }
515:
516: static void
517: Pcup(NODE arg, Obj *rp)
518: {
519: Itv s;
520: Num a, b;
521:
522: asir_assert(ARG0(arg),O_N,"cup");
523: asir_assert(ARG1(arg),O_N,"cup");
524: a = (Num)ARG0(arg);
525: b = (Num)ARG1(arg);
526: if ( a && NID(a) == N_IntervalDouble && b && NID(b) == N_IntervalDouble ) {
527: cupitvd((IntervalDouble)a, (IntervalDouble)b, (IntervalDouble *)rp);
528: } else {
529: cupitvp((Itv)ARG0(arg),(Itv)ARG1(arg),&s);
530: *rp = (Obj)s;
531: }
532: }
533:
534: static void
535: Pcap(NODE arg, Obj *rp)
536: {
537: Itv s;
538: Num a, b;
539:
540: asir_assert(ARG0(arg),O_N,"cap");
541: asir_assert(ARG1(arg),O_N,"cap");
542: a = (Num)ARG0(arg);
543: b = (Num)ARG1(arg);
544: if ( a && NID(a) == N_IntervalDouble && b && NID(b) == N_IntervalDouble ) {
545: capitvd((IntervalDouble)a, (IntervalDouble)b, (IntervalDouble *)rp);
546: } else {
547: capitvp((Itv)ARG0(arg),(Itv)ARG1(arg),&s);
548: *rp = (Obj)s;
549: }
550: }
551:
552: static void
553: Pwidth(arg,rp)
554: NODE arg;
555: Obj *rp;
556: {
557: Num s;
558: Num a;
559:
560: asir_assert(ARG0(arg),O_N,"width");
561: a = (Num)ARG0(arg);
562: if ( ! a ) {
563: *rp = 0;
564: } else if ( NID(a) == N_IntervalDouble ) {
565: widthitvd((IntervalDouble)a, (Num *)rp);
566: } else {
567: widthitvp((Itv)ARG0(arg),&s);
568: *rp = (Obj)s;
569: }
570: }
571:
572: static void
573: Pabsitv(arg,rp)
574: NODE arg;
575: Obj *rp;
576: {
577: Num s;
578: Num a, b;
579:
580: asir_assert(ARG0(arg),O_N,"absitv");
581: a = (Num)ARG0(arg);
582: if ( ! a ) {
583: *rp = 0;
584: } else if ( NID(a) == N_IntervalDouble ) {
585: absitvd((IntervalDouble)a, (Num *)rp);
586: } else {
587: absitvp((Itv)ARG0(arg),&s);
588: *rp = (Obj)s;
589: }
590: }
591:
592: static void
593: Pdistance(arg,rp)
594: NODE arg;
595: Obj *rp;
596: {
597: Num s;
598: Num a, b;
599:
600: asir_assert(ARG0(arg),O_N,"distance");
601: asir_assert(ARG1(arg),O_N,"distance");
602: a = (Num)ARG0(arg);
603: b = (Num)ARG1(arg);
604: if ( a && NID(a) == N_IntervalDouble && b && NID(b) == N_IntervalDouble ) {
605: distanceitvd((IntervalDouble)a, (IntervalDouble)b, (Num *)rp);
606: } else {
607: distanceitvp((Itv)ARG0(arg),(Itv)ARG1(arg),&s);
608: *rp = (Obj)s;
609: }
610: }
611:
612: static void
1.4 ! kondoh 613: Pinitv(NODE arg, Obj *rp)
1.1 noro 614: {
615: int s;
1.4 ! kondoh 616: Z q;
1.1 noro 617:
618: asir_assert(ARG0(arg),O_N,"intval");
619: asir_assert(ARG1(arg),O_N,"intval");
620: if ( ! ARG1(arg) ) {
621: if ( ! ARG0(arg) ) s = 1;
622: else s = 0;
623: }
624: else if ( NID(ARG1(arg)) == N_IntervalDouble ) {
625: s = initvd((Num)ARG0(arg),(IntervalDouble)ARG1(arg));
626:
627: } else if ( NID(ARG1(arg)) == N_IP || NID(ARG1(arg)) == N_IntervalBigFloat ) {
628: if ( ! ARG0(arg) ) s = initvp((Num)ARG0(arg),(Itv)ARG1(arg));
629: else if ( NID(ARG0(arg)) == N_IP ) {
630: s = itvinitvp((Itv)ARG0(arg),(Itv)ARG1(arg));
631: } else {
632: s = initvp((Num)ARG0(arg),(Itv)ARG1(arg));
633: }
634: } else {
635: s = ! compnum(0,(Num)ARG0(arg),(Num)ARG1(arg));
636: }
1.4 ! kondoh 637: STOZ(s,q);
1.1 noro 638: *rp = (Obj)q;
639: }
640:
641: static void
642: Pdisjitv(arg,rp)
643: NODE arg;
644: Obj *rp;
645: {
646: Itv s;
647:
648: asir_assert(ARG0(arg),O_N,"disjitv");
649: asir_assert(ARG1(arg),O_N,"disjitv");
650: error("disjitv: not implemented yet");
651: if ( ! s ) *rp = 0;
652: else *rp = (Obj)ONE;
653: }
654:
1.3 kondoh 655: static void
656: PzeroRewriteMode(NODE arg, Obj *rp)
657: {
1.4 ! kondoh 658: Q a;
! 659: Z r;
1.3 kondoh 660:
1.4 ! kondoh 661: STOZ(zerorewrite,r);
1.3 kondoh 662: *rp = (Obj)r;
663:
664: if (arg) {
665: a = (Q)ARG0(arg);
666: if(!a) {
667: zerorewrite = 0;
668: } else if ( (NUM(a)&&INT(a)) ){
669: zerorewrite = 1;
670: }
671: }
672: }
673:
674: static void
675: PzeroRewriteCountClear(NODE arg, Obj *rp)
676: {
1.4 ! kondoh 677: Q a;
! 678: Z r;
1.3 kondoh 679:
1.4 ! kondoh 680: STOZ(zerorewriteCount,r);
1.3 kondoh 681: *rp = (Obj)r;
682:
683: if (arg) {
684: a = (Q)ARG0(arg);
685: if(a &&(NUM(a)&&INT(a))){
686: zerorewriteCount = 0;
687: }
688: }
689: }
690:
691: static void
692: PzeroRewriteCount(NODE arg, Obj *rp)
693: {
1.4 ! kondoh 694: Z r;
1.3 kondoh 695:
1.4 ! kondoh 696: STOZ(zerorewriteCount,r);
1.3 kondoh 697: *rp = (Obj)r;
698: }
699:
700:
1.1 noro 701: #endif
702: extern int printmode;
703:
704: static void pprintmode( void )
705: {
706: switch (printmode) {
707: #if defined(INTERVAL)
708: case MID_PRINTF_E:
709: fprintf(stderr,"Interval printing mode is a mitpoint type.\n");
710: #endif
711: case PRINTF_E:
712: fprintf(stderr,"Printf's double printing mode is \"%%.16e\".\n");
713: break;
714: #if defined(INTERVAL)
715: case MID_PRINTF_G:
716: fprintf(stderr,"Interval printing mode is a mitpoint type.\n");
717: #endif
718: default:
719: case PRINTF_G:
720: fprintf(stderr,"Printf's double printing mode is \"%%g\".\n");
721: break;
722: }
723: }
724:
725: static void
726: Pprintmode(NODE arg, Obj *rp)
727: {
728: int l;
1.4 ! kondoh 729: Z a, r;
1.1 noro 730:
1.4 ! kondoh 731: a = (Z)ARG0(arg);
1.1 noro 732: if(!a||(NUM(a)&&INT(a))){
1.4 ! kondoh 733: l=ZTOS(a);
1.1 noro 734: if ( l < 0 ) l = 0;
735: #if defined(INTERVAL)
736: else if ( l > MID_PRINTF_E ) l = 0;
737: #else
738: else if ( l > PRINTF_E ) l = 0;
739: #endif
1.4 ! kondoh 740: STOZ(printmode,r);
1.1 noro 741: *rp = (Obj)r;
742: printmode = l;
743: pprintmode();
744: } else {
745: *rp = 0;
746: }
747: }
748:
749:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>