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

Diff for /OpenXM_contrib2/asir2000/io/pexpr.c between version 1.24 and 1.29

version 1.24, 2003/06/09 16:18:10 version 1.29, 2004/02/09 08:23:30
Line 44 
Line 44 
  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY   * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  * $OpenXM: OpenXM_contrib2/asir2000/io/pexpr.c,v 1.23 2003/06/07 16:40:25 saito Exp $   * $OpenXM: OpenXM_contrib2/asir2000/io/pexpr.c,v 1.28 2004/02/04 07:42:07 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "al.h"  #include "al.h"
Line 52 
Line 52 
 #include "comp.h"  #include "comp.h"
 #include "base.h"  #include "base.h"
   
   #if defined(PARI)
   #include "genpari.h"
   #endif
   
 #ifndef FPRINT  #ifndef FPRINT
 #define FPRINT  #define FPRINT
 #endif  #endif
Line 67  int hex_output;
Line 71  int hex_output;
 int fortran_output;  int fortran_output;
 int double_output;  int double_output;
 int real_digit;  int real_digit;
   int real_binary;
 int print_quote;  int print_quote;
   
 #define TAIL  #define TAIL
Line 102  int print_quote;
Line 107  int print_quote;
 #define PRINTUP printup  #define PRINTUP printup
 #define PRINTUM printum  #define PRINTUM printum
 #define PRINTSF printsf  #define PRINTSF printsf
   #define PRINTSYMBOL printsymbol
   #define PRINTRANGE printrange
 #endif  #endif
   
 #ifdef SPRINT  #ifdef SPRINT
Line 112  extern int hex_output;
Line 119  extern int hex_output;
 extern int fortran_output;  extern int fortran_output;
 extern int double_output;  extern int double_output;
 extern int real_digit;  extern int real_digit;
   extern int real_binary;
 extern int print_quote;  extern int print_quote;
   
   
Line 148  extern int print_quote;
Line 156  extern int print_quote;
 #define PRINTUP sprintup  #define PRINTUP sprintup
 #define PRINTUM sprintum  #define PRINTUM sprintum
 #define PRINTSF sprintsf  #define PRINTSF sprintsf
   #define PRINTSYMBOL sprintsymbol
   #define PRINTRANGE sprintrange
 #endif  #endif
   
 void PRINTEXPR();  void PRINTEXPR();
