=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/pexpr.c,v retrieving revision 1.19 retrieving revision 1.23 diff -u -p -r1.19 -r1.23 --- OpenXM_contrib2/asir2000/io/pexpr.c 2002/09/02 05:16:07 1.19 +++ OpenXM_contrib2/asir2000/io/pexpr.c 2003/06/07 16:40:25 1.23 @@ -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.18 2002/01/08 04:14:39 kondoh Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/pexpr.c,v 1.22 2003/05/29 16:45:01 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 @@ -203,7 +205,7 @@ P p; return (mmono(COEF(DC(p)))); } -#if PARI +#if defined(PARI) void printbf(a) BF a; { @@ -221,7 +223,7 @@ char *s; s[0] = 0; buf = s; } -#if PARI +#if defined(PARI) #include "genpari.h" void myoutbrute(g) @@ -406,37 +408,113 @@ 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_IntervalBigFloat: - PUTS("["); - PRINTNUM(INF((Itv)q)); - PUTS(","); - PRINTNUM(SUP((Itv)q)); - PUTS("]"); + switch ( outputstyle ) { + case 0: + PUTS("["); + PRINTNUM(INF((Itv)q)); + PUTS(","); + PRINTNUM(SUP((Itv)q)); + PUTS("]"); + break; + case 1: + PUTS("intval("); + PRINTNUM(INF((Itv)q)); + PUTS(","); + PRINTNUM(SUP((Itv)q)); + PUTS(")"); + break; + default: + PUTS("["); + PRINTNUM(INF((Itv)q)); + PUTS(","); + PRINTNUM(SUP((Itv)q)); + PUTS("]"); + break; + } break; case N_IntervalDouble: switch (printmode) { case PRINTF_E: - TAIL PRINTF(OUT, "[%.16e,%.16e]",INF((IntervalDouble)q),SUP((IntervalDouble)q)); + switch ( outputstyle ) { + case 0: + TAIL PRINTF(OUT, "[%.16e,%.16e]", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + case 1: + TAIL PRINTF(OUT, "intval(%.16e,%.16e)", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + default: + TAIL PRINTF(OUT, "[%.16e,%.16e]", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + } #if defined(ITVDEBUG) printbin(INF((IntervalDouble)q)); printbin(SUP((IntervalDouble)q)); #endif break; case MID_PRINTF_G: - TAIL PRINTF(OUT, "<%g,%g>", (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5,(SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); + switch ( outputstyle ) { + case 0: + TAIL PRINTF(OUT, "<%g,%g>", + (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5, + (SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); + break; + 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; + 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((IntervalDouble)q)+INF((IntervalDouble)q))*0.5,(SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); + switch ( outputstyle ) { + case 0: + TAIL PRINTF(OUT, "<%.16e,%.16e>", + (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5, + (SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); + break; + 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; + 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((IntervalDouble)q),SUP((IntervalDouble)q)); + switch ( outputstyle ) { + case 0: + TAIL PRINTF(OUT, "[%g,%g]", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + case 1: + TAIL PRINTF(OUT, "intval(%g,%g)", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + default: + TAIL PRINTF(OUT, "[%g,%g]", + INF((IntervalDouble)q),SUP((IntervalDouble)q)); + break; + } break; } break; @@ -619,11 +697,30 @@ 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 0: + PUTS("[ "); + for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { + PRINTEXPR(vl,ptr[i]); PUTS(" "); + } + PUTS("]"); + break; + case 1: + PUTS("vect("); + for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { + if ( i != 0 ) PUTS(", "); + PRINTEXPR(vl,ptr[i]); + } + PUTS(")"); + break; + default: + PUTS("[ "); + for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { + PRINTEXPR(vl,ptr[i]); PUTS(" "); + } + PUTS("]"); + break; } - PUTS("]"); } void PRINTMAT(vl,mat) @@ -633,14 +730,42 @@ 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 0: + 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; + 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; + 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; } }