🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Andreas Neyer Fri, 30 Sep 1988 02:34
(none)
#1452
Author: Andreas Neyer
Date: Fri, 30 Sep 1988 02:34
3894 lines
84508 bytes
Hi,

I just installed version 1.27 of gcc and g++. 
Since I have never installed a large program
I ran some of the tests for g++lib.a. 
They compiled and ran o.k.
Trying to compile my own program I encountered the 
problem/bug described below. I'd like to know whether
this is a bug in g++, an error in installing g++ or
something else.


Thank you in advance for your response: 

			Andreas Neyer
                        andreas@united


* Typescript:

Script started on Wed Sep 28 16:18:12 1988

santropez:1> g++ -v -c -I$HOME/include System.c

g++ version 1.27.0
 echo use .cc filename extension!
use .cc filename extension!
 /usr/tools/lib/gcc-cpp+ -v -I/united1/users/others/andreas/include -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__HAVE_FPU__ -Dmc68020 System.c /tmp/cca06459.cpp
GNU CPP version 1.27.0
 /usr/tools/lib/gcc-c++ /tmp/cca06459.cpp -quiet -dumpbase System.c -version -o /tmp/cca06459.s
GNU C++ version 1.27.0 (68k, MIT syntax) compiled by GNU C version 1.27.
Failed assertion (0) at line 1569 of `search.c'.
g++: Program c++ got fatal signal 6.

santropez:2> g++ -E -I$HOME/include System.c > Systemn .e
System.e: File exists.
santropez:3> g++ -E -I$HOME/include System.c >! System.e
santropez:4> exit
santropez:5> 
script done on Wed Sep 28 16:22:04 1988


* Machine:	

sun3/75


* Operating System:

Sun UNIX 4.2 Release 3.4 (GENERIC) #15: Fri Mar 4 10:17:54 PST 1988


* Machine dependent include files:

tm.h:	tm-sun3+.h ( as in SUN3.README )
md:     m68k.md



* File System.e ( produced with -E option see typescript above ):
----------------------------------------------------------------------
// use .cc filename extension!
# 1 "System.c"
# 1 "/united1/users/others/andreas/include/System.h"



# 1 "/usr/tools/lib/g++-include/math.h"
 
 






























overload acos;
overload acosh;
overload asin;
overload asinh;
overload atan2;
overload atanh;
overload ceil;
overload cos;
overload cosh;
overload exp;
overload floor;
overload gamma;
overload hypot;
overload log;
overload log10;
overload pow;
overload sin;
overload sinh;
overload sqrt;
overload tan;
overload tanh;

extern double  acos  (double) asm ("_" "acos") ;
extern double  acosh  (double) asm ("_" "acosh") ;
extern double  asin  (double) asm ("_" "asin") ;
extern double  asinh  (double) asm ("_" "asinh") ;
extern double  atan  (double) asm ("_" "atan") ;
extern double  atan2  (double, double) asm ("_" "atan2") ;
extern double  atanh  (double) asm ("_" "atanh") ;
extern double  cbrt  (double) asm ("_" "cbrt") ;
extern double  ceil  (double) asm ("_" "ceil") ;
extern double  copysign  (double,double) asm ("_" "copysign") ;
extern double  cos  (double) asm ("_" "cos") ;
extern double  cosh  (double) asm ("_" "cosh") ;
extern double  drem  (double,double) asm ("_" "drem") ;
extern double  erf  (double) asm ("_" "erf") ;
extern double  erfc  (double) asm ("_" "erfc") ;
extern double  exp  (double) asm ("_" "exp") ;
extern double  expm1  (double) asm ("_" "expm1") ;
extern double  fabs  (double) asm ("_" "fabs") ;
extern double  finite  (double) asm ("_" "finite") ;
extern double  floor  (double) asm ("_" "floor") ;
extern double  frexp  (double, int*) asm ("_" "frexp") ;
extern double  gamma  (double) asm ("_" "gamma") ;
extern double  hypot  (double,double) asm ("_" "hypot") ;
extern double  infnan  (int) asm ("_" "infnan") ;
extern int     isinf  (double) asm ("_" "isinf") ;
extern int     isnan  (double) asm ("_" "isnan") ;
extern double  j0  (double) asm ("_" "j0") ;
extern double  j1  (double) asm ("_" "j1") ;
extern double  jn  (int, double) asm ("_" "jn") ;
extern double  ldexp  (double, int) asm ("_" "ldexp") ;
extern double  lgamma  (double) asm ("_" "lgamma") ;
extern double  log  (double) asm ("_" "log") ;
extern double  log10  (double) asm ("_" "log10") ;
extern double  log1p  (double) asm ("_" "log1p") ;
extern double  logb  (double) asm ("_" "logb") ;
extern double  modf  (double, double*) asm ("_" "modf") ;
extern double  pow  (double, double) asm ("_" "pow") ;
extern double  rint  (double) asm ("_" "rint") ;
extern double  scalb  (double, int) asm ("_" "scalb") ;
extern double  sin  (double) asm ("_" "sin") ;
extern double  sinh  (double) asm ("_" "sinh") ;
extern double  sqrt  (double) asm ("_" "sqrt") ;
extern double  tan  (double) asm ("_" "tan") ;
extern double  tanh  (double) asm ("_" "tanh") ;
extern double  y0  (double) asm ("_" "y0") ;
extern double  y1  (double) asm ("_" "y1") ;
extern double  yn  (int, double) asm ("_" "yn") ;

 

 


struct exception
{
  int type;
  char* name;
  double arg1, arg2, retval;
};








int matherr(exception*);



# 1 "/usr/tools/lib/g++-include/values.h"
 
 


























































 
# 75 "/usr/tools/lib/g++-include/values.h"









# 126 "/usr/tools/lib/g++-include/math.h"


 





 

















































# 4 "/united1/users/others/andreas/include/System.h"

# 1 "/usr/tools/lib/g++-include/String.h"
 
 

























# 1 "/usr/tools/lib/g++-include/stream.h"
 
 
























# 1 "/usr/tools/lib/g++-include/File.h"
 
 
























# 1 "/usr/tools/lib/g++-include/builtin.h"
 

 





















 








overload clearbit;
overload dec;
overload gcd;
overload hex;
overload lcm;
overload lg;
overload oct;
overload setbit;
overload sign;
overload sqr;
overload testbit;

# 1 "/usr/tools/lib/g++-include/std.h"
 
 































overload abs; 

extern void      _exit  (int) asm ("_" "_exit") ;
extern void      abort  () asm ("_" "abort") ;
extern int       abs  (int) asm ("_" "abs") ;
extern int       access  (const char*, int) asm ("_" "access") ;
extern int       acct  (const char*) asm ("_" "acct") ;
extern unsigned  alarm  (unsigned) asm ("_" "alarm") ;
extern void*     alloca  (int) asm ("_" "alloca") ;
extern double    atof  (const char*) asm ("_" "atof") ;
extern int       atoi  (const char*) asm ("_" "atoi") ;
extern long      atol  (const char*) asm ("_" "atol") ;
extern int       bcmp  (const void*, const void*, int) asm ("_" "bcmp") ;
extern int       bcopy  (const void*, void*, int) asm ("_" "bcopy") ;
extern void*     brk  (void*) asm ("_" "brk") ;
extern int       bzero  (void*, int) asm ("_" "bzero") ;
extern void*     calloc  (unsigned, unsigned) asm ("_" "calloc") ;
extern void      cfree  (void*) asm ("_" "cfree") ;
extern int       chdir  (const char*) asm ("_" "chdir") ;
extern int       chmod  (const char*, int) asm ("_" "chmod") ;
extern int       chown  (const char*, int, int) asm ("_" "chown") ;
extern long      clock  () asm ("_" "clock") ;
extern int       close  (int) asm ("_" "close") ;
extern int       creat  (const char*, int) asm ("_" "creat") ;
extern char*     crypt  (const char*, const char*) asm ("_" "crypt") ;
extern char*     ctermid  (char*) asm ("_" "ctermid") ;
extern char*     cuserid  (char*) asm ("_" "cuserid") ;
extern double    drand48  () asm ("_" "drand48") ;
extern int       dup  (int) asm ("_" "dup") ;
extern int       dup2  (int, int) asm ("_" "dup2") ;
extern int       dysize  (int) asm ("_" "dysize") ;
extern char*     ecvt  (double, int, int*, int*) asm ("_" "ecvt") ;
extern char*     encrypt  (char*, int) asm ("_" "encrypt") ;
extern double    erand  (short*) asm ("_" "erand") ;
extern int       execl  (const char*, const char *, ...) asm ("_" "execl") ;
extern int       execle  (const char*, const char *, ...) asm ("_" "execle") ;
extern int       execlp  (const char*, const char*, ...) asm ("_" "execlp") ;
extern int       exect  (const char*,  const char**,  char**) asm ("_" "exect") ;
extern int       execv  (const char*,  const char**) asm ("_" "execv") ;
extern int       execve  (const char*, const char**, char**) asm ("_" "execve") ;
extern int       execvp  (const char*,  const char**) asm ("_" "execvp") ;
extern void      exit  (int) asm ("_" "exit") ;
extern int       fchmod  (int, int) asm ("_" "fchmod") ;
extern int       fchown  (int, int, int) asm ("_" "fchown") ;
extern int       fcntl  (int, int, int) asm ("_" "fcntl") ;
extern char*     fcvt  (double, int, int*, int*) asm ("_" "fcvt") ;
extern int       ffs  (int) asm ("_" "ffs") ;
extern int       flock  (int, int) asm ("_" "flock") ;
extern int       fork  () asm ("_" "fork") ;
extern void      free  (void*) asm ("_" "free") ;
extern int       fsync  (int) asm ("_" "fsync") ;
extern long      ftok  (const char*, int) asm ("_" "ftok") ;
extern int       ftruncate  (int, unsigned long) asm ("_" "ftruncate") ;
extern char*     gcvt  (double, int, char*) asm ("_" "gcvt") ;
extern char*     getcwd  (char*, int) asm ("_" "getcwd") ;
extern int       getdomainname  (char*, int) asm ("_" "getdomainname") ;
extern int       getdtablesize  () asm ("_" "getdtablesize") ;
extern int       getegid  () asm ("_" "getegid") ;
extern char*     getenv  (const char*) asm ("_" "getenv") ;
extern int       geteuid  () asm ("_" "geteuid") ;
extern int       getgid  () asm ("_" "getgid") ;
extern int       getgroups  (int, int*) asm ("_" "getgroups") ;
extern long      gethostid  () asm ("_" "gethostid") ;
extern int       gethostname  (char*, int) asm ("_" "gethostname") ;
extern char*     getlogin  () asm ("_" "getlogin") ;
extern int       getopt  (int, char**, char*) asm ("_" "getopt") ;
extern int       getpagesize  () asm ("_" "getpagesize") ;
extern char*     getpass  (const char*) asm ("_" "getpass") ;
extern int       getpgrp  () asm ("_" "getpgrp") ;
extern int       getpid  () asm ("_" "getpid") ;
extern int       getppid  () asm ("_" "getppid") ;
extern int       getpriority  (int, int) asm ("_" "getpriority") ;
extern int       getpw  (int, char*) asm ("_" "getpw") ;
extern unsigned  getuid  () asm ("_" "getuid") ;
extern char*     getwd  (const char*) asm ("_" "getwd") ;
extern char*     index  (const char*, int) asm ("_" "index") ;
extern char*     initstate  (unsigned, char*, int) asm ("_" "initstate") ;
extern int       ioctl  (int, int, char*) asm ("_" "ioctl") ;
extern int       isatty  (int) asm ("_" "isatty") ;
extern long      jrand48  (short*) asm ("_" "jrand48") ;
extern int       kill  (int, int) asm ("_" "kill") ;
extern int       killpg  (int, int) asm ("_" "killpg") ;
extern void      lcong48  (short*) asm ("_" "lcong48") ;
extern int       link  (const char*, const char*) asm ("_" "link") ;
extern int       lock  (int, int, long) asm ("_" "lock") ;
extern long      lrand48  () asm ("_" "lrand48") ;
extern long      lseek  (int, long, int) asm ("_" "lseek") ;
extern void*     malloc  (unsigned) asm ("_" "malloc") ;
extern void*     memalign  (unsigned, unsigned) asm ("_" "memalign") ;
extern void*     memccpy  (void*, const void*, int, int) asm ("_" "memccpy") ;
extern void*     memchr  (const void*, int, int) asm ("_" "memchr") ;
extern int       memcmp  (const void*, const void*, int) asm ("_" "memcmp") ;
extern void*     memcpy  (void*, const void*, int) asm ("_" "memcpy") ;
extern void*     memset  (void*, int, int) asm ("_" "memset") ;
extern int       mkdir  (const char*, int) asm ("_" "mkdir") ;
extern int       mknod  (const char*, int, int) asm ("_" "mknod") ;
extern char*     mkstemp  (char*) asm ("_" "mkstemp") ;
extern char*     mktemp  (char*) asm ("_" "mktemp") ;
extern long      mrand48  () asm ("_" "mrand48") ;
extern int       nice  (int) asm ("_" "nice") ;
extern long      nrand48  (short*) asm ("_" "nrand48") ;
extern int       open  (const char*, int, ...) asm ("_" "open") ;
extern void      pause  () asm ("_" "pause") ;
extern void      perror  (const char*) asm ("_" "perror") ;
extern int       pipe   (int*) asm ("_" "pipe") ;
extern void      profil  (char*, int, int, int) asm ("_" "profil") ;
extern int       psignal  (unsigned, char*) asm ("_" "psignal") ;
extern int       ptrace  (int, int, int, int) asm ("_" "ptrace") ;
extern int       putenv  (const char*) asm ("_" "putenv") ;
extern int       rand  () asm ("_" "rand") ;
extern long      random  () asm ("_" "random") ;
extern int       read  (int, void*, unsigned) asm ("_" "read") ;
extern int       readlink  (const char*, char*, int) asm ("_" "readlink") ;
extern void*     realloc  (void*, unsigned) asm ("_" "realloc") ;
extern int       rename  (const char*, const char*) asm ("_" "rename") ;
extern char*     rindex  (const char*, int) asm ("_" "rindex") ;
extern int       rmdir  (const char*) asm ("_" "rmdir") ;               
extern void*     sbrk  (int) asm ("_" "sbrk") ;              
extern short*    seed48  (short*) asm ("_" "seed48") ;
extern int       send  (int, char*, int, int) asm ("_" "send") ;
extern int       setgid  (int) asm ("_" "setgid") ;
extern int       sethostname  (char*, int) asm ("_" "sethostname") ;
extern int       setkey  (const char*) asm ("_" "setkey") ;
extern int       setpgrp  (int, int) asm ("_" "setpgrp") ;
extern int       setpriority  (int, int, int) asm ("_" "setpriority") ;
extern int       setregid  (int, int) asm ("_" "setregid") ;
extern int       setreuid  (int, int) asm ("_" "setreuid") ;
extern char*     setstate  (char*) asm ("_" "setstate") ;
extern int       setuid  (int) asm ("_" "setuid") ;
extern int       sigblock  (int) asm ("_" "sigblock") ;
extern int       siginterrupt  (int, int) asm ("_" "siginterrupt") ;
extern int       sigpause  (int) asm ("_" "sigpause") ;
extern int       sigsetmask  (int) asm ("_" "sigsetmask") ;
extern unsigned  sleep  (unsigned) asm ("_" "sleep") ;
extern int       srand  (int) asm ("_" "srand") ;
extern void      srand48  (long) asm ("_" "srand48") ;
extern void      srandom  (int) asm ("_" "srandom") ;
extern int       stime  (long*) asm ("_" "stime") ;
extern char*     strcat  (char*, const char*) asm ("_" "strcat") ;
extern char*     strchr  (const char*, int) asm ("_" "strchr") ;
extern int       strcmp  (const char*, const char*) asm ("_" "strcmp") ;
extern char*     strcpy  (char*, const char*) asm ("_" "strcpy") ;
extern int       strcspn  (const char*, const char*) asm ("_" "strcspn") ;
extern char*     strdup  (const char*) asm ("_" "strdup") ;
extern int       strlen  (const char*) asm ("_" "strlen") ;
extern char*     strncat  (char*, const char*, int) asm ("_" "strncat") ;
extern int       strncmp  (const char*, const char*, int) asm ("_" "strncmp") ;
extern char*     strncpy  (char*, const char*, int) asm ("_" "strncpy") ;
extern char*     strpbrk  (const char*, const char*) asm ("_" "strpbrk") ;
extern char*     strrchr  (const char*, int) asm ("_" "strrchr") ;
extern int       strspn  (const char*, const char*) asm ("_" "strspn") ;
extern double    strtod  (const char*, char**) asm ("_" "strtod") ;
extern char*     strtok  (char*, const char*) asm ("_" "strtok") ;
extern long      strtol  (const char*, char**, int) asm ("_" "strtol") ;
extern void      swab  (void*, void*, int) asm ("_" "swab") ;
extern int       symlink  (const char*, const char*) asm ("_" "symlink") ;
extern int       syscall  (int, ...) asm ("_" "syscall") ;
extern int       system  (const char*) asm ("_" "system") ;
extern char*     tempnam  (char*, char*) asm ("_" "tempnam") ;
extern long      time  (long*) asm ("_" "time") ;
 
extern char*     tmpnam  (char*) asm ("_" "tmpnam") ;
extern int       truncate  (const char*, unsigned long) asm ("_" "truncate") ;
extern char*     ttyname  (int) asm ("_" "ttyname") ;
extern int       ttyslot  () asm ("_" "ttyslot") ;
extern unsigned  ualarm  (unsigned, unsigned) asm ("_" "ualarm") ;
extern long      ulimit  (int, long) asm ("_" "ulimit") ;
extern int       umask  (int) asm ("_" "umask") ;
extern int       unlink  (const char*) asm ("_" "unlink") ;
extern unsigned  usleep  (unsigned) asm ("_" "usleep") ;
extern int       vadvise  (int) asm ("_" "vadvise") ;
extern void*     valloc  (unsigned) asm ("_" "valloc") ;
extern int       vfork  () asm ("_" "vfork") ;
extern int       vhangup  () asm ("_" "vhangup") ;
extern int       wait  (int*) asm ("_" "wait") ;
extern int       write  (int, const void*, unsigned) asm ("_" "write") ;


extern char**   environ;
extern int      errno;
extern char*    sys_errlist[];
extern int      sys_nerr;                  
extern char*    optarg;
extern int      opterr;
extern int      optind;


# 46 "/usr/tools/lib/g++-include/builtin.h"

# 1 "/usr/tools/lib/g++-include/math.h"
 
 






















# 183 "/usr/tools/lib/g++-include/math.h"

# 47 "/usr/tools/lib/g++-include/builtin.h"


long         abs(long x);
double       abs(double x);
void         clearbit(long& x, long b);
void         setbit(long& x, long b);
int          testbit(long x, long b);
int          even(long y);
long         gcd(long x, long y);
long         lg(long x); 
long         lcm(long x, long y);
int          odd(long y);
double       pow(double x, long p);
long         pow(long x, long y);
int          sign(long x);
int          sign(double x);
long         sqr(long x);
double       sqr(double x);
long         sqrt(long y);

char*        itoa(long x, int base = 10, int width = 0);
char*        hex(long x, int width = 0);
char*        oct(long x, int width = 0);
char*        dec(long x, int width = 0);
char*        form(const char* fmt ...);

unsigned int hashpjw(const char*);
unsigned int multiplicativehash(int);
unsigned int foldhash(double);

 

inline double abs(double x) 
{
  return (x < 0.0)? -x : x;
}

inline long abs(long x) 
{
  return (x < 0)? -x : x;
}

inline int sign(long x)
{
  return (x == 0) ? 0 : ( (x > 0) ? 1 : -1 );
}

inline int sign(double x)
{
  return (x == 0.0) ? 0 : ( (x > 0.0) ? 1 : -1 );
}

inline long sqr(long x)
{
  return x * x;
}

inline double sqr(double x)
{
  return x * x;
}

inline int even(long y)
{
  return !(y & 1);
}

inline int odd(long y)
{
  return (y & 1);
}

inline long lcm(long x, long y)
{
  return x / gcd(x, y) * y;
}

inline void setbit(long& x, long b)
{
  x |= (1 << b);
}

inline void clearbit(long& x, long b)
{
  x &= ~(1 << b);
}

inline int testbit(long x, long b)
{
  return ((x & (1 << b)) != 0);
}

 


# 27 "/usr/tools/lib/g++-include/File.h"

# 1 "/usr/tools/lib/g++-include/stdio.h"
 
 





















 




























 



 


extern  struct  _iobuf {
    int      _cnt;
    char*    _ptr;
    char*    _base;

    int     _bufsiz;
    short   _flag;



    char    _file;
} _iob[];



































extern int    _doprnt(const char*, void*,     struct _iobuf *);
extern int    _doscan(    struct _iobuf *, const char*, void*);
extern int    _filbuf(    struct _iobuf *);
extern int    _flsbuf(unsigned,     struct _iobuf *);
extern int    fclose(    struct _iobuf *);
extern     struct _iobuf *  fdopen(int, const char*);
extern int    fflush(    struct _iobuf *);
extern int    fgetc(    struct _iobuf *);
extern char*  fgets(char*, int,     struct _iobuf  *);
extern     struct _iobuf *  fopen(const char*, const char*);
extern int    fprintf(    struct _iobuf *, const char* ...);
extern int    fputc(int,     struct _iobuf *);
extern int    fputs(const char*,     struct _iobuf *);
extern int    fread(void*, int, int,     struct _iobuf *);
extern     struct _iobuf *  freopen(const char*, const char*,     struct _iobuf *);
extern int    fscanf(    struct _iobuf *, const char* ...);
extern int    fseek(    struct _iobuf *, long, int);
extern long   ftell(    struct _iobuf  *);
extern int    fwrite(const void*, int, int,     struct _iobuf *);
extern char*  gets(char*);
extern int    getw(    struct _iobuf *);
extern int    pclose(    struct _iobuf *);
extern     struct _iobuf *  popen(const char*, const char*);
extern int    printf(const char* ...);
extern void   puts(const char*);
extern int    putw(int,     struct _iobuf *);
extern int    scanf(const char* ...);
extern void   setbuf(    struct _iobuf *, char*);
extern void   setbuffer(    struct _iobuf *, char*, int);
extern void   setlinebuf(    struct _iobuf *);
extern void   setvbuf(    struct _iobuf *, char*, int, int);
extern int    sscanf(char*, const char* ...);
extern     struct _iobuf *  tmpfile();
extern int    ungetc(int,     struct _iobuf *);
extern int    vfprintf(    struct _iobuf *, const char*, void* ap);
extern int    vprintf(const char*, void* ap);
extern int    vsprintf(char*, const char*, void* ap);


extern int    sprintf(char*, const char* ...);





# 28 "/usr/tools/lib/g++-include/File.h"

# 1 "/usr/tools/lib/g++-include/stddef.h"
 
 



























enum bool   
{           
  FALSE = 0,
  TRUE  = 1              
};





















typedef void (*one_arg_error_handler_t)(char*);


# 29 "/usr/tools/lib/g++-include/File.h"


enum io_mode                     
{
  io_readonly   = 0,            
  io_writeonly  = 1,
  io_readwrite  = 2, 
  io_appendonly = 3,
  io_append     = 4,             
};

enum access_mode                 
{
  a_createonly  = 0,             
  a_create      = 1,             
  a_useonly     = 2,             
  a_use         = 3,             
};

enum state_value                 
{ 
  _good         = 0,             
  _eof          = 1,             
  _fail         = 2,             
  _bad          = 4              
};


class File
{
protected:
      struct _iobuf *         fp;               
  char*         nm;               
  char          rw;               
  state_value   state;            
  long          stat;             

  void          initialize();
  void          reinitialize(const char*);
  void          check_state();

public:
                File();
                File(const char* filename, io_mode m, access_mode a);
                File(const char* filename, const char* m);   
                File(int filedesc, io_mode m);
                File(    struct _iobuf * fileptr);

                ~File();

 

  File&         open(const char* filename, io_mode m, access_mode a);
  File&         open(const char* filename, const char* m);
  File&         open(int  filedesc, io_mode m);
  File&         open(    struct _iobuf * fileptr);

  File&         close();
  File&         remove();

 

  int           filedesc();
  const char*   name();
  void          setname(const char* newname);
  int           iocount();

  int           rdstate();
  int           eof();
  int           fail();
  int           bad();
  int           good();

 

  int           readable();
  int           writable();
  int           is_open();

  void*         operator void*();

 

  void          error();
  void          clear(state_value f = 0);  
  File&         failif(int cond);

 

  File&         get(char& c);
  File&         put(char  c);
  File&         unget(char c);
  File&         putback(char c);  

 

  File&         put(const char* s);
  File&         get    (char* s, int n, char terminator = '\n');
  File&         getline(char* s, int n, char terminator = '\n');

 

  File&         read(void* x, int sz, int n);
  File&         write(void* x, int sz, int n);


 

  File&         seek(long pos, int seek_mode=0);  
  long          tell();

  File&         flush();
  File&         setbuf(int buffer_kind);  
  File&         setbuf(int size, char* buf);
  File&         raw();
};


 

extern void  verbose_File_error_handler(char*);
extern void  quiet_File_error_handler(char*);
extern void  fatal_File_error_handler(char*);
extern one_arg_error_handler_t File_error_handler;

extern  one_arg_error_handler_t 
             set_File_error_handler(one_arg_error_handler_t f);

 

inline int File::filedesc()
{ 
  return   ((fp)->_file) ;
}

inline const char* File::name()
{ 
  return nm; 
}

inline int File::rdstate()
{ 
  check_state();  return state;  
}                                

inline void* File::operator void*()
{ 
  return (state & (_bad|_fail))? 0 : this ; 
}

inline int File::eof()
{ 
  check_state(); return state & _eof; 
}

inline int File::fail()
{ 
  check_state(); return state & _fail; 
}

inline int File::bad()
{ 
  check_state(); return state & _bad; 
}

inline int File::good()
{ 
  check_state(); return rdstate() == _good; 
}

inline int File::iocount()
{ 
  return stat; 
}

inline int File::readable()
{ 
  return ((rw & 01) && (state & (_fail|_bad)) == 0);
}

inline int File::writable()
{ 
  return ((rw & 02) && (state & (_fail|_bad)) == 0);
}


inline int File::is_open()
{ 
  return (fp != 0);
}

inline void File::clear(state_value flag = 0)
{ 
  state = flag;
}

inline File& File::raw()
{ 
  return File::setbuf(   00004 ); 
}

 


# 27 "/usr/tools/lib/g++-include/stream.h"


class whitespace                 
{                                
  char filler;                     
};

class ostream: File
{
public:
           File::open;      File::close;
           File::remove;    File::filedesc;  File::is_open;
           File::raw;       File::put;       
           File::iocount;   File::error;     File::name;
           File::setname;   File::rdstate;   File::flush;
           File::eof;       File::fail;      File::bad;
           File::good;      File::clear;     File::failif;
           File::setbuf;    File::writable;  File::readable;
           

           ostream();
           ostream(const char* filename, io_mode m, access_mode a);
           ostream(const char* filename, const char* m);
           ostream(int filedesc, io_mode m = io_writeonly);
           ostream(    struct _iobuf * fileptr);

           ~ostream();

  void*    operator void*();

  ostream& form(const char* fmt, ...);           

  ostream& operator << (char   c);
  ostream& operator << (short  n);
  ostream& operator << (unsigned short n);
  ostream& operator << (int    n);
  ostream& operator << (unsigned int n);
  ostream& operator << (long   n);
  ostream& operator << (unsigned long n);
  ostream& operator << (float  n);
  ostream& operator << (double n);
  ostream& operator << (const char* s);
};


class istream: File
{
  ostream* tied_to;         
  void     _flush();

public:
           File::open;      File::close;     File::get;
           File::remove;    File::filedesc;  File::is_open;
           File::raw;       File::unget;     File::getline;
           File::iocount;   File::error;     File::name;
           File::setname;   File::rdstate;   File::putback;
           File::eof;       File::fail;      File::bad;
           File::good;      File::clear;     File::failif;
           File::setbuf;    File::writable;  File::readable;


           istream();
           istream(const char* filename, io_mode m, access_mode a);
           istream(const char* filename, const char* m);
           istream(int filedesc, io_mode m = io_readonly);
           istream(    struct _iobuf * fileptr);

           ~istream();

  void*    operator void*();

  ostream* tie(ostream* s);

  istream& scan(const char* fmt, ...);

  istream& operator >> (char&   c);
  istream& operator >> (short&  n);
  istream& operator >> (unsigned short& n);
  istream& operator >> (int&    n);
  istream& operator >> (unsigned int& n);
  istream& operator >> (long&   n);
  istream& operator >> (unsigned long& n);
  istream& operator >> (float&  n);
  istream& operator >> (double& n);
  istream& operator >> (char*   s);
  istream& operator >> (whitespace& w);
};

void eatwhite(istream& s);


 

extern istream  cin;              
extern ostream  cout;             
extern ostream  cerr;             

extern whitespace WS;             

 


inline void* ostream::operator void*()
{ 
  return (state & (_bad|_fail))? 0 : this ; 
}

inline ostream& ostream::operator<<(char   c)
{ 
  put(c);
  return *this;
}

inline ostream& ostream::operator<<(short  n)
{ 
  return form("%d",(int)n);
}

inline ostream& ostream::operator<<(unsigned short n)
{ 
  return form("%u",(unsigned)n);
}

inline ostream& ostream::operator<<(int    n)
{ 
  return form("%d",n);
}

inline ostream& ostream::operator<<(unsigned int n)
{ 
  return form("%u",n);
}

inline ostream& ostream::operator<<(long   n)
{ 
  return form("%ld",n);
}

inline ostream& ostream::operator<<(unsigned long n)
{ 
  return form("%lu",n);
}

inline ostream& ostream::operator<<(float  n)
{ 
  return form("%g",(double)n);
}

inline ostream& ostream::operator<<(double n)
{ 
  return form("%g",n);
}

inline ostream& ostream::operator<<(const char* s)
{ 
  put(s);
  return *this;
}

inline void*    istream::operator void*()
{ 
  return (state & (_bad|_fail))? 0 : this ; 
}

inline istream& istream::operator>>(char&   c)
{ 
  _flush();
  get(c);
  return *this;
}

inline istream& istream::operator>>(short&  n)
{ 
  return scan("%hd", &n); 
}

inline istream& istream::operator>>(unsigned short& n)
{ 
  return scan("%hd", &n); 
}

inline istream& istream::operator>>(int&    n)
{ 
  return scan("%d",  &n); 
}

inline istream& istream::operator>>(unsigned int& n)
{ 
  return scan("%d",  &n); 
}

inline istream& istream::operator>>(long&   n)
{ 
  return scan("%ld", &n); 
}

inline istream& istream::operator>>(unsigned long& n)
{ 
  return scan("%ld", &n); 
}

inline istream& istream::operator>>(float&  n)
{ 
  return scan("%f",  &n); 
}

inline istream& istream::operator>>(double& n)
{ 
  return scan("%lf", &n); 
}

inline istream& istream::operator>>(char*   s)
{ 
  return scan("%s",   s); 
}

 


# 28 "/usr/tools/lib/g++-include/String.h"


struct _Srep                      
{
  unsigned short    len;          
  unsigned short    sz;           
  short             ref;          
  char              s[1];         
                                  
                                  
};


class String;
class SubString;


struct re_pattern_buffer;        
struct re_registers;

class Regex
{
  friend class       String;
  friend class       SubString;

  re_pattern_buffer* buf;
  re_registers*      reg;

  void               initialize(const char* t, int tlen, int fast, 
                                int bufsize, const char* transtable);

public:
                     Regex(const char* t, 
                           int fast = 0, 
                           int bufsize = 40, 
                           const char* transtable = 0);

                     Regex(String& x, 
                           int fast = 0, 
                           int bufsize = 40, 
                           const char* transtable = 0);

                     ~Regex();

  int                match(const char* s, int len, int pos = 0);
  int                search(const char* s, int len, 
                            int& matchlen, int startpos = 0);
};


class SubString
{
  friend class      String;

  String*           S;
  unsigned short    pos;
  unsigned short    len;

  void              assign(_Srep*, const char*, int = -1);
                    SubString(String* x, int p, int l);
                    SubString(SubString& x);

public:
                    ~SubString();

  void              operator =  (String&     y);
  void              operator =  (SubString&  y);
  void              operator =  (const char* t);
  void              operator =  (char        c);
  
  friend String     operator +  (SubString& x, String&     y);
  friend String     operator +  (String&    x, SubString&  y);
  friend String     operator +  (SubString& x, SubString&  y);
  friend String     operator +  (SubString& x, const char* t);
  friend String     operator +  (SubString& x, char        c);

  friend int        operator == (SubString& x, String&     y);
  friend int        operator == (String&    x, SubString&  y);
  friend int        operator == (SubString& x, SubString&  y);
  friend int        operator == (SubString& x, const char* t);
  
  friend int        operator != (SubString& x, String&     y);
  friend int        operator != (String&    x, SubString&  y);
  friend int        operator != (SubString& x, SubString&  y);
  friend int        operator != (SubString& x, const char* t);
  
  friend int        operator <= (SubString& x, String&     y);
  friend int        operator <= (String&    x, SubString&  y);
  friend int        operator <= (SubString& x, SubString&  y);
  friend int        operator <= (SubString& x, const char* t);
  
  friend int        operator <  (SubString& x, String&     y);
  friend int        operator <  (String&    x, SubString&  y);
  friend int        operator <  (SubString& x, SubString&  y);
  friend int        operator <  (SubString& x, const char* t);
  
  friend int        operator >= (SubString& x, String&     y);
  friend int        operator >= (String&    x, SubString&  y);
  friend int        operator >= (SubString& x, SubString&  y);
  friend int        operator >= (SubString& x, const char* t);
  
  friend int        operator >  (SubString& x, String&     y);
  friend int        operator >  (String&    x, SubString&  y);
  friend int        operator >  (SubString& x, SubString&  y);
  friend int        operator >  (SubString& x, const char* t);

  int               contains(char        c);
  int               contains(String&     y);
  int               contains(SubString&  y);
  int               contains(const char* t);
  int               contains(Regex&       r);

  int               matches(Regex&  r);

 

  int               length();
  int               empty();
  const char*       operator char*();

  friend ostream&   operator<<(ostream& s, SubString& x);

 

  friend int        compare(SubString& x, String&     y);
  friend int        compare(String&    x, SubString&  y);
  friend int        compare(SubString& x, SubString&  y);
  friend int        compare(SubString& x, const char* y);

  friend void       concat(SubString&  x, String&     y, String& result);
  friend void       concat(SubString&  x, SubString&  y, String& result);
  friend void       concat(SubString&  x, const char* y, String& result);
  friend void       concat(SubString&  x, char        y, String& result);
  friend void       concat(String&     x, SubString&  y, String& result);
};


class String
{
  friend class      SubString;
  friend class      Regex;

  _Srep*            rep;

  int               search(int, int, const char*, int = -1);
  int               search(int, int, char);
  int               match(int, int, int, const char*, int = -1);
  void              _gsub(const char*, int, const char* ,int);
  void              _gsub(Regex&, const char*, int);

public:

 

                    String();
                    String(String&     x);
                    String(SubString&  x);
                    String(const char* t);
                    String(const char* t, int len);
                    String(char c);

                    ~String();

  String&           operator =  (String&     y);
  String&           operator =  (const char* y);
  String&           operator =  (char        c);
  String&           operator =  (SubString&  y);

 

  friend String     operator +  (String& x, String&     y);     
  friend String     operator +  (String& x, const char* t);
  friend String     operator +  (String& x, char        c);
  friend String     operator +  (String& x, SubString&  y);     
  friend String     operator +  (SubString& x, String&  y);     

  String&           operator += (String&     y);
  String&           operator += (SubString&  y);
  String&           operator += (const char* t);
  String&           operator += (char        c);

 

  friend int        operator == (String&     x, String&     y);
  friend int        operator == (String&     x, const char* t);
  friend int        operator == (String&     x, SubString&  y);
  friend int        operator == (SubString&  x, String&     y);
  
  friend int        operator != (String&     x, String&     y);
  friend int        operator != (String&     x, const char* t);
  friend int        operator != (String&     x, SubString&  y);
  friend int        operator != (SubString&  x, String&     y);
  
  friend int        operator <= (String&     x, String&     y);
  friend int        operator <= (String&     x, const char* t);
  friend int        operator <= (String&     x, SubString&  y);
  friend int        operator <= (SubString&  x, String&     y);
  
  friend int        operator <  (String&     x, String&     y);
  friend int        operator <  (String&     x, const char* t);
  friend int        operator <  (String&     x, SubString&  y);
  friend int        operator <  (SubString&  x, String&     y);
  
  friend int        operator >= (String&     x, String&     y);
  friend int        operator >= (String&     x, const char* t);
  friend int        operator >= (String&     x, SubString&  y);
  friend int        operator >= (SubString&  x, String&     y);
  
  friend int        operator >  (String&     x, String&     y);
  friend int        operator >  (String&     x, const char* t);
  friend int        operator >  (String&     x, SubString&  y);
  friend int        operator >  (SubString&  x, String&     y);

  friend int        fcompare(String&   x, String&     y);  

 

  int               index(char        c, int startpos = 0);      
  int               index(String&     y, int startpos = 0);      
  int               index(SubString&  y, int startpos = 0);      
  int               index(const char* t, int startpos = 0);  
  int               index(Regex&      r, int startpos = 0);       

  int               contains(char        c);
  int               contains(String&     y);
  int               contains(SubString&  y);
  int               contains(const char* t);
  int               contains(Regex&      r);

  int               contains(char        c, int pos);
  int               contains(String&     y, int pos);
  int               contains(SubString&  y, int pos);
  int               contains(const char* t, int pos);
  int               contains(Regex&      r, int pos);

  int               matches(char        c, int pos = 0);
  int               matches(String&     y, int pos = 0);
  int               matches(SubString&  y, int pos = 0);
  int               matches(const char* t, int pos = 0);
  int               matches(Regex&      r, int pos = 0);

 

  SubString         at(int         pos, int len);
  SubString         at(String&     x, int startpos = 0); 
  SubString         at(SubString&  x, int startpos = 0); 
  SubString         at(const char* t, int startpos = 0);
  SubString         at(char        c, int startpos = 0);
  SubString         at(Regex&      r, int startpos = 0); 

  SubString         before(int          pos);
  SubString         before(String&      x, int startpos = 0);
  SubString         before(SubString&   x, int startpos = 0);
  SubString         before(const char*  t, int startpos = 0);
  SubString         before(char         c, int startpos = 0);
  SubString         before(Regex&       r, int startpos = 0);

  SubString         after(int         pos);
  SubString         after(String&     x, int startpos = 0);
  SubString         after(SubString&  x, int startpos = 0);
  SubString         after(const char* t, int startpos = 0);
  SubString         after(char        c, int startpos = 0);
  SubString         after(Regex&      r, int startpos = 0);

 

  void              del(int         pos, int len);
  void              del(String&     y, int startpos = 0);
  void              del(SubString&  y, int startpos = 0);
  void              del(const char* t, int startpos = 0);
  void              del(char        c, int startpos = 0);
  void              del(Regex&      r, int startpos = 0);

  void              gsub(String&     pat, String&     repl);
  void              gsub(SubString&  pat, String&     repl);
  void              gsub(const char* pat, String&     repl);
  void              gsub(const char* pat, const char* repl);
  void              gsub(Regex&      pat, String&     repl);

 

  friend int        decompose(String& x, String& l, String& m, String& r,
                              Regex& pat, int startpos = 0);

  friend int        split(String& x, String res[], int maxn, String& sep);
  friend int        split(String& x, String res[], int maxn, Regex&  sep);

  friend String     join(String src[], int n, String& sep);

  friend String     replicate(char        c, int n);
  friend String     replicate(String&     y, int n);

  friend String     common_prefix(String& x, String& y, int startpos = 0);
  friend String     common_suffix(String& x, String& y, int startpos = -1);

  friend String     reverse(String& x);
  friend String     upcase(String& x);
  friend String     downcase(String& x);
  friend String     capitalize(String& x);

 

  void              reverse();
  void              upcase();
  void              downcase();
  void              capitalize();

 

  char              operator [] (int i);
  const char*       operator char*();

 

  friend ostream&   operator<<(ostream& s, String& x);
  friend ostream&   operator<<(ostream& s, SubString& x);
  friend istream&   operator>>(istream& s, String& x);

 

  int               length();
  int               empty();
  int               operator ! ();
  void              make_unique();
  void              setlength(int l);
  void              error(char* msg);

 

  friend int        compare(String&    x, String&     y);
  friend int        compare(String&    x, SubString&  y);
  friend int        compare(String&    x, const char* y);
  friend int        compare(SubString& x, String&     y);

  friend void       concat(String&    x, String&     y, String& result);
  friend void       concat(String&    x, SubString&  y, String& result);
  friend void       concat(SubString& x, String&     y, String& result);
  friend void       concat(String&    x, const char* y, String& result);
  friend void       concat(String&    x, char        y, String& result);

  void              copy(const char* y, int len = -1);
  void              copy(String& y);
  void              copy(SubString& y);
  void              copy(char y);
};



 

extern Regex RXwhite;           
extern Regex RXint;             
extern Regex RXdouble;          
                                
                                
extern Regex RXalpha;           
extern Regex RXlowercase;       
extern Regex RXuppercase;       
extern Regex RXalphanum;        
extern Regex RXidentifier;      


extern void default_String_error_handler(char*);
extern one_arg_error_handler_t String_error_handler;

extern one_arg_error_handler_t 
        set_String_error_handler(one_arg_error_handler_t f);

 


extern _Srep  _nil_Srep;

inline String::String()
{ 
  rep = &_nil_Srep;
}

inline String::String(String& x)
{ 
  rep = x.rep; if (rep->ref > 0) rep->ref++;
}

inline String::String(const char* t)
{
  rep = &_nil_Srep; copy(t);
}

inline String::String(const char* t, int tlen)
{
  rep = &_nil_Srep; copy(t, tlen);
}

inline String::String(SubString& y)
{
  rep = &_nil_Srep; copy(&(y.S->rep->s[y.pos]), y.len);
}

inline String::String(char c)
{
  rep = &_nil_Srep; char ch = c; copy(&ch, 1);
}

inline String::~String()
{ 
  if (rep->ref > 0 && --rep->ref == 0) delete rep;
}

inline String& String::operator =  (String& y)
{ 
  y.rep->ref++;
  if (rep->ref > 0 && --rep->ref == 0) delete rep;
  rep = y.rep;
  return *this; 
}

inline String& String::operator=(const char* t)
{
  copy(t); return *this;
}

inline String& String::operator=(SubString&  y)
{
  copy(&(y.S->rep->s[y.pos]), y.len); return *this;
}

inline String& String::operator=(char c)
{
  char ch = c;  copy(&ch, 1); return *this;
}


inline void String::copy(char c)
{
  char ch = c; copy(&ch, 1);
}

inline void String::copy(String& y)
{
  copy(y.rep->s, y.rep->len);
}

inline void String::copy(SubString& y)
{
  copy(&(y.S->rep->s[y.pos]), y.len);
}

inline SubString::SubString(SubString& x)
{ 
  S = x.S; pos = x.pos;   len = x.len; 
}

inline SubString::~SubString() {}


inline void SubString::operator = (const char* ys)
{
  assign(0, ys);
}

inline void SubString::operator = (char ch)
{
  assign(0, &ch, 1);
}

inline void SubString::operator = (String& y)
{
  assign(y.rep, y.rep->s, y.rep->len);
}

inline void SubString::operator = (SubString& y)
{
  assign(y.S->rep, &(y.S->rep->s[y.pos]), y.len);
}

inline String& String::operator+=(String& y)
{
  concat(*this, y, *this); return *this;
}

inline String& String::operator+=(SubString&  y)
{
  concat(*this, y, *this); return *this;
}

inline String& String::operator+=(const char* t)
{
  concat(*this, t, *this); return *this;
}

inline String& String::operator+=(char c)
{
  concat(*this, c, *this); return *this;
}

inline String operator + (String& x, String& y)
{
  String r; concat(x, y, r); return r;
}

inline String operator + (String& x, const char* t)
{
  String r; concat(x, t, r); return r;
}

inline String operator + (String& x, SubString& y)
{
  String r; concat(x, y, r); return r;
}

inline String operator + (String& x, char c)
{
  String r; concat(x, c, r); return r;
}

inline String operator + (SubString& x, String& y)
{
  String r; concat(x, y, r); return r;
}

inline String operator+(SubString& x, const char* y)
{
  String r; concat(x, y, r); return r;
}

inline String operator+(SubString& x, char c)
{
  String r; concat(x, c, r); return r;
}

inline String operator+(SubString& x, SubString& y)
{
  String r; concat(x, y, r); return r;
}
  
inline int String::length()
{ 
  return rep->len;
}

inline int String::empty()
{ 
  return rep->len == 0;
}

inline int String::operator ! ()
{ 
  return rep->len == 0;
}

inline char  String::operator [] (int i) 
{ 
  return rep->s[i];
}

inline int String::index(char c, int startpos = 0)
{
  return search(startpos, rep->len, c);
}

inline int String::index(const char* t, int startpos = 0)
{   
  return search(startpos, rep->len, t);
}

inline int String::index(String& y, int startpos = 0)
{   
  return search(startpos, rep->len, y.rep->s, y.rep->len);
}

inline int String::index(SubString& y, int startpos = 0)
{   
  return search(startpos, rep->len, &(y.S->rep->s[y.pos]), y.len);
}

inline int String::contains(char c)
{
  return search(0, rep->len, c) >= 0;
}

inline int SubString::contains(char c)
{
  return S->search(pos, pos+len, 0, c) >= 0;
}

inline int String::contains(const char* t)
{   
  return search(0, rep->len, t) >= 0;
}

inline int String::contains(String& y)
{   
  return search(0, rep->len, y.rep->s, y.rep->len) >= 0;
}

inline int String::contains(SubString& y)
{   
  return search(0, rep->len, &(y.S->rep->s[y.pos]), y.len) >= 0;
}

inline int SubString::contains(const char* t)
{   
  return S->search(pos, pos+len, t) >= 0;
}

inline int SubString::contains(String& y)
{   
  return S->search(pos, pos+len, y.rep->s, y.rep->len) >= 0;
}

inline int SubString::contains(SubString&  y)
{   
  return S->search(pos, pos+len, &(y.S->rep->s[y.pos]), y.len) >= 0;
}

inline int String::contains(char c, int p)
{
  char ch = c; return match(p, rep->len, 0, &ch, 1);
}

inline int String::matches(char c, int p = 0)
{
  char ch = c; return match(p, rep->len, 1, &ch, 1);
}

inline int String::contains(const char* t, int p)
{
  return match(p, rep->len, 0, t);
}

inline int String::matches(const char* t, int p = 0)
{
  return match(p, rep->len, 1, t);
}

inline int String::contains(String& y, int p)
{
  return match(p, rep->len, 0, y.rep->s, y.rep->len);
}

inline int String::matches(String& y, int p = 0)
{
  return match(p, rep->len, 1, y.rep->s, y.rep->len);
}

inline int String::contains(SubString& y, int p)
{
  return match(p, rep->len, 0, &(y.S->rep->s[y.pos]), y.len);
}

inline int String::matches(SubString& y, int p = 0)
{
  return match(p, rep->len, 1, &(y.S->rep->s[y.pos]), y.len);
}

inline int String::contains(Regex& r)
{
  int unused;
  return r.search(rep->s, rep->len, unused, 0);
}

inline int SubString::contains(Regex& r)
{
  int unused;
  return r.search(&(S->rep->s[pos]), len, unused, 0);
}

inline int String::contains(Regex& r, int p)
{
  return r.match(rep->s, rep->len, p);
}

inline int String::matches(Regex& r, int p = 0)
{
  int l = (p < 0)? -p : rep->len - p;
  return r.match(rep->s, rep->len, p) == l;
}

inline int SubString::matches(Regex& r)
{
  return r.match(&(S->rep->s[pos]), len, 0) == len;
}

inline const char* String::operator char*()
{ 
  return rep->s;
}

inline int String::index(Regex& r, int startpos = 0)
{
  int mlen;  return r.search(rep->s, rep->len, mlen, startpos);
}

inline const char* SubString::operator char*()
{ 
  return (char*)(String(*this)); 
}

inline  int SubString::length()
{ 
  return len;
}

inline  int SubString::empty()
{ 
  return len == 0;
}

inline  ostream& operator<<(ostream& s, String& x)
{ 
  s.put(x.rep->s); return s;
}

inline int operator==(String& x, String& y) 
{
  return x.rep->len == y.rep->len && compare(x, y) == 0; 
}

inline int operator!=(String& x, String& y)
{
  return x.rep->len != y.rep->len || compare(x, y) != 0; 
}

inline int operator>(String& x, String& y)
{
  return compare(x, y) > 0; 
}

inline int operator>=(String& x, String& y)
{
  return compare(x, y) >= 0; 
}

inline int operator<(String& x, String& y)
{
  return compare(x, y) < 0; 
}

inline int operator<=(String& x, String& y)
{
  return compare(x, y) <= 0; 
}

inline int operator==(String& x, SubString&  y) 
{
  return x.rep->len == y.len && compare(x, y) == 0; 
}

inline int operator!=(String& x, SubString&  y)
{
  return x.rep->len != y.len || compare(x, y) != 0; 
}

inline int operator>(String& x, SubString&  y)      
{
  return compare(x, y) > 0; 
}

inline int operator>=(String& x, SubString&  y)
{
  return compare(x, y) >= 0; 
}

inline int operator<(String& x, SubString&  y) 
{
  return compare(x, y) < 0; 
}

inline int operator<=(String& x, SubString&  y)
{
  return compare(x, y) <= 0; 
}

inline int operator==(String& x, const char* t) 
{
  return compare(x, t) == 0; 
}

inline int operator!=(String& x, const char* t) 
{
  return compare(x, t) != 0; 
}

inline int operator>(String& x, const char* t)  
{
  return compare(x, t) > 0; 
}

inline int operator>=(String& x, const char* t) 
{
  return compare(x, t) >= 0; 
}

inline int operator<(String& x, const char* t)  
{
  return compare(x, t) < 0; 
}

inline int operator<=(String& x, const char* t) 
{
  return compare(x, t) <= 0; 
}

inline int operator==(SubString& x, String& y) 
{
  return x.len == y.rep->len && compare(y, x) == 0; 
}

inline int operator!=(SubString& x, String& y)
{
  return x.len != y.rep->len || compare(y, x) != 0;
}

inline int operator>(SubString& x, String& y)      
{
  return compare(y, x) < 0;
}

inline int operator>=(SubString& x, String& y)     
{
  return compare(y, x) <= 0;
}

inline int operator<(SubString& x, String& y)      
{
  return compare(y, x) > 0;
}

inline int operator<=(SubString& x, String& y)     
{
  return compare(y, x) >= 0;
}

inline int operator==(SubString& x, SubString&  y) 
{
  return x.len == y.len && compare(x, y) == 0; 
}

inline int operator!=(SubString& x, SubString&  y)
{
  return x.len != y.len || compare(x, y) != 0;
}

inline int operator>(SubString& x, SubString&  y)      
{
  return compare(x, y) > 0;
}

inline int operator>=(SubString& x, SubString&  y)
{
  return compare(x, y) >= 0;
}

inline int operator<(SubString& x, SubString&  y) 
{
  return compare(x, y) < 0;
}

inline int operator<=(SubString& x, SubString&  y)
{
  return compare(x, y) <= 0;
}

inline int operator==(SubString& x, const char* t) 
{
  return compare(x, t) == 0; 
}

inline int operator!=(SubString& x, const char* t) 
{
  return compare(x, t) != 0;
}

inline int operator>(SubString& x, const char* t)  
{
  return compare(x, t) > 0; 
}

inline int operator>=(SubString& x, const char* t) 
{
  return compare(x, t) >= 0; 
}

inline int operator<(SubString& x, const char* t)  
{
  return compare(x, t) < 0; 
}

inline int operator<=(SubString& x, const char* t) 
{
  return compare(x, t) <= 0; 
}

inline void String::make_unique()
{
  if (rep->ref != 1) setlength(rep->len);
}

 


# 5 "/united1/users/others/andreas/include/System.h"


# 1 "/united1/users/others/andreas/include/Error.h"



void myerror(int, char* =0, char* =0, char* =0 );


# 7 "/united1/users/others/andreas/include/System.h"

# 1 "/united1/users/others/andreas/include/ClassSet.h"



# 1 "/usr/tools/lib/g++-include/String.h"
 
 






















# 928 "/usr/tools/lib/g++-include/String.h"

# 4 "/united1/users/others/andreas/include/ClassSet.h"

# 1 "/united1/users/others/andreas/include/Error.h"






# 5 "/united1/users/others/andreas/include/ClassSet.h"

# 1 "/united1/users/others/andreas/include/Set.h"



# 1 "/united1/users/others/andreas/include/Collec.h"



# 1 "/usr/tools/lib/g++-include/String.h"
 
 






















# 928 "/usr/tools/lib/g++-include/String.h"

# 4 "/united1/users/others/andreas/include/Collec.h"


extern class Object;

class Collec {

   friend class iterator;
   friend class Set;

   Object** first_;
   Object** last_;
   int array_size_;
   int base_size_;

   void enlarge( int );
   void reduce();

public:

   void add( Object* e )
   {
      if (e) {
         if ( size() >= array_size_ ) enlarge( array_size_ );
         *last_++ = e;
      }
   } 

   void add( Collec& );
   void  remove( Object* );
   void  remove_all( Object* );
   Object* find( Object* );

   int contains( Object* o ) { 
       return find(o) ? 1 : 0;  
   }
   
   int size()
   { 
      return last_ - first_;
   }

   int empty()
   {  
      return last_-first_ == 0; 
   }

   void clear()
   {
      last_ = first_;
   }

   friend ostream& operator<<( ostream&, Collec& );

   Collec& operator=( Collec& );

   Object* operator[]( int i )
   {
      if (i > size()) return 0;
      else return first_[ i-1 ];
   }

   Collec()
   {
      base_size_ = 16;
      array_size_ = base_size_;
      first_ = new Object*[array_size_];
      last_ = first_;
   }

   Collec( int b )
   {
      base_size_ = b;
      array_size_ = base_size_;
      first_ = new Object*[array_size_];
      last_ = first_;
   }
   Collec( Collec& );

   ~Collec()
   {
      delete( first_ );
   }

   virtual void printOn( ostream& strm );
};

class iterator {
   int index;
   Collec* coll;
public:

   Object* operator++()
   {  
      Object* ret;
      Object** current;
      if (index < 0) ret = 0;
      else {
         current = coll->first_ + index++;
         if (current < coll->last_ && current >= coll->first_) 
            ret = *current;
         else { 
           index = -1;
           ret = 0;
         } 
      } 
      return ret;
   } 
   
   Object* operator()()
   {  
      Object* ret;
      Object** current;
      if (index < 0) ret = 0;
      else {
         current = coll->first_ + index++;
         if (current < coll->last_ && current >= coll->first_) 
            ret = *current;
         else { 
           index = -1;
           ret = 0;
         } 
      } 
      return ret;
   } 
   
   Object* operator--()
   {  
      Object* ret;
      Object** current;
      if (index < 0) ret = 0;
      else {
         if (index==0) index = coll->size()+1;
         current = coll->first_ -1 + --index;
         if (current >= coll->first_ && current < coll->last_ ) 
            ret = *current;
         else {
           index = -1;
           ret = 0;
         }
      }
      return ret;
   } 
   
   void reset()
   {
      index = 0;
   }
   
   iterator( iterator& i )
   {
      coll = i.coll;
      index = i.index;
   }
   
   iterator( Collec& c )
   {
      coll = &c;
      index = 0;
   }
   
   iterator& operator=( iterator& i )
   {
      coll = i.coll;
      index = i.index;
      return *this;
   }
};


# 4 "/united1/users/others/andreas/include/Set.h"


class Set : public Collec {
public:

   void add( Object* e ) 
   {
      if ( !find(e) ) Collec::add(e);
   }

   void add( Collec& );

   Object* filter( Object* o ); 
     
   Set() : () {}
   Set( int i ) : (i) {}
   Set( Collec& );
   Set( Set& s ) : (s) {}
   ~Set() {}
};


# 6 "/united1/users/others/andreas/include/ClassSet.h"

# 1 "/united1/users/others/andreas/include/Object.h"



# 1 "/usr/tools/lib/g++-include/String.h"
 
 






















# 928 "/usr/tools/lib/g++-include/String.h"

# 4 "/united1/users/others/andreas/include/Object.h"

# 1 "/united1/users/others/andreas/include/MyFile.h"



# 1 "/usr/tools/lib/g++-include/stream.h"
 
 





















# 245 "/usr/tools/lib/g++-include/stream.h"

# 4 "/united1/users/others/andreas/include/MyFile.h"

# 1 "/usr/tools/lib/g++-include/String.h"
 
 






















# 928 "/usr/tools/lib/g++-include/String.h"

# 5 "/united1/users/others/andreas/include/MyFile.h"


class InputFile : public istream {
public:
   void readln();
   void getString( String&, int ); 
}; 

class OutputFile : public ostream {
public:
};


# 5 "/united1/users/others/andreas/include/Object.h"

# 1 "/united1/users/others/andreas/include/Class.h"



# 1 "/usr/tools/lib/g++-include/String.h"
 
 






















# 928 "/usr/tools/lib/g++-include/String.h"

# 4 "/united1/users/others/andreas/include/Class.h"

# 1 "/united1/users/others/andreas/include/MyFile.h"
# 17 "/united1/users/others/andreas/include/MyFile.h"

# 5 "/united1/users/others/andreas/include/Class.h"


class Class {   
   friend class Object;
   String cls;
   Class* super; 
public:
   Class( char* s, Class& c ) { cls = s; super = &c; }
   Class( char* s ) { cls = s; super = 0; }
   Class( String& s, Class& c ) { cls = s; super = &c; }
   Class( String& s ) { cls = s; super = 0; }
};

# 6 "/united1/users/others/andreas/include/Object.h"


extern Class ObjectClass;

class Object {   
   Class* cls;
public:
   int isMemberOf( Class& c ) { return &c == cls; }
   int isMemberOf( Class* c ) { return c == cls; }
   String className() { return cls->cls; } 
   Class* classObject() { return cls; }
   int isKindOf( Class& c );
   void set_class( Class* c ) { cls = c; } 
   void set_class( Class& c ) { cls = &c; } 
   Object() { cls = &ObjectClass; }

   virtual int isEqual( Object* o ) { return this == o; } 

   virtual void printOn( ostream& strm ) {
      strm << cls->cls << "::" << hex((int)this);
   }

   friend ostream& operator<<( ostream&, Object& ); 
};

# 7 "/united1/users/others/andreas/include/ClassSet.h"


class ClassSet : public Set {
public:
   Object* get( Class& c);
}; 


# 8 "/united1/users/others/andreas/include/System.h"

# 1 "/united1/users/others/andreas/include/BusSec.h"



# 1 "/united1/users/others/andreas/include/Physical.h"



# 1 "/united1/users/others/andreas/include/Element.h"



# 1 "/united1/users/others/andreas/include/Object.h"
# 30 "/united1/users/others/andreas/include/Object.h"

# 4 "/united1/users/others/andreas/include/Element.h"

# 1 "/united1/users/others/andreas/include/ClassSet.h"
# 14 "/united1/users/others/andreas/include/ClassSet.h"

# 5 "/united1/users/others/andreas/include/Element.h"


extern Class ElementClass;

class Element : public Object {   
public:
   ClassSet groups;

   Element() { set_class(&ElementClass); }
   virtual void printFull( ostream& ); 

};

# 4 "/united1/users/others/andreas/include/Physical.h"


extern Class PhysicalClass;

class Physical : public Element {   
   String id;
public:

   Physical( String& s ); 

   int isEqual( Object* o ); 

   String name() { return id; };

   void printOn( ostream& strm ) 
   { strm << className() << "::" << id; };

   void printFull( ostream& );
};

# 4 "/united1/users/others/andreas/include/BusSec.h"

# 1 "/united1/users/others/andreas/include/Matrix.h"



# 1 "/usr/tools/lib/g++-include/stream.h"
 
 





















# 245 "/usr/tools/lib/g++-include/stream.h"

# 4 "/united1/users/others/andreas/include/Matrix.h"

# 1 "/usr/tools/lib/g++-include/math.h"
 
 






















# 183 "/usr/tools/lib/g++-include/math.h"

# 5 "/united1/users/others/andreas/include/Matrix.h"


class Matrix {
   int row;
   int col;
   double** mat;
public:
   Matrix( int, int );
   Matrix( Matrix& );
   ~Matrix();
 
   double& operator()( int, int ); 
   void operator=( double );
   void operator=( Matrix& );
   void operator+=( Matrix& );
   void operator-=( Matrix& );

   double infNorm();
   friend Matrix operator+( Matrix&, Matrix& );
   friend Matrix operator-( Matrix&, Matrix& );
   friend Matrix operator*( Matrix&, Matrix& );
   friend Matrix operator*( double, Matrix& );
   friend Matrix inverse( Matrix& );
   friend Matrix transpose( Matrix& );

   void addprod( Matrix&, Matrix& );
   void addprod( double, Matrix& );
   void subprod( Matrix&, Matrix& );
   void subprod( double, Matrix& );
   void inverse();

   friend ostream& operator<<( ostream&, Matrix& );
   friend istream& operator>>( istream&, Matrix& );
};


# 5 "/united1/users/others/andreas/include/BusSec.h"


extern Class BusSecClass;

class BusSec : public Physical {   
   int typ;
public:
   ClassSet conn;
   Matrix x;

   BusSec( String& s );

   int type() { return typ; };

   void readIEEE( InputFile& ); 
   void printFull( ostream& ); 
};

# 9 "/united1/users/others/andreas/include/System.h"


class System : public ClassSet {
   BusSec* refBus;
public:
   int loadflowtype;
   double maxerror;
   double loadmultiplier;
   double capmultiplier;
   double impmultiplier;
   double volterror;
   double flowerror;
   double injerror;
   double voltacc;
   double flowacc;
   double injacc;
   double maxiter;
   int size;

   System();

   double subVolt;
   double basePower;
   double baseVolt;
   double baseAdm(); 
   double SubstVolt();

   void makeTopology();
   void loadflow();
   void loadflowTimer();
   void createMeasurements();
   void makeMeasurementTopology();
   void estimate();
   void printLoadflowResults( ostream& );
   void printEstimationResults( ostream& );
   void readIEEE( InputFile& );
   void readSimple( InputFile& );
   void readParameters( InputFile& );
   void printFull( ostream& );
   void makeTopology1();
   void initState1();
   void loadflow1();
   void printLoadflowResults1( ostream& );
}; 

extern System SYSTEM;

# 1 "System.c"


# 1 "/united1/users/others/andreas/include/Line.h"



# 1 "/united1/users/others/andreas/include/Branch.h"



# 1 "/united1/users/others/andreas/include/ImpEle.h"



# 1 "/united1/users/others/andreas/include/Physical.h"
# 23 "/united1/users/others/andreas/include/Physical.h"

# 4 "/united1/users/others/andreas/include/ImpEle.h"

# 1 "/united1/users/others/andreas/include/BusSec.h"
# 22 "/united1/users/others/andreas/include/BusSec.h"

# 5 "/united1/users/others/andreas/include/ImpEle.h"


extern Class ImpEleClass;

class ImpEle : public Physical {   
public:
   ImpEle( String& s );

   virtual BusSec* otherBus( BusSec* ) { return 0; };
   void printFull( ostream& );
};

# 4 "/united1/users/others/andreas/include/Branch.h"


extern Class BranchClass;

class Branch : public ImpEle {   
   BusSec* bus1;
   BusSec* bus2;
public:
   Branch( String&, BusSec*, BusSec* );

   virtual BusSec* otherBus( BusSec* ); 
   void printFull( ostream& );
};

# 4 "/united1/users/others/andreas/include/Line.h"

# 1 "/united1/users/others/andreas/include/Matrix.h"
# 40 "/united1/users/others/andreas/include/Matrix.h"

# 5 "/united1/users/others/andreas/include/Line.h"


extern Class LineClass;

class Line : public Branch {   
public:
   double rPu;
   double xPu;
   Line( String&, BusSec*, BusSec* );
   
   double otherVoltage( double, Matrix& );
   double newVoltage( double, double, Matrix& );
   Matrix losses( double, Matrix& );

   void readIEEE( InputFile& );
   void readSimple( InputFile& );
   void printFull( ostream& ); 
};

# 3 "System.c"

# 1 "/united1/users/others/andreas/include/PQLoad.h"



# 1 "/united1/users/others/andreas/include/Shunt.h"



# 1 "/united1/users/others/andreas/include/ImpEle.h"
# 16 "/united1/users/others/andreas/include/ImpEle.h"

# 4 "/united1/users/others/andreas/include/Shunt.h"

# 1 "/united1/users/others/andreas/include/Matrix.h"
# 40 "/united1/users/others/andreas/include/Matrix.h"

# 5 "/united1/users/others/andreas/include/Shunt.h"

# 1 "/united1/users/others/andreas/include/Error.h"






# 6 "/united1/users/others/andreas/include/Shunt.h"


extern Class ShuntClass;

class Shunt : public ImpEle {   
public:
   BusSec* bus;
   Shunt( String&, BusSec* );

   virtual Matrix flow( double ) { 
      myerror(1,"Flow must be imp. by subclass"); 
      Matrix m(1,1);
      return m;
   }
   virtual BusSec* otherBus( BusSec* ) { return 0; };
   void printFull( ostream& );
};

# 4 "/united1/users/others/andreas/include/PQLoad.h"

# 1 "/united1/users/others/andreas/include/Matrix.h"
# 40 "/united1/users/others/andreas/include/Matrix.h"

# 5 "/united1/users/others/andreas/include/PQLoad.h"


extern Class PQLoadClass;

class PQLoad : public Shunt {   
   double p;
   double q;
public:
   PQLoad( String&, BusSec*, double, double );
  
   Matrix flow( double );
   double P() { return p; }
   double Q() { return q; } 
   void printFull( ostream& ); 
};

# 4 "System.c"

# 1 "/united1/users/others/andreas/include/Cap.h"



# 1 "/united1/users/others/andreas/include/Shunt.h"
# 23 "/united1/users/others/andreas/include/Shunt.h"

# 4 "/united1/users/others/andreas/include/Cap.h"

# 1 "/united1/users/others/andreas/include/Matrix.h"
# 40 "/united1/users/others/andreas/include/Matrix.h"

# 5 "/united1/users/others/andreas/include/Cap.h"


extern Class CapClass;

class Cap : public Shunt {   
   double yPu;
public:
   Cap( String&, BusSec* );
  
   Matrix flow( double );
   Matrix voltageSensitivity( double );
   void readSimple( istream& );
   void printFull( ostream& ); 
};

# 5 "System.c"

# 1 "/united1/users/others/andreas/include/LfNode.h"



# 1 "/united1/users/others/andreas/include/Matrix.h"
# 40 "/united1/users/others/andreas/include/Matrix.h"

# 4 "/united1/users/others/andreas/include/LfNode.h"

# 1 "/united1/users/others/andreas/include/Node.h"



# 1 "/united1/users/others/andreas/include/Conceptual.h"



# 1 "/united1/users/others/andreas/include/Element.h"
# 17 "/united1/users/others/andreas/include/Element.h"

# 4 "/united1/users/others/andreas/include/Conceptual.h"

# 1 "/united1/users/others/andreas/include/ClassSet.h"
# 14 "/united1/users/others/andreas/include/ClassSet.h"

# 5 "/united1/users/others/andreas/include/Conceptual.h"


extern Class ConceptualClass;

class Conceptual : public Element {   
public:
   ClassSet elements;

   Conceptual( Element* ); 
   void printFull( ostream& );
};

# 4 "/united1/users/others/andreas/include/Node.h"


extern Class NodeClass;

class Node : public Conceptual {   
public:

   Node( Element* ); 
   void printFull( ostream& );
};

# 5 "/united1/users/others/andreas/include/LfNode.h"

# 1 "/united1/users/others/andreas/include/Line.h"
# 23 "/united1/users/others/andreas/include/Line.h"

# 6 "/united1/users/others/andreas/include/LfNode.h"

# 1 "/united1/users/others/andreas/include/Cap.h"
# 19 "/united1/users/others/andreas/include/Cap.h"

# 7 "/united1/users/others/andreas/include/LfNode.h"

# 1 "/united1/users/others/andreas/include/TopSet.h"



# 1 "/united1/users/others/andreas/include/Collec.h"
# 172 "/united1/users/others/andreas/include/Collec.h"

# 4 "/united1/users/others/andreas/include/TopSet.h"


class TopSet : public Collec {
public:
};


# 8 "/united1/users/others/andreas/include/LfNode.h"

# 1 "/united1/users/others/andreas/include/PQLoad.h"
# 20 "/united1/users/others/andreas/include/PQLoad.h"

# 9 "/united1/users/others/andreas/include/LfNode.h"


extern Class LfNodeClass;

class LfNode : public Node {   
   Matrix s;
   Matrix ds;
   double u;
   Line* line;
   PQLoad* load;
   Cap* cap;
   TopSet children;
   LfNode* parent;
   double err;
public:
   LfNode( Element* ); 
   void initVoltage( double v ) { u = v*v; } 
   void makeTopology(); 
   double lfStep();
   void lfstep();
   void updateError( double );
   void resetState();
   void makeMes();
   void printLf( ostream& );
   void printStateK( ostream& );
   void printState( ostream& );
   void printFull( ostream& );
   void printOn( ostream& );
   double P();
   double Q();
   double Pinj();
   double Qinj();
   double I();
   double J();
   double Iinj();
   double Jinj();
   double V(); 
};

# 6 "System.c"

# 1 "/united1/users/others/andreas/include/Lf1Node.h"



# 1 "/united1/users/others/andreas/include/Matrix.h"
# 40 "/united1/users/others/andreas/include/Matrix.h"

# 4 "/united1/users/others/andreas/include/Lf1Node.h"

# 1 "/united1/users/others/andreas/include/Node.h"
# 14 "/united1/users/others/andreas/include/Node.h"

# 5 "/united1/users/others/andreas/include/Lf1Node.h"

# 1 "/united1/users/others/andreas/include/Line.h"
# 23 "/united1/users/others/andreas/include/Line.h"

# 6 "/united1/users/others/andreas/include/Lf1Node.h"

# 1 "/united1/users/others/andreas/include/Cap.h"
# 19 "/united1/users/others/andreas/include/Cap.h"

# 7 "/united1/users/others/andreas/include/Lf1Node.h"

# 1 "/united1/users/others/andreas/include/TopSet.h"
# 10 "/united1/users/others/andreas/include/TopSet.h"

# 8 "/united1/users/others/andreas/include/Lf1Node.h"

# 1 "/united1/users/others/andreas/include/PQLoad.h"
# 20 "/united1/users/others/andreas/include/PQLoad.h"

# 9 "/united1/users/others/andreas/include/Lf1Node.h"


extern Class Lf1NodeClass;

class Lf1Node : public Node {   
   Matrix s;
   Matrix ds;
   double u;
   double du;
   Matrix jd;
   Matrix ju;
   Line* line;
   PQLoad* load;
   Cap* cap;
   TopSet children;
   Lf1Node* parent;
public:
   Lf1Node( Element* ); 
   void initVoltage( double v ) { u = v*v; } 
   void makeTopology(); 
   void initState();
   void initJacobianLocal();
   double uerr();
   Matrix serr();
   void forwardStepLocal(); 
   void forwardStep(); 
   void backwardStepLocal(); 
   void backwardStep(); 
   double lfstep();
   void printLf( ostream& );
   void printStateK( ostream& );
   void printState( ostream& );
   void printFull( ostream& );
   void printOn( ostream& );
};

# 7 "System.c"

# 1 "/united1/users/others/andreas/include/EstNode.h"



# 1 "/united1/users/others/andreas/include/Matrix.h"
# 40 "/united1/users/others/andreas/include/Matrix.h"

# 4 "/united1/users/others/andreas/include/EstNode.h"

# 1 "/united1/users/others/andreas/include/Node.h"
# 14 "/united1/users/others/andreas/include/Node.h"

# 5 "/united1/users/others/andreas/include/EstNode.h"

# 1 "/united1/users/others/andreas/include/Line.h"
# 23 "/united1/users/others/andreas/include/Line.h"

# 6 "/united1/users/others/andreas/include/EstNode.h"

# 1 "/united1/users/others/andreas/include/TopSet.h"
# 10 "/united1/users/others/andreas/include/TopSet.h"

# 7 "/united1/users/others/andreas/include/EstNode.h"

# 1 "/united1/users/others/andreas/include/Measure.h"



# 1 "/united1/users/others/andreas/include/Physical.h"
# 23 "/united1/users/others/andreas/include/Physical.h"

# 4 "/united1/users/others/andreas/include/Measure.h"

# 1 "/united1/users/others/andreas/include/BusSec.h"
# 22 "/united1/users/others/andreas/include/BusSec.h"

# 5 "/united1/users/others/andreas/include/Measure.h"


extern Class MeasureClass;

class Measure : public Physical {   
   double v;
   double vacc;
   double pacc;
   double p;
   double q;
   double pinj; 
   double qinj; 
public:
   BusSec* bus;

   Measure( String&, BusSec* );
   double wu(); 
   double ws(); 
   double wsinj(); 
   double wflow();
   double winj();
   double wv();
   double V();
   double U();
   double P() { return p; }
   double Pinj() { return pinj; }
   double Q() { return q; }
   double Qinj() { return qinj; }
   double I();
   double Iinj();
   double J();
   double Jinj();
   void update( double, double, double, double, double );
   void readSimple( istream& );
   void printFull( ostream& );
   void printState( ostream& );
};

# 8 "/united1/users/others/andreas/include/EstNode.h"

# 1 "/united1/users/others/andreas/include/LfNode.h"
# 47 "/united1/users/others/andreas/include/LfNode.h"

# 9 "/united1/users/others/andreas/include/EstNode.h"


extern Class EstNodeClass;


class EstNode : public Node {   
   friend class EstBranch;

   Matrix x;
   Matrix dx;
   Matrix err;
   Matrix grad;

   Matrix ms;
   Matrix msinj;
   double mu;

   Matrix d;
   Matrix l;

   Matrix dtemp;
   Matrix ltemp;
   Matrix errtemp;

   Line* line;
   Measure* measure;
   TopSet branches;
   TopSet children;
   EstNode* parent;

   static double maxerr;
   static int numNodes;

public:
   static double totalerror; 
   static double merrit; 

   EstNode( Element* ); 

   void initVoltage( double v ) { x(3,1) = v*v; } 
   void updateError( double ); 
   void updateMerrit(); 

   EstBranch* branchTo( EstNode* );
   void makeTopology(); 
   void makeBranches();

   void updateGain();
   void factorGain();
   void backwardSubst();
   void forwardSubst();

   void measErr();
   void Error();

   void updateX();

   void initState();
   double estStep();
   void eststep();
   void eststep1();
   void eststep2();
   void eststep3();
   void eststep4();
   void eststep5();

   void printRes( ostream& );
   void printResults( ostream& );
   void printState( ostream& );
   void printFull( ostream& );
   void printOn( ostream& );
   LfNode* lfnode();
   void check();

   double z2();
   double u2();
   double s2();
   double rPu();
   double xPu();
   double pp();
   double pq();
   double pu();
   double qp();
   double qq();
   double qu();
   double cp();
   double cq();
   double cu();
   double V();
   double P();
   double Q();
   double Pinj();
   double Qinj();
};

# 8 "System.c"

# 1 "/united1/users/others/andreas/include/Measure.h"
# 42 "/united1/users/others/andreas/include/Measure.h"

# 9 "System.c"


System SYSTEM;

System::System() {
   maxerror = 0.001;
   maxiter = 10;
   loadmultiplier = 1.0;
   capmultiplier = 1.0;
   impmultiplier = 1.0;
   volterror = 1.0;
   injerror = 1.0;
   flowerror = 1.0;
   voltacc = 1.0;
   injacc = 1.0;
   flowacc = 1.0;
   loadflowtype = 0;
}

void System::readParameters( InputFile& strm ) {
   strm >> loadflowtype;
   strm.readln();
   strm >> loadmultiplier;
   strm.readln();
   strm >> impmultiplier;
   strm.readln();
   strm >> capmultiplier;
   strm.readln();
   strm >> volterror;
   strm. readln();
   strm >> flowerror;
   strm. readln();
   strm >> injerror;
   strm. readln();
   strm >> voltacc;
   strm. readln();
   strm >> flowacc;
   strm. readln();
   strm >> injacc;
   strm. readln();
   strm >> maxerror;
   strm.readln();
   strm >> maxiter;
}

void System::readSimple( InputFile& strm ) {
   BusSec *b1,*b2;
   String s,s1,s2;
   double p,q;

   strm.readln();
   strm.readln();

   strm >> subVolt;
   subVolt *= 1000.0;
   strm >> basePower;
   basePower *= 1000.0;
   strm >> baseVolt;
   baseVolt *= 1000.0;
   subVolt = subVolt / baseVolt;
   strm.readln();
 
   strm.readln();
   strm.readln();

   cerr << "Starting to read the Buses\n";

   strm >> s1;
   b1 = new BusSec( s1 );
   cerr << "First Bus is the Reference Bus " << *b1 << "\n";
   add(b1);
   refBus = b1;
   Line* l;
   PQLoad* pq;
   while ( s1 != "-999" ) {
      b1 = new BusSec( s1 );
      b1 = (BusSec*) filter( b1 );
      strm >> s2;
      b2 = new BusSec( s2 );
      add(b2); 
      s = s1;
      s += "-";
      s += s2;
      l = new Line( s, b1, b2 );
      l->readSimple( strm );
      strm >> p;
      strm >> q;
      pq = new PQLoad( s2, b2, p, q ); 
      strm >> s1;
   } 
   strm.readln();
   strm.readln();
   cerr << "Starting to read the Capacitors\n";
   strm >> s1;
   cerr << "First Capacitor is " << s1 << "\n"; 
   Cap* c;
   while ( s1 != "-999" ) {
      b1 = new BusSec( s1 );
      b1 = (BusSec*) filter( b1 );
      c = new Cap( s1, b1 );
      c->readSimple( strm );
      strm >> s1;
   }
   strm.readln();
   strm.readln();
   cerr << "Starting to read the Measurements\n";
   strm >> s1;
   cerr << "First Measurement is " << s1 << "\n";
   Measure* m;
   while ( s1 != "-999" ) {
      b1 = new BusSec( s1 );
      b1 = (BusSec*) filter( b1 );
      m = new Measure( s1, b1 );
      m->readSimple( strm );
      strm >> s1;
   }
}

void System::readIEEE( InputFile& strm ) {
   BusSec *b,*b1,*b2;
   String s1,s2,s;
   char buf[80];
   basePower = 100.0;
   strm.readln();
   strm.readln();

   strm >> s;
   while ( s != "-999" ) {
      b = new BusSec( s );
      b->readIEEE( strm );
      add(b);
      strm >> s;
      if (b->type() == 3) refBus = b;
      baseVolt = b->x(2,1);
   }
   strm.readln();
   strm.readln();
   strm >> s1;
   while ( s1 != "-999" ) {
      b1 = new BusSec( s1 );
      b1 = (BusSec*) filter(b1);
      strm >> s2;
      b2 = new BusSec( s2 );
      b2 = (BusSec*) filter(b2);
      s = s1;
      s += "=";
      s += s2;
      Line* l;
      l = new Line( s, b1, b2 );
      l->readIEEE( strm );
      strm >> s1;
   } 
}

void System::makeTopology1() {
   Lf1Node* l;
   l = new Lf1Node (refBus);
   l->makeTopology();
}

void System::makeTopology() {
   LfNode* l;
   l = new LfNode (refBus);
   l->makeTopology();
}

void System::makeMeasurementTopology() {
   EstNode* e;
   e = new EstNode (refBus);
   e->makeTopology();
}

void System::loadflow() {
   LfNode* l;
   double err;
   double maxerr = maxerror;
   l = (LfNode*) refBus->groups.get( LfNodeClass );
   for (int i=1; i<=10; i++) {
      l->initVoltage( SubstVolt() );
      err = l->lfStep(); 
      cerr << "   Iteration " << i << ":  Error = " << err;
      cerr << "    log(err)  = " << log(err) << "\n";
      if (err < maxerr) {
         cerr << "Loadflow converged in " << i << " Iterations\n";
         return;
      }
   } 
   cerr << "Loadflow did not converge in " << i-1 << " Iterations\n";
}
   
void System::loadflow1() {
   Lf1Node* l;
   double err;
   double maxerr = maxerror;
   l = (Lf1Node*) refBus->groups.get( Lf1NodeClass );
   l->initVoltage( SubstVolt() );
   l->initState();
   for (int i=1; i<=10; i++) {
      err = l->lfstep(); 
      cerr << "   Iteration " << i << ":  Error = " << err;
      cerr << "    log(err)  = " << log(err) << "\n";
      if (err < maxerr) {
         cerr << "Loadflow converged in " << i << " Iterations\n";
         return;
      }
   } 
   cerr << "Loadflow did not converge in " << i-1 << " Iterations\n";
}
   
void System::estimate() {
   EstNode* slack;
   double err;
   double maxerr = maxerror;
   slack = (EstNode*) refBus->groups.get( EstNodeClass );
   slack->initVoltage( SubstVolt() );
   slack->initState();
 
   for (int i=1; i<=maxiter; i++) {
      cerr << "   Starting the " << i << "th iteration\n";
      err = slack->estStep(); 
      cerr << "   Iteration " << i;
      cerr << ":  Error = " << err;
      cerr << "   log(err) = " << log(err) << "\n";
      cerr << "   Total Residuals = " << EstNode::totalerror << "\n";
      cerr << "   Merrit Function = " << EstNode::merrit << "\n";
      if (err < maxerr) {
         cerr << "Estimator converged in " << i << " Iterations\n";
         return;
      }
   } 
   cerr << "Estimator did not converge in " << i-1 << " Iterations\n";
}
   
void System::loadflowTimer() {
   LfNode* l;
   double err;
   double maxerr = 0.001;
   int maxiter = 10;
   l = (LfNode*) refBus->groups.get( LfNodeClass );
   int i;
   for (int j=1; j<=100; j++) {
      l->resetState();
      for (i=1; i<=maxiter; i++) {
         l->initVoltage( SubstVolt() );
         err = l->lfStep(); 
         if (err < maxerr) {
            break;
         }
      } 
   }
   cerr << j-1 << " Loadflows with " << i-1 << " Iterations\n";
}
   
void System::initState1() {
   Lf1Node* l;
   l = (Lf1Node*) refBus->groups.get( Lf1NodeClass );
   l->initVoltage( SubstVolt() );
   l->initState();
}

void System::printLoadflowResults1( ostream& o ) {
   Lf1Node* l;
   l = (Lf1Node*) refBus->groups.get( Lf1NodeClass );
   l->printLf( o );
}

void System::printLoadflowResults( ostream& o ) {
   LfNode* l;
   l = (LfNode*) refBus->groups.get( LfNodeClass );
   l->printLf( o );
}

void System::printEstimationResults( ostream& o ) {
   EstNode* l;
   l = (EstNode*) refBus->groups.get( EstNodeClass );
   l->printResults( o );
}

void System::createMeasurements() {
   LfNode* l;
   l = (LfNode*) refBus->groups.get( LfNodeClass );
   l->makeMes();
}
   
void System::printFull( ostream& o ) {
   o << "Global Object System:\n";
   o << "   refBus = " << *refBus << "\n";
   o << "   subVolt = " << subVolt << "\n";
   o << "   basePower = " << basePower << "\n";
   o << "   baseVolt = " << baseVolt << "\n";
}


double System::baseAdm() {
   return basePower / ( baseVolt * baseVolt );
}

double System::SubstVolt() {
   return subVolt;
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads