=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/pexpr.c,v retrieving revision 1.16 retrieving revision 1.24 diff -u -p -r1.16 -r1.24 --- OpenXM_contrib2/asir2000/io/pexpr.c 2001/09/03 07:01:08 1.16 +++ OpenXM_contrib2/asir2000/io/pexpr.c 2003/06/09 16:18:10 1.24 @@ -44,7 +44,7 @@ * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. - * $OpenXM: OpenXM_contrib2/asir2000/io/pexpr.c,v 1.15 2001/08/28 05:46:26 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/pexpr.c,v 1.23 2003/06/07 16:40:25 saito Exp $ */ #include "ca.h" #include "al.h" @@ -57,6 +57,7 @@ #endif #define PRINTHAT (fortran_output?PUTS("**"):PUTS("^")) +extern int outputstyle; #ifdef FPRINT FILE *asir_out; @@ -79,7 +80,7 @@ int print_quote; #define PRINTV printv #define PRINTEXPR printexpr #define PRINTNUM printnum -#define PRINTP printp +#define PRINTP asir_printp #define PRINTR printr #define PRINTLIST printlist #define PRINTVECT printvect @@ -113,6 +114,7 @@ extern int double_output; extern int real_digit; extern int print_quote; + #define TAIL while ( *OUT ) OUT++; #define PUTS(s) strcat(OUT,s) #define PRINTF sprintf @@ -124,7 +126,7 @@ extern int print_quote; #define PRINTV sprintv #define PRINTEXPR sprintexpr #define PRINTNUM sprintnum -#define PRINTP sprintp +#define PRINTP asir_sprintp #define PRINTR sprintr #define PRINTLIST sprintlist #define PRINTVECT sprintvect @@ -170,6 +172,13 @@ void PRINTCPLX(); void PRINTLM(); void PRINTLF(); void PRINTUP2(); +void PRINTUP(); +void PRINTUM(); +void PRINTFOP(); +void PRINTEOP(); +void PRINTLOP(); +void PRINTQOP(); +void PRINTSF(); #ifdef FPRINT void output_init() { @@ -182,7 +191,7 @@ P p; { if ( NUM(p) ) #if defined(INTERVAL) - if ( NID(p) != N_IP && NID(p) != N_ID && NID(p) != N_IT && NID(p) != N_IF + if ( NID(p) != N_IP && NID(p) != N_IntervalDouble && NID(p) != N_IntervalQuad && NID(p) != N_IntervalBigFloat && compnum(CO,(Num)p,0) < 0 ) #else if ( compnum(CO,(Num)p,0) < 0 ) @@ -196,10 +205,12 @@ P p; return (mmono(COEF(DC(p)))); } -#if PARI +#if defined(PARI) void printbf(a) BF a; { + void sor(); + sor(a->body,double_output ? 'f' : 'g',-1,0); } #endif @@ -212,7 +223,7 @@ char *s; s[0] = 0; buf = s; } -#if PARI +#if defined(PARI) #include "genpari.h" void myoutbrute(g) @@ -397,37 +408,93 @@ Num q; case N_A: PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")"); break; -#if PARI +#if defined(PARI) case N_B: PRINTBF((BF)q); break; #endif #if defined(INTERVAL) case N_IP: - case N_IF: - PUTS("["); - PRINTNUM(INF((Itv)q)); - PUTS(","); - PRINTNUM(SUP((Itv)q)); - PUTS("]"); + case N_IntervalBigFloat: + switch ( outputstyle ) { + case 1: + PUTS("intval("); + PRINTNUM(INF((Itv)q)); + PUTS(","); + PRINTNUM(SUP((Itv)q)); + PUTS(")"); + break; + case 0: + default: + PUTS("["); + PRINTNUM(INF((Itv)q)); + PUTS(","); + PRINTNUM(SUP((Itv)q)); + PUTS("]"); + break; + } break; - case N_ID: + case N_IntervalDouble: switch (printmode) { case PRINTF_E: - TAIL PRINTF(OUT, "[%.16e,%.16e]",INF((ItvD)q),SUP((ItvD)q)); + switch ( outputstyle ) { + case 1: + TAIL PRINTF(OUT, "intval(%.16e,%.16e)", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + case 0: + default: + TAIL PRINTF(OUT, "[%.16e,%.16e]", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + } #if defined(ITVDEBUG) - printbin(INF((ItvD)q)); - printbin(SUP((ItvD)q)); + printbin(INF((IntervalDouble)q)); + printbin(SUP((IntervalDouble)q)); #endif break; case MID_PRINTF_G: - TAIL PRINTF(OUT, "<%g,%g>", (SUP((ItvD)q)+INF((ItvD)q))*0.5,(SUP((ItvD)q)-INF((ItvD)q))*0.5); + switch ( outputstyle ) { + case 1: + TAIL PRINTF(OUT, "intvalm(%g,%g)", + (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5, + (SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); + break; + case 0: + default: + TAIL PRINTF(OUT, "<%g,%g>", + (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5, + (SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); + break; + } break; case MID_PRINTF_E: - TAIL PRINTF(OUT, "<%.16e,%.16e>", (SUP((ItvD)q)+INF((ItvD)q))*0.5,(SUP((ItvD)q)-INF((ItvD)q))*0.5); + switch ( outputstyle ) { + case 1: + TAIL PRINTF(OUT, "intvalm(%.16e,%.16e)", + (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5, + (SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); + break; + case 0: + default: + TAIL PRINTF(OUT, "<%.16e,%.16e>", + (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5, + (SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); + break; + } break; case PRINTF_G: default: - TAIL PRINTF(OUT, "[%g,%g]",INF((ItvD)q),SUP((ItvD)q)); + switch ( outputstyle ) { + case 1: + TAIL PRINTF(OUT, "intval(%g,%g)", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + case 0: + default: + TAIL PRINTF(OUT, "[%g,%g]", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + } break; } break; @@ -465,8 +532,8 @@ C a; if ( a->i ) { #if defined(INTERVAL) if ( a->r && ((compnum(0,a->i,0) > 0) - || NID(a->i) == N_IP || NID(a->i) == N_ID - || NID(a->i) == N_IT || NID(a->i) == N_IF) ) + || NID(a->i) == N_IP || NID(a->i) == N_IntervalDouble + || NID(a->i) == N_IntervalQuad || NID(a->i) == N_IntervalBigFloat) ) #else if ( a->r && (compnum(0,a->i,0) > 0) ) #endif @@ -546,8 +613,8 @@ V v; else if ( (vid)v->attr == V_PF ) { pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad; if ( !strcmp(NAME(pf),"pow") ) { - PUTS("("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("("); - PRINTR(vl,(R)ad[1].arg); PUTS(")"); + PUTS("(("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("("); + PRINTR(vl,(R)ad[1].arg); PUTS("))"); } else if ( !pf->argc ) { TAIL PRINTF(OUT,"%s",NAME(pf)); } else { @@ -610,11 +677,24 @@ VECT vect; int i; pointer *ptr; - PUTS("[ "); - for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { - PRINTEXPR(vl,ptr[i]); PUTS(" "); + switch ( outputstyle ) { + case 1: + PUTS("vect("); + for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { + if ( i != 0 ) PUTS(","); + PRINTEXPR(vl,ptr[i]); + } + PUTS(")"); + break; + case 0: + default: + PUTS("[ "); + for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { + PRINTEXPR(vl,ptr[i]); PUTS(" "); + } + PUTS("]"); + break; } - PUTS("]"); } void PRINTMAT(vl,mat) @@ -624,14 +704,32 @@ MAT mat; int i,j,r,c; pointer *ptr; - for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) { - PUTS("[ "); - for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) { - PRINTEXPR(vl,ptr[j]); PUTS(" "); - } - PUTS("]"); - if ( i < r - 1 ) - PUTS("\n"); + switch ( outputstyle ) { + case 1: + PUTS("mat(\n"); + for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) { + if ( i != 0 ) PUTS(",\n"); + PUTS("[ "); + for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) { + if ( j != 0 ) PUTS(","); + PRINTEXPR(vl,ptr[j]); + } + PUTS(" ]"); + } + PUTS(")"); + break; + case 0: + default: + for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) { + PUTS("[ "); + for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) { + PRINTEXPR(vl,ptr[j]); PUTS(" "); + } + PUTS("]"); + if ( i < r - 1 ) + PUTS("\n"); + } + break; } } @@ -736,7 +834,6 @@ VL vl; GFMMAT mat; { int row,col,i,j; - unsigned int t; unsigned int **b; row = mat->row; @@ -756,7 +853,6 @@ VL vl; BYTEARRAY array; { int len,i; - unsigned int t; unsigned char *b; len = array->len; @@ -849,7 +945,7 @@ F f; } } -PRINTFOP(vl,f) +void PRINTFOP(vl,f) VL vl; F f; { @@ -864,7 +960,7 @@ F f; } } -PRINTEOP(vl,f) +void PRINTEOP(vl,f) VL vl; F f; { @@ -891,7 +987,7 @@ F f; PUTS(")"); } -PRINTLOP(vl,f) +void PRINTLOP(vl,f) VL vl; F f; { @@ -917,7 +1013,7 @@ F f; PRINTEXPR(vl,(Obj)FPL(f)); PUTS(op); PUTS("0"); } -PRINTQOP(vl,f) +void PRINTQOP(vl,f) VL vl; F f; { @@ -928,7 +1024,7 @@ F f; PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")"); } -PRINTUP(n) +void PRINTUP(n) UP n; { int i,d; @@ -962,7 +1058,7 @@ UP n; } } -PRINTUM(n) +void PRINTUM(n) UM n; { int i,d; @@ -996,7 +1092,7 @@ UM n; } } -PRINTSF(i) +void PRINTSF(i) unsigned int i; { if ( !i ) {