=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/spexpr.c,v retrieving revision 1.22 retrieving revision 1.25 diff -u -p -r1.22 -r1.25 --- OpenXM_contrib2/asir2000/io/spexpr.c 2003/05/29 16:45:01 1.22 +++ OpenXM_contrib2/asir2000/io/spexpr.c 2003/12/25 02:40:24 1.25 @@ -44,20 +44,23 @@ * 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/spexpr.c,v 1.21 2003/02/14 22:29:15 ohara Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/spexpr.c,v 1.24 2003/06/09 16:18:10 saito Exp $ */ #include "ca.h" #include "al.h" #include "parse.h" #include "comp.h" #include "base.h" +#if PARI +#include "genpari.h" +#endif #ifndef SPRINT #define SPRINT #endif #define PRINTHAT (fortran_output?PUTS("**"):PUTS("^")) -extern int prefixmode; +extern int outputstyle; #ifdef FPRINT FILE *asir_out; @@ -209,8 +212,6 @@ P p; void printbf(a) BF a; { - void sor(); - sor(a->body,double_output ? 'f' : 'g',-1,0); } #endif @@ -224,8 +225,6 @@ char *s; } #if defined(PARI) -#include "genpari.h" - void myoutbrute(g) GEN g; { @@ -236,7 +235,6 @@ void sprintbf(a) BF a; { char *str; - char *GENtostr(); char *GENtostr0(); if ( double_output ) { @@ -415,27 +413,37 @@ Num q; #if defined(INTERVAL) case N_IP: case N_IntervalBigFloat: - if ( prefixmode == 0 ) { - PUTS("["); - PRINTNUM(INF((Itv)q)); - PUTS(","); - PRINTNUM(SUP((Itv)q)); - PUTS("]"); - } else { - PUTS("intval("); - PRINTNUM(INF((Itv)q)); - PUTS(","); - PRINTNUM(SUP((Itv)q)); - PUTS(")"); + 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_IntervalDouble: switch (printmode) { case PRINTF_E: - if (prefixmode == 0 ) { - TAIL PRINTF(OUT, "[%.16e,%.16e]",INF((IntervalDouble)q),SUP((IntervalDouble)q)); - } else { - TAIL PRINTF(OUT, "intval(%.16e,%.16e)",INF((IntervalDouble)q),SUP((IntervalDouble)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((IntervalDouble)q)); @@ -443,25 +451,47 @@ Num q; #endif break; case MID_PRINTF_G: - if (prefixmode == 0) { - TAIL PRINTF(OUT, "<%g,%g>", (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5,(SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); - } else { - TAIL PRINTF(OUT, "intvalm(%g,%g)", (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5,(SUP((IntervalDouble)q)-INF((IntervalDouble)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: - if (prefixmode == 0) { - TAIL PRINTF(OUT, "<%.16e,%.16e>", (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5,(SUP((IntervalDouble)q)-INF((IntervalDouble)q))*0.5); - } else { - TAIL PRINTF(OUT, "intvalm(%.16e,%.16e)", (SUP((IntervalDouble)q)+INF((IntervalDouble)q))*0.5,(SUP((IntervalDouble)q)-INF((IntervalDouble)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: - if (prefixmode == 0) { - TAIL PRINTF(OUT, "[%g,%g]",INF((IntervalDouble)q),SUP((IntervalDouble)q)); - } else { - TAIL PRINTF(OUT, "intval(%g,%g)",INF((IntervalDouble)q),SUP((IntervalDouble)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; } @@ -645,19 +675,23 @@ VECT vect; int i; pointer *ptr; - if ( prefixmode == 0 ) { - PUTS("[ "); - for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { - PRINTEXPR(vl,ptr[i]); PUTS(" "); - } - PUTS("]"); - } else { - PUTS("vect("); - for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { - if ( i != 0 ) PUTS(", "); - 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; } } @@ -668,27 +702,32 @@ MAT mat; int i,j,r,c; pointer *ptr; - if ( prefixmode == 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(" "); + 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("]"); - if ( i < r - 1 ) - PUTS("\n"); - } - } else { - 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++ ) { - 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"); } - PUTS("]"); - } - PUTS(")"); + break; } }