=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/spexpr.c,v retrieving revision 1.5 retrieving revision 1.11 diff -u -p -r1.5 -r1.11 --- OpenXM_contrib2/asir2000/io/spexpr.c 2000/11/08 08:02:51 1.5 +++ OpenXM_contrib2/asir2000/io/spexpr.c 2001/03/13 01:10:27 1.11 @@ -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/spexpr.c,v 1.4 2000/08/22 05:04:18 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/spexpr.c,v 1.10 2001/03/09 01:44:10 noro Exp $ */ #include "ca.h" #include "al.h" @@ -103,6 +103,8 @@ static char *buf; extern char DFORMAT[BUFSIZ]; extern int hex_output; extern int fortran_output; +extern int double_output; +extern int real_digit; #define TAIL while ( *OUT ) OUT++; #define PUTS(s) strcat(OUT,s) @@ -168,7 +170,11 @@ int mmono(p) P p; { if ( NUM(p) ) +#if defined(INTERVAL) + if ( NID(p) != N_IP && compnum(CO,(Num)p,0) < 0 ) +#else if ( compnum(CO,(Num)p,0) < 0 ) +#endif return ( 1 ); else return ( 0 ); @@ -182,7 +188,7 @@ P p; void printbf(a) BF a; { - sor(a->body,'g',-1,0); + sor(a->body,double_output ? 'f' : 'g',-1,0); } #endif #endif @@ -195,13 +201,26 @@ char *s; } #if PARI +#include "genpari.h" + +void myoutbrute(g) +GEN g; +{ + bruteall(g,'f',-1,1); +} + void sprintbf(a) BF a; { char *str; char *GENtostr(); + char *GENtostr0(); - str = GENtostr(a->body); + if ( double_output ) { + str = GENtostr0(a->body,myoutbrute); + } else { + str = GENtostr(a->body); + } TAIL PRINTF(OUT,"%s",str); free(str); } @@ -286,9 +305,13 @@ N n; } } +extern int printmode; + void PRINTNUM(q) Num q; { + char real_format[20]; + if ( !q ) { PUTS("0"); return; @@ -303,7 +326,27 @@ Num q; } break; case N_R: - TAIL PRINTF(OUT,"%g",BDY((Real)q)); + switch (printmode) { + case PRINTF_E: +#if defined(INTERVAL) + case MID_PRINTF_E: +#endif + TAIL PRINTF(OUT,"%.15e",BDY((Real)q)); + break; + case PRINTF_G: +#if defined(INTERVAL) + case MID_PRINTF_G: +#endif + default: + if ( real_digit ) { + sprintf(real_format, + double_output?"%%.%df":"%%.%dg",real_digit); + TAIL PRINTF(OUT,real_format,BDY((Real)q)); + } else { + TAIL PRINTF(OUT,double_output?"%f":"%g",BDY((Real)q)); + } + break; + } break; case N_A: PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")"); @@ -312,6 +355,37 @@ Num q; 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("]"); + break; + case N_ID: + switch (printmode) { + case PRINTF_E: + TAIL PRINTF(OUT, "[%.16e,%.16e]",INF((ItvD)q),SUP((ItvD)q)); +#if defined(ITVDEBUG) + printbin(INF((ItvD)q)); + printbin(SUP((ItvD)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); + 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); + break; + case PRINTF_G: + default: + TAIL PRINTF(OUT, "[%g,%g]",INF((ItvD)q),SUP((ItvD)q)); + break; + } + break; +#endif case N_C: PRINTCPLX((C)q); break; case N_M: @@ -327,6 +401,8 @@ Num q; case N_GFPN: PRINTUP((UP)(((GFPN)q)->body)); break; + case N_GFS: + TAIL PRINTF(OUT,"%d",CONT((GFS)q)); break; } } @@ -628,12 +704,12 @@ BYTEARRAY array; unsigned char *b; len = array->len; - b =array->body; + b = array->body; PUTS("|"); for ( i = 0; i < len-1; i++ ) { - TAIL PRINTF(OUT,"%02x ",b[i]); + TAIL PRINTF(OUT,"%02x ",(unsigned int)b[i]); } - TAIL PRINTF(OUT,"%02x",b[i]); + TAIL PRINTF(OUT,"%02x",(unsigned int)b[i]); PUTS("|"); }