Annotation of OpenXM_contrib2/asir2000/io/cpexpr.c, Revision 1.16
1.3 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.4 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.3 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
1.16 ! noro 47: * $OpenXM: OpenXM_contrib2/asir2000/io/cpexpr.c,v 1.15 2003/02/14 22:29:15 ohara Exp $
1.3 noro 48: */
1.1 noro 49: #include "ca.h"
50: #include "parse.h"
1.2 noro 51: #include "al.h"
1.1 noro 52: #include "base.h"
1.16 ! noro 53: #if PARI
! 54: #include "genpari.h"
! 55: #endif
1.1 noro 56:
1.8 noro 57: extern int hex_output,fortran_output,double_output,real_digit;
1.2 noro 58:
59: #define PRINTHAT (fortran_output?PUTS("**"):PUTS("^"))
60:
1.1 noro 61: #define TAIL
62: #define PUTS(s) (total_length+=strlen(s))
63: #define PRINTN length_n
1.2 noro 64: #define PRINTBF length_bf
1.1 noro 65: #define PRINTCPLX length_cplx
1.2 noro 66: #define PRINTLM length_lm
67: #define PRINTUP2 length_up2
1.1 noro 68: #define PRINTV length_v
69: #define PRINTEXPR length_expr
70: #define PRINTNUM length_num
71: #define PRINTP length_p
72: #define PRINTR length_r
73: #define PRINTLIST length_list
74: #define PRINTVECT length_vect
75: #define PRINTMAT length_mat
76: #define PRINTSTR length_str
77: #define PRINTCOMP length_comp
78: #define PRINTDP length_dp
1.2 noro 79: #define PRINTUI length_ui
80: #define PRINTGF2MAT length_gf2mat
81: #define PRINTGFMMAT length_gfmmat
1.5 noro 82: #define PRINTBYTEARRAY length_bytearray
1.11 noro 83: #define PRINTQUOTE length_QUOTE
1.2 noro 84: #define PRINTERR length_err
85: #define PRINTLF length_lf
86: #define PRINTLOP length_lop
87: #define PRINTFOP length_fop
88: #define PRINTEOP length_eop
89: #define PRINTQOP length_qop
90: #define PRINTUP length_up
1.12 noro 91: #define PRINTUM length_um
92: #define PRINTSF length_sf
1.1 noro 93:
94: void PRINTEXPR();
95: void PRINTNUM();
1.2 noro 96: void PRINTN();
1.1 noro 97: void PRINTV();
98: void PRINTP();
99: void PRINTR();
100: void PRINTLIST();
101: void PRINTVECT();
102: void PRINTMAT();
103: void PRINTSTR();
104: void PRINTCOMP();
105: void PRINTDP();
1.2 noro 106: void PRINTUI();
107: void PRINTGF2MAT();
108: void PRINTGFMMAT();
1.5 noro 109: void PRINTBYTEARRAY();
1.11 noro 110: void PRINTQUOTE();
1.2 noro 111: void PRINTERR();
1.1 noro 112: void PRINTCPLX();
1.2 noro 113: void PRINTLM();
114: void PRINTLF();
1.13 noro 115: void PRINTUP();
116: void PRINTUM();
1.2 noro 117: void PRINTUP2();
1.13 noro 118: void PRINTFOP();
119: void PRINTEOP();
120: void PRINTLOP();
121: void PRINTQOP();
122: void PRINTSF();
1.1 noro 123:
124: static int total_length;
125:
1.13 noro 126: int estimate_length(VL vl,pointer p)
1.1 noro 127: {
128: total_length = 0;
129: PRINTEXPR(vl,p);
130: return total_length;
131: }
132:
1.15 ohara 133: #if defined(PARI)
1.13 noro 134: void PRINTBF(BF a)
1.2 noro 135: {
136: char *str;
1.7 noro 137: char *GENtostr0();
138: void myoutbrute();
1.2 noro 139:
1.7 noro 140: if ( double_output ) {
141: str = GENtostr0(a->body,myoutbrute);
142: } else {
143: str = GENtostr(a->body);
144: }
1.2 noro 145: total_length += strlen(str);
146: free(str);
147: }
148: #endif
149:
1.13 noro 150: void PRINTEXPR(VL vl,pointer p)
1.1 noro 151: {
152: if ( !p ) {
153: total_length++;
154: return;
155: }
156:
157: switch ( OID(p) ) {
158: case O_N:
159: PRINTNUM((Num)p); break;
160: case O_P:
161: PRINTP(vl,(P)p); break;
162: case O_R:
163: PRINTR(vl,(R)p); break;
164: case O_LIST:
165: PRINTLIST(vl,(LIST)p); break;
166: case O_VECT:
167: PRINTVECT(vl,(VECT)p); break;
168: case O_MAT:
169: PRINTMAT(vl,(MAT)p); break;
170: case O_STR:
171: PRINTSTR((STRING)p); break;
172: case O_COMP:
173: PRINTCOMP(vl,(COMP)p); break;
174: case O_DP:
175: PRINTDP(vl,(DP)p); break;
1.2 noro 176: case O_USINT:
177: PRINTUI(vl,(USINT)p); break;
178: case O_GF2MAT:
179: PRINTGF2MAT(vl,(GF2MAT)p); break;
180: case O_ERR:
181: PRINTERR(vl,(ERR)p); break;
182: case O_MATHCAP:
183: PRINTLIST(vl,((MATHCAP)p)->body); break;
184: case O_F:
185: PRINTLF(vl,(F)p); break;
186: case O_GFMMAT:
187: PRINTGFMMAT(vl,(GFMMAT)p); break;
1.5 noro 188: case O_BYTEARRAY:
189: PRINTBYTEARRAY(vl,(BYTEARRAY)p); break;
1.11 noro 190: case O_QUOTE:
191: PRINTQUOTE(vl,(QUOTE)p); break;
1.1 noro 192: default:
193: break;
194: }
195: }
196:
1.13 noro 197: void PRINTN(N n)
1.1 noro 198: {
199: double ceil();
200:
201: if ( !n )
202: PUTS("0");
1.2 noro 203: else if ( hex_output )
204: total_length += 2+(int)(PL(n)*8);
1.1 noro 205: else
206: total_length += (int)(ceil(0.31*((double)(BSH*PL(n))))+1);
207: }
208:
1.13 noro 209: void PRINTNUM(Num q)
1.1 noro 210: {
211: if ( !q ) {
212: PUTS("0");
213: return;
214: }
215: switch ( NID(q) ) {
216: case N_Q:
217: if ( SGN((Q)q) == -1 )
218: PUTS("-");
219: PRINTN(NM((Q)q));
220: if ( !INT((Q)q) ) {
221: PUTS("/"); PRINTN(DN((Q)q));
222: }
223: break;
224: case N_R:
1.7 noro 225: if ( double_output )
1.8 noro 226: total_length += 400+real_digit; /* XXX */
1.7 noro 227: else
1.8 noro 228: total_length += 20+real_digit; /* XXX */
1.1 noro 229: break;
230: case N_A:
231: PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")");
232: break;
1.15 ohara 233: #if defined(PARI)
1.1 noro 234: case N_B:
235: PRINTBF((BF)q); break;
236: #endif
237: case N_C:
238: PRINTCPLX((C)q); break;
239: case N_M:
1.2 noro 240: total_length += 11; /* XXX */
241: break;
242: case N_LM:
243: PRINTN(((LM)q)->body); break;
244: case N_GF2N:
245: if ( hex_output )
246: PRINTN((N)(((GF2N)q)->body));
247: else
248: PRINTUP2(((GF2N)q)->body);
249: break;
250: case N_GFPN:
251: PRINTUP((UP)(((GFPN)q)->body));
1.9 noro 252: break;
253: case N_GFS:
1.10 noro 254: total_length += 13; /* XXX */
1.2 noro 255: break;
1.12 noro 256: case N_GFSN:
257: PRINTUM(BDY((GFSN)q));
258: break;
1.2 noro 259: default:
1.1 noro 260: break;
261: }
262: }
263:
1.13 noro 264: void PRINTCPLX(C a)
1.1 noro 265: {
266: PUTS("(");
267: if ( a->r )
268: PRINTNUM(a->r);
269: if ( a->i ) {
270: if ( a->r && (compnum(0,a->i,0) > 0) )
271: PUTS("+");
272: PRINTNUM(a->i); PUTS("*@i");
273: }
274: PUTS(")");
275: }
276:
1.13 noro 277: void PRINTP(VL vl,P p)
1.1 noro 278: {
279: V v;
280: DCP dc;
281:
282: if ( !p )
283: PUTS("0");
284: else if ( NUM(p) )
285: PRINTNUM((Num)p);
286: else
287: for ( dc = DC(p), v = VR(p); dc; dc = NEXT(dc) ) {
288: if ( !DEG(dc) )
289: PRINTP(vl,COEF(dc));
290: else {
291: if ( NUM(COEF(dc)) && UNIQ((Q)COEF(dc)) ) {
292: ;
293: } else if ( NUM(COEF(dc)) && MUNIQ((Q)COEF(dc)) )
294: PUTS("-");
295: else if ( NUM(COEF(dc)) || !NEXT(DC(COEF(dc)))) {
296: PRINTP(vl,COEF(dc)); PUTS("*");
297: } else {
298: PUTS("("); PRINTP(vl,COEF(dc)); PUTS(")*");
299: }
300: PRINTV(vl,v);
301: if ( cmpq(DEG(dc),ONE) ) {
1.2 noro 302: PRINTHAT;
1.1 noro 303: if ( INT(DEG(dc)) && SGN(DEG(dc))>0 )
304: PRINTNUM((Num)DEG(dc));
305: else {
306: PUTS("("); PRINTNUM((Num)DEG(dc)); PUTS(")");
307: }
308: }
309: }
310: if ( NEXT(dc) ) {
311: P t;
312:
313: t = COEF(NEXT(dc));
314: if (!DEG(NEXT(dc))) {
315: if ( NUM(t) ) {
316: if ( !mmono(t) )
317: PUTS("+");
318: } else {
319: if (!mmono(COEF(DC(t))))
320: PUTS("+");
321: }
322: } else {
323: if ( !mmono(t) )
324: PUTS("+");
325: }
326: }
327: }
328: }
329:
1.2 noro 330: extern int hideargs;
331:
1.13 noro 332: void PRINTV(VL vl,V v)
1.1 noro 333: {
334: PF pf;
335: PFAD ad;
336: int i;
337:
338: if ( NAME(v) )
339: PUTS(NAME(v));
340: else if ( (vid)v->attr == V_PF ) {
341: pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad;
342: if ( !strcmp(NAME(pf),"pow") ) {
1.14 noro 343: PUTS("(("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("(");
344: PRINTR(vl,(R)ad[1].arg); PUTS("))");
1.1 noro 345: } else if ( !pf->argc )
346: PUTS(NAME(pf));
347: else {
1.2 noro 348: if ( hideargs ) {
349: for ( i = 0; i < pf->argc; i++ )
350: if ( ad[i].d )
351: break;
352: if ( i < pf->argc ) {
353: PUTS(NAME(pf));
1.1 noro 354: total_length += 11; /* XXX */
1.2 noro 355: for ( i = 1; i < pf->argc; i++ ) {
356: total_length += 11; /* XXX */
357: }
358: PUTS("}");
359: } else {
360: PUTS(NAME(pf));
361: total_length += 1; /* XXX */
1.1 noro 362: }
363: } else {
1.2 noro 364: for ( i = 0; i < pf->argc; i++ )
365: if ( ad[i].d )
366: break;
367: if ( i < pf->argc ) {
368: PUTS(NAME(pf));
369: total_length += 11; /* XXX */
370: for ( i = 1; i < pf->argc; i++ ) {
371: total_length += 11; /* XXX */
372: }
373: PUTS(")(");
374: } else {
375: PUTS(NAME(pf));
376: total_length += 1; /* XXX */
377: }
378: PRINTR(vl,(R)ad[0].arg);
379: for ( i = 1; i < pf->argc; i++ ) {
380: PUTS(","); PRINTR(vl,(R)ad[i].arg);
381: }
382: PUTS(")");
1.1 noro 383: }
384: }
385: }
386: }
387:
1.13 noro 388: void PRINTR(VL vl,R a)
1.1 noro 389: {
390: if ( !a )
391: PUTS("0");
392: else
393: switch (OID(a)) {
394: case O_N: case O_P:
395: PRINTP(vl,(P)a); break;
396: default:
397: PUTS("("); PRINTP(vl,NM((R)a)); PUTS(")/("); PRINTP(vl,DN((R)a)); PUTS(")");
398: break;
399: }
400: }
401:
1.13 noro 402: void PRINTVECT(VL vl,VECT vect)
1.1 noro 403: {
404: int i;
405: pointer *ptr;
406:
407: PUTS("[ ");
408: for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) {
409: PRINTEXPR(vl,ptr[i]); PUTS(" ");
410: }
411: PUTS("]");
412: }
413:
1.13 noro 414: void PRINTMAT(VL vl,MAT mat)
1.1 noro 415: {
416: int i,j,r,c;
417: pointer *ptr;
418:
419: for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) {
420: PUTS("[ ");
421: for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) {
422: PRINTEXPR(vl,ptr[j]); PUTS(" ");
423: }
424: PUTS("]");
425: if ( i < r - 1 )
426: PUTS("\n");
427: }
428: }
429:
1.13 noro 430: void PRINTLIST(VL vl,LIST list)
1.1 noro 431: {
432: NODE tnode;
433:
434: PUTS("[");
435: for ( tnode = (NODE)list->body; tnode; tnode = NEXT(tnode) ) {
436: PRINTEXPR(vl,tnode->body);
437: if ( NEXT(tnode) )
438: PUTS(",");
439: }
440: PUTS("]");
441: }
442:
1.13 noro 443: void PRINTSTR(STRING str)
1.1 noro 444: {
445: char *p;
446:
447: for ( p = BDY(str); *p; p++ )
448: if ( *p == '"' )
449: PUTS("\"");
450: else {
451: total_length += 1;
452: }
453: }
454:
1.13 noro 455: void PRINTCOMP(VL vl,COMP c)
1.1 noro 456: {
457: int n,i;
458:
459: n = getcompsize((int)c->type);
460: PUTS("{");
461: for ( i = 0; i < n; i++ ) {
462: PRINTEXPR(vl,(pointer)c->member[i]);
463: if ( i < n-1 )
464: PUTS(",");
465: }
466: PUTS("}");
467: }
468:
1.13 noro 469: void PRINTDP(VL vl,DP d)
1.1 noro 470: {
471: int n,i;
472: MP m;
473: DL dl;
474:
475: for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) {
476: PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<");
477: for ( i = 0, dl = m->dl; i < n-1; i++ ) {
478: total_length += 11;
479: }
480: total_length += 10;
481: PUTS(">>");
482: if ( NEXT(m) )
483: PUTS("+");
1.2 noro 484: }
485: }
486:
1.13 noro 487: void PRINTUI(VL vl,USINT u)
1.2 noro 488: {
489: total_length += 10;
490: }
491:
1.13 noro 492: void PRINTGF2MAT(VL vl,GF2MAT mat)
1.2 noro 493: {
494: int row,col,w,i,j,k,m;
495: unsigned int t;
496: unsigned int **b;
497:
498: row = mat->row;
499: col = mat->col;
500: w = (col+BSH-1)/BSH;
501: b = mat->body;
502: for ( i = 0; i < row; i++ ) {
503: for ( j = 0, m = 0; j < w; j++ ) {
504: t = b[i][j];
505: for ( k = 0; m < col && k < BSH; k++, m++ )
506: if ( t & (1<<k) )
507: PUTS("1");
508: else
509: PUTS("0");
510: }
511: PUTS("\n");
512: }
513: }
514:
1.13 noro 515: void PRINTGFMMAT(VL vl,GFMMAT mat)
1.2 noro 516: {
517: int row,col,i,j;
518: unsigned int **b;
519:
520: row = mat->row;
521: col = mat->col;
522: b = mat->body;
523: for ( i = 0; i < row; i++ ) {
524: PUTS("[");
525: for ( j = 0; j < col; j++ ) {
526: total_length += 10; /* XXX */
527: }
528: PUTS("]\n");
529: }
1.5 noro 530: }
531:
1.13 noro 532: void PRINTBYTEARRAY(VL vl,BYTEARRAY array)
1.5 noro 533: {
534: /* |xx xx ... xx| */
1.6 noro 535: total_length += 1+3*array->len;
1.11 noro 536: }
537:
1.13 noro 538: void PRINTQUOTE(VL vl,QUOTE quote)
1.11 noro 539: {
540: /* <...quoted...> */
541: total_length += 20;
1.2 noro 542: }
543:
1.13 noro 544: void PRINTERR(VL vl,ERR e)
1.2 noro 545: {
546: PUTS("error("); PRINTEXPR(vl,e->body); PUTS(")");
547: }
548:
1.13 noro 549: void PRINTUP2(UP2 p)
1.2 noro 550: {
551: int d,i;
552:
553: if ( !p ) {
554: PUTS("0");
555: } else {
556: d = degup2(p);
557: PUTS("(");
558: if ( !d ) {
559: PUTS("1");
560: } else if ( d == 1 ) {
561: PUTS("@");
562: } else {
563: PRINTHAT;
564: total_length += 11;
565: }
566: for ( i = d-1; i >= 0; i-- ) {
567: if ( p->b[i/BSH] & (1<<(i%BSH)) )
568: if ( !i ) {
569: PUTS("+1");
570: } else if ( i == 1 ) {
571: PUTS("+@");
572: } else {
573: PRINTHAT;
574: total_length += 12;
575: }
576: }
577: PUTS(")");
578: }
579: }
580:
1.13 noro 581: void PRINTLF(VL vl,F f)
1.2 noro 582: {
583: switch ( FOP(f) ) {
584: case AL_TRUE:
585: PUTS("@true");
586: break;
587: case AL_FALSE:
588: PUTS("@false");
589: break;
590:
591: case AL_OR: case AL_AND:
592: PRINTFOP(vl,f); break;
593: case AL_NOT: case AL_IMPL: case AL_REPL: case AL_EQUIV:
594: PRINTEOP(vl,f); break;
595:
596: case AL_EQUAL: case AL_NEQ: case AL_LESSP:
597: case AL_GREATERP: case AL_LEQ: case AL_GEQ:
598: PRINTLOP(vl,f); break;
599:
600: case AL_EX: case AL_ALL:
601: PRINTQOP(vl,f); break;
602: default:
603: break;
604: }
605: }
606:
1.13 noro 607: void PRINTFOP(VL vl,F f)
1.2 noro 608: {
609: char *op;
610: NODE n;
611:
612: op = FOP(f)==AL_OR?" @|| ":" @&& ";
613: n = FJARG(f);
614: PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
615: for ( n = NEXT(n); n; n = NEXT(n) ) {
616: PUTS(op); PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
617: }
618: }
619:
1.13 noro 620: void PRINTEOP(VL vl,F f)
1.2 noro 621: {
622: oFOP op;
623: char *sop;
624:
625: if ( (op = FOP(f)) == AL_NOT ) {
626: PUTS("(@! "); PRINTEXPR(vl,(Obj)FARG(f)); PUTS(")"); return;
627: }
628: switch ( op ) {
629: case AL_IMPL:
630: sop = " @impl "; break;
631: case AL_REPL:
632: sop = " @repl "; break;
633: case AL_EQUIV:
634: sop = " @equiv "; break;
635: default:
636: break;
637: }
638: PUTS("(");
639: PRINTEXPR(vl,(Obj)FLHS(f));
640: PUTS(sop);
641: PRINTEXPR(vl,(Obj)FRHS(f));
642: PUTS(")");
643: }
644:
1.13 noro 645: void PRINTLOP(VL vl,F f)
1.2 noro 646: {
647: char *op;
648:
649: switch ( FOP(f) ) {
650: case AL_EQUAL:
651: op = " @== "; break;
652: case AL_NEQ:
653: op = " @!= "; break;
654: case AL_LESSP:
655: op = " @< "; break;
656: case AL_GREATERP:
657: op = " @> "; break;
658: case AL_LEQ:
659: op = " @<= "; break;
660: case AL_GEQ:
661: op = " @>= "; break;
662: default:
663: error("PRINTLOP : invalid operator");
664: break;
665: }
666: PRINTEXPR(vl,(Obj)FPL(f)); PUTS(op); PUTS("0");
667: }
668:
1.13 noro 669: void PRINTQOP(VL vl,F f)
1.2 noro 670: {
671: char *op;
672:
673: op = FOP(f)==AL_EX?"ex":"all";
674: PUTS(op); PUTS(NAME(FQVR(f)));
675: total_length += 2;
676: PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")");
677: }
678:
1.13 noro 679: void PRINTUP(UP n)
1.2 noro 680: {
681: int i,d;
682:
683: if ( !n )
684: PUTS("0");
685: else if ( !n->d )
686: PRINTNUM(n->c[0]);
687: else {
688: d = n->d;
689: PUTS("(");
690: if ( !d ) {
691: PRINTNUM(n->c[d]);
692: } else if ( d == 1 ) {
693: PRINTNUM(n->c[d]);
694: PUTS("*@p");
695: } else {
696: PRINTNUM(n->c[d]);
697: PRINTHAT;
698: total_length += 13;
699: }
700: for ( i = d-1; i >= 0; i-- ) {
701: if ( n->c[i] ) {
702: PUTS("+("); PRINTNUM(n->c[i]); PUTS(")");
703: if ( i >= 2 ) {
704: PRINTHAT;
705: total_length += 13;
706: } else if ( i == 1 )
707: PUTS("*@p");
708: }
709: }
710: PUTS(")");
1.1 noro 711: }
1.12 noro 712: }
713:
1.13 noro 714: void PRINTUM(UM n)
1.12 noro 715: {
716: int i,d;
717:
718: if ( !n )
719: PUTS("0");
720: else if ( !n->d )
721: PRINTSF(n->c[0]);
722: else {
723: d = n->d;
724: PUTS("(");
725: if ( !d ) {
726: PRINTSF(n->c[d]);
727: } else if ( d == 1 ) {
728: PRINTSF(n->c[d]);
729: PUTS("*@s");
730: } else {
731: PRINTSF(n->c[d]);
732: PUTS("*@s"); PRINTHAT; total_length += 13;
733: }
734: for ( i = d-1; i >= 0; i-- ) {
735: if ( n->c[i] ) {
736: PUTS("+("); PRINTSF(n->c[i]); PUTS(")");
737: if ( i >= 2 ) {
738: PUTS("*@s"); PRINTHAT; total_length += 13;
739: } else if ( i == 1 )
740: PUTS("*@s");
741: }
742: }
743: PUTS(")");
744: }
745: }
746:
1.13 noro 747: void PRINTSF(unsigned int i)
1.12 noro 748: {
749: if ( !i ) {
750: PUTS("0");
751: } else
752: total_length += 15;
1.1 noro 753: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>