[BACK]Return to pexpr.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / io

Annotation of OpenXM_contrib2/asir2000/io/pexpr.c, Revision 1.4

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.4     ! noro       47:  * $OpenXM: OpenXM_contrib2/asir2000/io/pexpr.c,v 1.3 2000/08/21 08:31:38 noro Exp $
1.3       noro       48: */
1.1       noro       49: #include "ca.h"
                     50: #include "al.h"
                     51: #include "parse.h"
                     52: #include "comp.h"
                     53: #include "base.h"
                     54:
                     55: #ifndef FPRINT
                     56: #define FPRINT
                     57: #endif
                     58:
1.2       noro       59: #define PRINTHAT (fortran_output?PUTS("**"):PUTS("^"))
1.1       noro       60:
                     61: #ifdef FPRINT
                     62: FILE *asir_out;
                     63: #define OUT asir_out
                     64: char DFORMAT[BUFSIZ];
1.2       noro       65: int hex_output;
                     66: int fortran_output;
1.1       noro       67:
                     68: #define TAIL
                     69: #define PUTS(s) fputs(s,OUT)
                     70: #define PRINTF fprintf
                     71: #define PRINTN printn
                     72: #define PRINTBF printbf
                     73: #define PRINTCPLX printcplx
                     74: #define PRINTLM printlm
                     75: #define PRINTUP2 printup2
                     76: #define PRINTV printv
                     77: #define PRINTEXPR printexpr
                     78: #define PRINTNUM printnum
                     79: #define PRINTP printp
                     80: #define PRINTR printr
                     81: #define PRINTLIST printlist
                     82: #define PRINTVECT printvect
                     83: #define PRINTMAT printmat
                     84: #define PRINTSTR printstr
                     85: #define PRINTCOMP printcomp
                     86: #define PRINTDP printdp
                     87: #define PRINTUI printui
                     88: #define PRINTGF2MAT printgf2mat
                     89: #define PRINTGFMMAT printgfmmat
                     90: #define PRINTERR printerr
                     91: #define PRINTLF printlf
                     92: #define PRINTLOP printlop
                     93: #define PRINTFOP printfop
                     94: #define PRINTEOP printeop
                     95: #define PRINTQOP printqop
                     96: #define PRINTUP printup
                     97: #endif
                     98:
                     99: #ifdef SPRINT
                    100: static char *buf;
                    101: #define OUT buf
                    102: extern char DFORMAT[BUFSIZ];
1.2       noro      103: extern int hex_output;
                    104: extern int fortran_output;
1.1       noro      105:
                    106: #define TAIL while ( *OUT ) OUT++;
                    107: #define PUTS(s) strcat(OUT,s)
                    108: #define PRINTF sprintf
                    109: #define PRINTN sprintn
                    110: #define PRINTBF sprintbf
                    111: #define PRINTCPLX sprintcplx
                    112: #define PRINTLM sprintlm
                    113: #define PRINTUP2 sprintup2
                    114: #define PRINTV sprintv
                    115: #define PRINTEXPR sprintexpr
                    116: #define PRINTNUM sprintnum
                    117: #define PRINTP sprintp
                    118: #define PRINTR sprintr
                    119: #define PRINTLIST sprintlist
                    120: #define PRINTVECT sprintvect
                    121: #define PRINTMAT sprintmat
                    122: #define PRINTSTR sprintstr
                    123: #define PRINTCOMP sprintcomp
                    124: #define PRINTDP sprintdp
                    125: #define PRINTUI sprintui
                    126: #define PRINTGF2MAT sprintgf2mat
                    127: #define PRINTGFMMAT sprintgfmmat
                    128: #define PRINTERR sprinterr
                    129: #define PRINTLF sprintlf
                    130: #define PRINTLOP sprintlop
                    131: #define PRINTFOP sprintfop
                    132: #define PRINTEOP sprinteop
                    133: #define PRINTQOP sprintqop