Line 179  void PRINTEOP();
Line 189  void PRINTEOP();
 void PRINTLOP();  void PRINTLOP();
 void PRINTQOP();  void PRINTQOP();
 void PRINTSF();  void PRINTSF();
   void PRINTSYMBOL();
   void PRINTRANGE();
   
 #ifdef FPRINT  #ifdef FPRINT
 void output_init() {  void output_init() {
Line 209  P p;
Line 221  P p;
 void printbf(a)  void printbf(a)
 BF a;  BF a;
 {  {
         void sor();  
   
         sor(a->body,double_output ? 'f' : 'g',-1,0);          sor(a->body,double_output ? 'f' : 'g',-1,0);
 }  }
 #endif  #endif
Line 224  char *s;
Line 234  char *s;
 }  }
   
 #if defined(PARI)  #if defined(PARI)
 #include "genpari.h"  
   
 void myoutbrute(g)  void myoutbrute(g)
 GEN g;  GEN g;
 {  {
Line 236  void sprintbf(a)
Line 244  void sprintbf(a)
 BF a;  BF a;
 {  {
         char *str;          char *str;
         char *GENtostr();  
         char *GENtostr0();          char *GENtostr0();
   
         if ( double_output ) {          if ( double_output ) {
Line 294  Obj p;
Line 301  Obj p;
                         PRINTBYTEARRAY(vl,(BYTEARRAY)p); break;                          PRINTBYTEARRAY(vl,(BYTEARRAY)p); break;
                 case O_QUOTE:                  case O_QUOTE:
                         PRINTQUOTE(vl,(QUOTE)p); break;                          PRINTQUOTE(vl,(QUOTE)p); break;
                   case O_SYMBOL:
                           PRINTSYMBOL((SYMBOL)p); break;
                   case O_RANGE:
                           PRINTRANGE(vl,(RANGE)p); break;
                 default:                  default:
                         break;                          break;
         }          }
Line 395  Num q;
Line 406  Num q;
                                 case MID_PRINTF_G:                                  case MID_PRINTF_G:
 #endif  #endif
                                 default:                                  default:
                                         if ( real_digit ) {                                          if ( real_binary ) {
                                                   unsigned int *m;
                                                   unsigned int u,l,mask;
                                                   int i,expo;
   
                                                   m = (unsigned int *)&BDY((Real)q);
   #if defined(__i386__) || defined(MIPSEL) || defined(VISUAL) || defined(__alpha) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__x86_64)
                                                   u = m[1]; l = m[0];
   #else
                                                   u = m[0]; l = m[1];
   #endif
                                                   if (u&0x80000000) {
                                                           TAIL PRINTF(OUT,"-");
                                                   }
                                                   u &= 0x7fffffff;
                                                   expo = ((int)(u>>20));
                                                   u &= 0xfffff;
                                                   if ( expo == 2047 ) {
                                                           if ( u || l ) {
                                                                   TAIL PRINTF(OUT,"NaN");
                                                           } else {
                                                                   TAIL PRINTF(OUT,"Inf");
                                                           }
                                                   } else if ( expo == 0 ) {
                                                           if ( u || l ) {
                                                                   TAIL PRINTF(OUT,"0b0.");
                                                                   for ( i = 0, mask = 0x80000; i < 20;
                                                                           i++, mask >>= 1) {
                                                                           TAIL
                                                                           if ( u&mask )
                                                                                   PRINTF(OUT,"1");
                                                                           else
                                                                                   PRINTF(OUT,"0");
                                                                   }
                                                                   for ( i = 0, mask = 0x80000000; i < 32;
                                                                           i++, mask >>= 1) {
                                                                           TAIL
                                                                           if ( l&mask )
                                                                                   PRINTF(OUT,"1");
                                                                           else
                                                                                   PRINTF(OUT,"0");
                                                                   }
                                                                   TAIL PRINTF(OUT,"*2^%d",-1022);
                                                           } else {
                                                                   TAIL PRINTF(OUT,"0");
                                                           }
                                                   } else {
                                                           expo -= 1023;
                                                           TAIL PRINTF(OUT,"0b1.");
                                                           for ( i = 0, mask = 0x80000; i < 20;
                                                                   i++, mask >>= 1) {
                                                                   TAIL
                                                                   if ( u&mask )
                                                                           PRINTF(OUT,"1");
                                                                   else
                                                                           PRINTF(OUT,"0");
                                                           }
                                                           for ( i = 0, mask = 0x80000000; i < 32;
                                                                   i++, mask >>= 1) {
                                                                   TAIL
                                                                   if ( l&mask )
                                                                           PRINTF(OUT,"1");
                                                                   else
                                                                           PRINTF(OUT,"0");
                                                           }
                                                           if ( expo ) {
                                                                   TAIL PRINTF(OUT,"*2^%d",expo);
                                                           }
                                                   }
                                           } else if ( real_digit ) {
                                                 sprintf(real_format,                                                  sprintf(real_format,
                                                         double_output?"%%.%df":"%%.%dg",real_digit);                                                          double_output?"%%.%df":"%%.%dg",real_digit);
                                                 TAIL PRINTF(OUT,real_format,BDY((Real)q));                                                  TAIL PRINTF(OUT,real_format,BDY((Real)q));
Line 1100  unsigned int i;
Line 1180  unsigned int i;
         } else {          } else {
                 TAIL PRINTF(OUT,"@_%d",IFTOF(i));                  TAIL PRINTF(OUT,"@_%d",IFTOF(i));
         }          }
   }
   
   void PRINTSYMBOL(SYMBOL sym)
   {
           PUTS(sym->name);
   }
   
   void PRINTRANGE(VL vl,RANGE p)
   {
           PUTS("range(");
           PRINTEXPR(vl,p->start);
           PUTS(",");
           PRINTEXPR(vl,p->end);
           PUTS(")");
 }  }

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.29

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