1.2       noro      134: #define PRINTUP sprintup
1.1       noro      135: #endif
                    136:
                    137: void PRINTEXPR();
                    138: void PRINTNUM();
                    139: void PRINTN();
                    140: void PRINTV();
                    141: void PRINTP();
                    142: void PRINTR();
                    143: void PRINTLIST();
                    144: void PRINTVECT();
                    145: void PRINTMAT();
                    146: void PRINTSTR();
                    147: void PRINTCOMP();
                    148: void PRINTDP();
                    149: void PRINTUI();
                    150: void PRINTGF2MAT();
                    151: void PRINTGFMMAT();
                    152: void PRINTERR();
                    153: void PRINTCPLX();
                    154: void PRINTLM();
                    155: void PRINTLF();
1.2       noro      156: void PRINTUP2();
1.1       noro      157:
                    158: #ifdef FPRINT
                    159: void output_init() {
                    160:        OUT = stdout;
                    161:        sprintf(DFORMAT,"%%0%dd",DLENGTH);
                    162: }
                    163:
                    164: int mmono(p)
                    165: P p;
                    166: {
                    167:        if ( NUM(p) )
                    168:                if ( compnum(CO,(Num)p,0) < 0 )
                    169:                        return ( 1 );
                    170:                else
                    171:                        return ( 0 );
                    172:        else if ( NEXT(DC(p)) )
                    173:                return ( 0 );
                    174:        else
                    175:                return (mmono(COEF(DC(p))));
                    176: }
                    177:
                    178: #if PARI
                    179: void printbf(a)
                    180: BF a;
                    181: {
                    182:        sor(a->body,'g',-1,0);
                    183: }
                    184: #endif
                    185: #endif
                    186:
                    187: #ifdef SPRINT
                    188: void soutput_init(s)
                    189: char *s;
                    190: {
                    191:        s[0] = 0; buf = s;
                    192: }
                    193:
                    194: #if PARI
                    195: void sprintbf(a)
                    196: BF a;
                    197: {
1.2       noro      198:        char *str;
                    199:        char *GENtostr();
                    200:
                    201:        str = GENtostr(a->body);
                    202:        TAIL PRINTF(OUT,"%s",str);
                    203:        free(str);
1.1       noro      204: }
                    205: #endif
                    206: #endif
                    207:
                    208: void PRINTEXPR(vl,p)
                    209: VL vl;
                    210: Obj p;
                    211: {
                    212:        if ( !p ) {
                    213:                PRINTR(vl,(R)p);
                    214:                return;
                    215:        }
                    216:
                    217:        switch ( OID(p) ) {
                    218:                case O_N:
                    219:                        PRINTNUM((Num)p); break;
                    220:                case O_P:
                    221:                        PRINTP(vl,(P)p); break;
                    222:                case O_R:
                    223:                        PRINTR(vl,(R)p); break;
                    224:                case O_LIST:
                    225:                        PRINTLIST(vl,(LIST)p); break;
                    226:                case O_VECT:
                    227:                        PRINTVECT(vl,(VECT)p); break;
                    228:                case O_MAT:
                    229:                        PRINTMAT(vl,(MAT)p); break;
                    230:                case O_STR:
                    231:                        PRINTSTR((STRING)p); break;
                    232:                case O_COMP:
                    233:                        PRINTCOMP(vl,(COMP)p); break;
                    234:                case O_DP:
                    235:                        PRINTDP(vl,(DP)p); break;
                    236:                case O_USINT:
                    237:                        PRINTUI(vl,(USINT)p); break;
                    238:                case O_GF2MAT:
                    239:                        PRINTGF2MAT(vl,(GF2MAT)p); break;
                    240:                case O_ERR:
                    241:                        PRINTERR(vl,(ERR)p); break;
                    242:                case O_MATHCAP:
                    243:                        PRINTLIST(vl,((MATHCAP)p)->body); break;
                    244:                case O_F:
                    245:                        PRINTLF(vl,(F)p); break;
                    246:                case O_GFMMAT:
                    247:                        PRINTGFMMAT(vl,(GFMMAT)p); break;
                    248:                default:
                    249:                        break;
                    250:        }
                    251: }
                    252:
                    253: void PRINTN(n)
                    254: N n;
                    255: {
                    256:        register int i,*ptr;
                    257:        N tn;
                    258:
                    259:        if ( !n ) {
                    260:                PUTS("0");
                    261:                return;
                    262:        }
                    263:        if ( hex_output ) {
                    264:                ptr = BD(n);
                    265:                TAIL PRINTF(OUT,"0x%x",ptr[PL(n)-1]);
                    266:                if ( hex_output < 0 )
                    267:                        for ( i = PL(n) - 2; i >= 0; i-- ) {
                    268:                                TAIL PRINTF(OUT,"|%08x",ptr[i]);
                    269:                        }
                    270:                else
                    271:                        for ( i = PL(n) - 2; i >= 0; i-- ) {
                    272:                                TAIL PRINTF(OUT,"%08x",ptr[i]);
                    273:                        }
                    274:        } else {
                    275:                ntobn(DBASE,n,&tn);
                    276:                ptr = BD(tn);
                    277:                TAIL PRINTF(OUT,"%d",ptr[PL(tn) - 1]);
                    278:                for ( i = PL(tn) - 2; i >= 0; i-- ) {
                    279:                        TAIL PRINTF(OUT,DFORMAT,ptr[i]);
                    280:                }
                    281:        }
                    282: }
                    283:
                    284: void PRINTNUM(q)
                    285: Num q;
                    286: {
                    287:        if ( !q ) {
                    288:                PUTS("0");
                    289:                return;
                    290:        }
                    291:        switch ( NID(q) ) {
                    292:                case N_Q:
                    293:                        if ( SGN((Q)q) == -1 )
                    294:                                PUTS("-");
                    295:                        PRINTN(NM((Q)q));
                    296:                        if ( !INT((Q)q) ) {
                    297:                                PUTS("/"); PRINTN(DN((Q)q));
                    298:                        }
                    299:                        break;
                    300:                case N_R:
                    301:                        TAIL PRINTF(OUT,"%g",BDY((Real)q));
                    302:                        break;
                    303:                case N_A:
                    304:                        PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")");
                    305:                        break;
                    306: #if PARI
                    307:                case N_B:
                    308:                        PRINTBF((BF)q); break;
                    309: #endif
                    310:                case N_C:
                    311:                        PRINTCPLX((C)q); break;
                    312:                case N_M:
                    313:                        TAIL PRINTF(OUT,"%d",CONT((MQ)q)); break;
                    314:                case N_LM:
                    315:                        PRINTN(((LM)q)->body); break;
                    316:                case N_GF2N:
                    317:                        if ( hex_output )
                    318:                                PRINTN((N)(((GF2N)q)->body));
                    319:                        else
                    320:                                PRINTUP2(((GF2N)q)->body);
                    321:                        break;
                    322:                case N_GFPN:
                    323:                        PRINTUP((UP)(((GFPN)q)->body));
                    324:                        break;
                    325:        }
                    326: }
                    327:
                    328: void PRINTCPLX(a)
                    329: C a;
                    330: {
                    331:        PUTS("(");
                    332:        if ( a->r )
                    333:                PRINTNUM(a->r);
                    334:        if ( a->i ) {
                    335:                if ( a->r && (compnum(0,a->i,0) > 0) )
                    336:                        PUTS("+");
                    337:                PRINTNUM(a->i); PUTS("*@i");
                    338:        }
                    339:        PUTS(")");
                    340: }
                    341:
                    342: void PRINTP(vl,p)
                    343: VL vl;
                    344: P p;
                    345: {
                    346:        V v;
                    347:        DCP dc;
                    348:
                    349:        if ( !p )
                    350:                PUTS("0");
                    351:        else if ( NUM(p) )
                    352:                PRINTNUM((Num)p);
                    353:        else
                    354:                for ( dc = DC(p), v = VR(p); dc; dc = NEXT(dc) ) {
                    355:                        if ( !DEG(dc) )
                    356:                                PRINTP(vl,COEF(dc));
                    357:                        else {
                    358:                                if ( NUM(COEF(dc)) && UNIQ((Q)COEF(dc)) ) {
                    359:                                        ;
                    360:                                } else if ( NUM(COEF(dc)) && MUNIQ((Q)COEF(dc)) )
                    361:                                        PUTS("-");
                    362:                                else if ( NUM(COEF(dc)) || !NEXT(DC(COEF(dc)))) {
                    363:                                        PRINTP(vl,COEF(dc)); PUTS("*");
                    364:                                } else {
                    365:                                        PUTS("("); PRINTP(vl,COEF(dc)); PUTS(")*");
                    366:                                }
                    367:                                PRINTV(vl,v);
                    368:                                if ( cmpq(DEG(dc),ONE) ) {
1.2       noro      369:                                        PRINTHAT;
1.1       noro      370:                                        if ( INT(DEG(dc)) && SGN(DEG(dc))>0 )
                    371:                                                PRINTNUM((Num)DEG(dc));
                    372:                                        else {
                    373:                                                PUTS("("); PRINTNUM((Num)DEG(dc)); PUTS(")");
                    374:                                        }
                    375:                                }
                    376:                        }
                    377:                        if ( NEXT(dc) ) {
                    378:                                P t;
                    379:
                    380:                                t = COEF(NEXT(dc));
                    381:                                if (!DEG(NEXT(dc))) {
                    382:                                        if ( NUM(t) ) {
                    383:                                                if ( !mmono(t) )
                    384:                                                        PUTS("+");
                    385:                                        } else {
                    386:                                                if (!mmono(COEF(DC(t))))
                    387:                                                        PUTS("+");
                    388:                                        }
                    389:                                } else {
                    390:                                        if ( !mmono(t) )
                    391:                                                PUTS("+");
                    392:                                }
                    393:                        }
                    394:                }
                    395: }
                    396:
                    397: int hideargs;
                    398:
                    399: void PRINTV(vl,v)
                    400: VL vl;
                    401: V v;
                    402: {
                    403:        PF pf;
                    404:        PFAD ad;
                    405:        int i;
                    406:
                    407:        if ( NAME(v) )
                    408:                PUTS(NAME(v));
                    409:        else if ( (vid)v->attr == V_PF ) {
                    410:                pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad;
                    411:                if ( !strcmp(NAME(pf),"pow") ) {
1.2       noro      412:                        PUTS("("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("(");
1.1       noro      413:                        PRINTR(vl,(R)ad[1].arg); PUTS(")");
                    414:                } else if ( !pf->argc ) {
                    415:                        TAIL PRINTF(OUT,"%s",NAME(pf));
                    416:                } else {
                    417:                        if ( hideargs ) {
                    418:                                for ( i = 0; i < pf->argc; i++ )
                    419:                                        if ( ad[i].d )
                    420:                                                break;
                    421:                                if ( i < pf->argc ) {
                    422:                                        TAIL PRINTF(OUT,"%s{%d",NAME(pf),ad[0].d);
                    423:                                        for ( i = 1; i < pf->argc; i++ ) {
                    424:                                                TAIL PRINTF(OUT,",%d",ad[i].d);
                    425:                                        }
                    426:                                        PUTS("}");
                    427:                                } else {
                    428:                                        TAIL PRINTF(OUT,"%s",NAME(pf));
                    429:                                }
                    430:                        } else {
                    431:                                for ( i = 0; i < pf->argc; i++ )
                    432:                                        if ( ad[i].d )
                    433:                                                break;
                    434:                                if ( i < pf->argc ) {
                    435:                                        TAIL PRINTF(OUT,"%s{%d",NAME(pf),ad[0].d);
                    436:                                        for ( i = 1; i < pf->argc; i++ ) {
                    437:                                                TAIL PRINTF(OUT,",%d",ad[i].d);
                    438:                                        }
                    439:                                        PUTS("}(");
                    440:                                } else {
                    441:                                        TAIL PRINTF(OUT,"%s(",NAME(pf));
                    442:                                }
                    443:                                PRINTR(vl,(R)ad[0].arg);
                    444:                                for ( i = 1; i < pf->argc; i++ ) {
                    445:                                        PUTS(","); PRINTR(vl,(R)ad[i].arg);
                    446:                                }
                    447:                                PUTS(")");
                    448:                        }
                    449:                }
                    450:        }
                    451: }
                    452:
                    453: void PRINTR(vl,a)
                    454: VL vl;
                    455: R a;
                    456: {
                    457:        if ( !a )
                    458:                PUTS("0");
                    459:        else
                    460:                switch (OID(a)) {
                    461:                        case O_N: case O_P:
                    462:                                PRINTP(vl,(P)a); break;
                    463:                        default:
                    464:                                PUTS("("); PRINTP(vl,NM((R)a)); PUTS(")/("); PRINTP(vl,DN((R)a)); PUTS(")");
                    465:                                break;
                    466:                }
                    467: }
                    468:
                    469: void PRINTVECT(vl,vect)
                    470: VL vl;
                    471: VECT vect;
                    472: {
                    473:        int i;
                    474:        pointer *ptr;
                    475:
                    476:        PUTS("[ ");
                    477:        for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) {
                    478:                PRINTEXPR(vl,ptr[i]); PUTS(" ");
                    479:        }
                    480:        PUTS("]");
                    481: }
                    482:
                    483: void PRINTMAT(vl,mat)
                    484: VL vl;
                    485: MAT mat;
                    486: {
                    487:        int i,j,r,c;
                    488:        pointer *ptr;
                    489:
                    490:        for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) {
                    491:                PUTS("[ ");
                    492:                for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) {
                    493:                        PRINTEXPR(vl,ptr[j]); PUTS(" ");
                    494:                }
                    495:                PUTS("]");
                    496:                if ( i < r - 1 )
                    497:                        PUTS("\n");
                    498:        }
                    499: }
                    500:
                    501: void PRINTLIST(vl,list)
                    502: VL vl;
                    503: LIST list;
                    504: {
                    505:        NODE tnode;
                    506:
                    507:        PUTS("[");
                    508:        for ( tnode = (NODE)list->body; tnode; tnode = NEXT(tnode) ) {
                    509:                PRINTEXPR(vl,tnode->body);
                    510:                if ( NEXT(tnode) )
                    511:                        PUTS(",");
                    512:        }
                    513:        PUTS("]");
                    514: }
                    515:
                    516: void PRINTSTR(str)
                    517: STRING str;
                    518: {
                    519:        char *p;
                    520:
                    521:        for ( p = BDY(str); *p; p++ )
                    522:                if ( *p == '"' )
                    523:                        PUTS("\"");
                    524:                else {
                    525:                        TAIL PRINTF(OUT,"%c",*p);
                    526:                }
                    527: }
                    528:
                    529: void PRINTCOMP(vl,c)
                    530: VL vl;
                    531: COMP c;
                    532: {
                    533:        int n,i;
                    534:
                    535:        n = getcompsize((int)c->type);
                    536:        PUTS("{");
                    537:        for ( i = 0; i < n; i++ ) {
                    538:                PRINTEXPR(vl,(pointer)c->member[i]);
                    539:                if ( i < n-1 )
                    540:                        PUTS(",");
                    541:        }
                    542:        PUTS("}");
                    543: }
                    544:
                    545: void PRINTDP(vl,d)
                    546: VL vl;
                    547: DP d;
                    548: {
                    549:        int n,i;
                    550:        MP m;
                    551:        DL dl;
                    552:
                    553:        for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) {
                    554:                PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<");
                    555:                for ( i = 0, dl = m->dl; i < n-1; i++ ) {
                    556:                        TAIL PRINTF(OUT,"%d,",dl->d[i]);
                    557:                }
                    558:                TAIL PRINTF(OUT,"%d",dl->d[i]);
                    559:                PUTS(">>");
                    560:                if ( NEXT(m) )
                    561:                        PUTS("+");
                    562:        }
                    563: }
                    564:
                    565: void PRINTUI(vl,u)
                    566: VL vl;
                    567: USINT u;
                    568: {
                    569:        TAIL PRINTF(OUT,"%u",BDY(u));
                    570: }
                    571:
                    572: void PRINTGF2MAT(vl,mat)
                    573: VL vl;
                    574: GF2MAT mat;
                    575: {
                    576:        int row,col,w,i,j,k,m;
                    577:        unsigned int t;
                    578:        unsigned int **b;
                    579:
                    580:        row = mat->row;
                    581:        col = mat->col;
                    582:        w = (col+BSH-1)/BSH;
                    583:        b = mat->body;
                    584:        for ( i = 0; i < row; i++ ) {
                    585:                for ( j = 0, m = 0; j < w; j++ ) {
                    586:                        t = b[i][j];
                    587:                        for ( k = 0; m < col && k < BSH; k++, m++ )
                    588:                                if ( t & (1<<k) )
                    589:                                        PUTS("1");
                    590:                                else
                    591:                                        PUTS("0");
                    592:                }
                    593:                PUTS("\n");
                    594:        }
                    595: }
                    596:
                    597: void PRINTGFMMAT(vl,mat)
                    598: VL vl;
                    599: GFMMAT mat;
                    600: {
                    601:        int row,col,i,j;
                    602:        unsigned int t;
                    603:        unsigned int **b;
                    604:
                    605:        row = mat->row;
                    606:        col = mat->col;
                    607:        b = mat->body;
                    608:        for ( i = 0; i < row; i++ ) {
                    609:                PUTS("[");
                    610:                for ( j = 0; j < col; j++ ) {
                    611:                        TAIL PRINTF(OUT,"%8d",b[i][j]);
                    612:                }
                    613:                PUTS("]\n");
                    614:        }
                    615: }
                    616:
                    617: void PRINTERR(vl,e)
                    618: VL vl;
                    619: ERR e;
                    620: {
                    621:        PUTS("error("); PRINTEXPR(vl,e->body); PUTS(")");
                    622: }
                    623:
                    624: void PRINTUP2(p)
                    625: UP2 p;
                    626: {
                    627:        int d,i;
                    628:
1.2       noro      629:        if ( !p ) {
                    630:                TAIL PRINTF(OUT,"0");
                    631:        } else {
1.1       noro      632:                d = degup2(p);
1.2       noro      633:                TAIL PRINTF(OUT,"(");
                    634:                if ( !d ) {
                    635:                        TAIL PRINTF(OUT,"1");
                    636:                } else if ( d == 1 ) {
                    637:                        TAIL PRINTF(OUT,"@");
                    638:                } else {
                    639:                        PUTS("@"); PRINTHAT; TAIL PRINTF(OUT,"%d",d);
                    640:                }
1.1       noro      641:                for ( i = d-1; i >= 0; i-- ) {
                    642:                        if ( p->b[i/BSH] & (1<<(i%BSH)) )
1.2       noro      643:                                if ( !i ) {
                    644:                                        TAIL PRINTF(OUT,"+1");
                    645:                                } else if ( i == 1 ) {
                    646:                                        TAIL PRINTF(OUT,"+@");
                    647:                                } else {
                    648:                                        PUTS("+@"); PRINTHAT; TAIL PRINTF(OUT,"%d",i);
                    649:                                }
1.1       noro      650:                }
1.2       noro      651:                TAIL PRINTF(OUT,")");
1.1       noro      652:        }
                    653: }
                    654:
                    655: void PRINTLF(vl,f)
                    656: VL vl;
                    657: F f;
                    658: {
                    659:        switch ( FOP(f) ) {
                    660:                case AL_TRUE:
                    661:                        TAIL PRINTF(OUT,"@true");
                    662:                        break;
                    663:                case AL_FALSE:
                    664:                        TAIL PRINTF(OUT,"@false");
                    665:                        break;
                    666:
                    667:                case AL_OR: case AL_AND:
                    668:                        PRINTFOP(vl,f); break;
                    669:                case AL_NOT: case AL_IMPL: case AL_REPL: case AL_EQUIV:
                    670:                        PRINTEOP(vl,f); break;
                    671:
                    672:                case AL_EQUAL: case AL_NEQ: case AL_LESSP:
                    673:                case AL_GREATERP: case AL_LEQ: case AL_GEQ:
                    674:                        PRINTLOP(vl,f); break;
                    675:
                    676:                case AL_EX: case AL_ALL:
                    677:                        PRINTQOP(vl,f); break;
                    678:                default:
                    679:                        break;
                    680:        }
                    681: }
                    682:
                    683: PRINTFOP(vl,f)
                    684: VL vl;
                    685: F f;
                    686: {
                    687:        char *op;
                    688:        NODE n;
                    689:
                    690:        op = FOP(f)==AL_OR?" @|| ":" @&& ";
                    691:        n = FJARG(f);
                    692:        PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
                    693:        for ( n = NEXT(n); n; n = NEXT(n) ) {
                    694:                PUTS(op); PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
                    695:        }
                    696: }
                    697:
                    698: PRINTEOP(vl,f)
                    699: VL vl;
                    700: F f;
                    701: {
                    702:        oFOP op;
                    703:        char *sop;
                    704:
                    705:        if ( (op = FOP(f)) == AL_NOT ) {
                    706:                PUTS("(@! "); PRINTEXPR(vl,(Obj)FARG(f)); PUTS(")"); return;
                    707:        }
                    708:        switch ( op ) {
                    709:                case AL_IMPL:
                    710:                        sop = " @impl "; break;
                    711:                case AL_REPL:
                    712:                        sop = " @repl "; break;
                    713:                case AL_EQUIV:
                    714:                        sop = " @equiv "; break;
                    715:                default:
                    716:                        break;
                    717:        }
                    718:        PUTS("(");
                    719:        PRINTEXPR(vl,(Obj)FLHS(f));
                    720:        PUTS(sop);
                    721:        PRINTEXPR(vl,(Obj)FRHS(f));
                    722:        PUTS(")");
                    723: }
                    724:
                    725: PRINTLOP(vl,f)
                    726: VL vl;
                    727: F f;
                    728: {
                    729:        char *op;
                    730:
                    731:        switch ( FOP(f) ) {
                    732:                case AL_EQUAL:
                    733:                        op = " @== "; break;
                    734:                case AL_NEQ:
                    735:                        op = " @!= "; break;
                    736:                case AL_LESSP:
                    737:                        op = " @< "; break;
                    738:                case AL_GREATERP:
                    739:                        op = " @> "; break;
                    740:                case AL_LEQ:
                    741:                        op = " @<= "; break;
                    742:                case AL_GEQ:
                    743:                        op = " @>= "; break;
                    744:                default:
                    745:                        error("PRINTLOP : invalid operator");
                    746:                        break;
                    747:        }
                    748:        PRINTEXPR(vl,(Obj)FPL(f)); PUTS(op); PUTS("0");
                    749: }
                    750:
                    751: PRINTQOP(vl,f)
                    752: VL vl;
                    753: F f;
                    754: {
                    755:        char *op;
                    756:
                    757:        op = FOP(f)==AL_EX?"ex":"all";
                    758:        TAIL PRINTF(OUT,"%s(%s,",op,NAME(FQVR(f)));
                    759:        PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")");
                    760: }
                    761:
                    762: PRINTUP(n)
                    763: UP n;
                    764: {
                    765:        int i,d;
                    766:
                    767:        if ( !n )
                    768:                PUTS("0");
                    769:        else if ( !n->d )
                    770:                PRINTNUM(n->c[0]);
                    771:        else {
                    772:                d = n->d;
                    773:                PUTS("(");
                    774:                if ( !d ) {
                    775:                        PRINTNUM(n->c[d]);
                    776:                } else if ( d == 1 ) {
                    777:                        PRINTNUM(n->c[d]);
                    778:                        PUTS("*@p");
                    779:                } else {
                    780:                        PRINTNUM(n->c[d]);
1.2       noro      781:                        PUTS("*@p"); PRINTHAT; TAIL PRINTF(OUT,"%d",d);
1.1       noro      782:                }
                    783:                for ( i = d-1; i >= 0; i-- ) {
                    784:                        if ( n->c[i] ) {
                    785:                                PUTS("+("); PRINTNUM(n->c[i]); PUTS(")");
                    786:                                if ( i >= 2 ) {
1.2       noro      787:                                        PUTS("*@p"); PRINTHAT; TAIL PRINTF(OUT,"%d",i);
1.1       noro      788:                                } else if ( i == 1 )
                    789:                                        PUTS("*@p");
                    790:                        }
                    791:                }
                    792:                PUTS(")");
                    793:        }
                    794: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>