# To unbundle, sh this file
echo Attic.hxx 1>&2
cat >Attic.hxx <<'End of Attic.hxx'
#ifndef ATTIC_HXX
#define ATTIC_HXX

class Junk {
 public:
  Junk() {}
  virtual ~Junk() {}
};


class Attic {
 private:
  int count;
  int max;
  int halfMax;
  int upper;
  Junk** stuff;
 public:
  Attic( int m );
  ~Attic();
  void store( Junk* );
};

#endif  ATTIC_HXX
End of Attic.hxx
echo dlist.hxx 1>&2
cat >dlist.hxx <<'End of dlist.hxx'
/*************************************************************************
**************************************************************************
**************************************************************************
******                                                                ****
******  DLIST: Doubly linked lists. Based on slist, found in          ****
******         Stroustrup's C++ Programming Language                  ****
******                                                                ****
******  Copyright (c) 1990  Universities Research Association, Inc.   ****
******                All Rights Reserved                             ****
******                                                                ****
******  Author:    Leo Michelotti                                     ****
******                                                                ****
******             Fermilab                                           ****
******             P.O.Box 500                                        ****
******             Mail Stop 345                                      ****
******             Batavia, IL   60510                                ****
******                                                                ****
******             Phone: (708) 840 4956                              ****
******             Email: MICHELOTTI@FNALAD                           ****
******                    MICHELOTTI@ADCALC.FNAL.GOV                  ****
******                    ALMOND::MICHELOTTI                          ****
******                                                                ****
******  Release    Version 1.0 : May 20, 1990                         ****
******  Dates:                                                        ****
**************************************************************************
**************************************************************************
******                                                                ****
******  This material resulted from work developed under a            ****
******  Government Contract and is subject to the following           ****
******  license: The Government retains a paid-up, nonexclusive,      ****
******  irrevocable worldwide license to reproduce, prepare           ****
******  derivative works, perform publicly and display publicly       ****
******  by or for the Government, including the right to distribute   ****
******  to other Government contractors.  Neither the United          ****
******  States nor the United States Department of Energy, nor        ****
******  any of their employees, makes any warranty, express or        ****
******  implied, or assumes any legal liability or responsibility     ****
******  for the accuracy, completeness or usefulness of any           ****
******  information, apparatus, product, or process disclosed, or     ****
******  represents that its use would not infringe privately owned    ****
******  rights.                                                       ****
******                                                                ****
******  These files are made avaliable for use by specific            ****
******  individuals or a specific group.  They are not to be          ****
******  reproduced or redistributed.                                  ****
******                                                                ****
******  These files are provided "as is" with no warranties of any    ****
******  kind including the warranties of design,                      ****
******  merchantibility and fitness for a particular purpose,         ****
******  or arising from a course of dealing, usage or trade           ****
******  practice.                                                     ****
******                                                                ****
******  These files are provided with no support or obligation on     ****
******  the part of U.R.A. or Fermilab to assist in their use,        ****
******  correction, modification or enhancement.                      ****
******                                                                ****
******  Neither U.R.A. nor Fermilab shall be liable with              ****
******  respect to the infringement of copyrights, trade              ****
******  secrets or any patents by these files or any part             ****
******  thereof.                                                      ****
******                                                                ****
******  In no event will U.R.A., Fermilab, or the author(s) be        ****
******  liable for any lost revenue or profits or other               ****
******  special, indirect and consequential damages, even if          ****
******  they have been advised of the possibility of such             ****
******  damages.                                                      ****
******                                                                ****
**************************************************************************
*************************************************************************/

#ifndef DLIST_HXX
#define DLIST_HXX

typedef void* ent;

class dlink {
friend class dlist;
friend class dlist_iterator;
friend class dlist_traversor;
friend class dlist_looper;
friend class dlist_reverseIterator;
  dlink* next;
  dlink* prev;
  ent e;
public:
  dlink( ent a, dlink* p, dlink* q ) { e=a; prev=p; next=q; }
  void putAbove( dlink* );
  void putBelow( dlink* );
  dlink* nextPtr() {return next;}
  dlink* prevPtr() {return prev;}
  ent info() {return e;}
/*
 *   Pool functions written by Michael Allen
 *   February, 1993
 */
#ifdef POOLED
  inline void* operator new(size_t);
  inline void operator delete(void*, size_t);
#endif  POOLED
} ;


/*
 *   Pool functions written by Michael Allen
 *   February, 1993
 */
#ifdef POOLED
class _dlink_Shell
{
friend class _dlink_Pool;

 private:
 
  union
  {
    _dlink_Shell* next;
    char  dummy[sizeof(dlink)];
  };
};

#define _dlink_BLOCK_COUNT 1024

class _dlink_Pool
{
friend class dlink;
  
 private:
  _dlink_Pool();
  
  inline static void* alloc();
  inline static void free(void*);
  
  _dlink_Shell slot[_dlink_BLOCK_COUNT];
  static _dlink_Shell* top;
  static int num_made;
};

inline void*
dlink::operator new(size_t)
{
  return _dlink_Pool::alloc();
}

inline void
dlink::operator delete(void* p, size_t)
{
  _dlink_Pool::free(p);
}

inline void*
_dlink_Pool::alloc()
{
  if (0 == top)
    {
      new _dlink_Pool;
    }
  void* ans = top;
  top = top->next;
  return ans;
}

inline void
_dlink_Pool::free(void* p)
{
  ((_dlink_Shell*)p)->next = top;
  top = (_dlink_Shell*)p;
}

#endif  POOLED

class dlist {
private:
friend class dlist_iterator;
friend class dlist_traversor;
friend class dlist_looper;
friend class dlist_reverseIterator;
  dlink* last;
public:
  ent remove( dlink* );            // Removes the single argument.
  char remove( ent );              // Ditto 
  ent remove( int );               // Returns the ent removed from the dlist
                                   // Failure -> returns null pointer
  dlist remove( ent, ent );        // Removes everything between its arguments
                                   // (exclusively) and returns the removed chain.
  dlist remove( int, int );
  void insert( ent a );
  void append( ent a );
  char putAbove( ent a, ent b );   // Installs b above a in the list
  char putBelow( ent a, ent b );   // Installs b below a in the list
  ent get();
  ent operator[]( int );
  int size();
  void clear();
  void zap();
  // -----------------------------
  dlist()          { last = 0; }
  dlist( ent a )   { last = new dlink(a,0,0); 
                     last->prev = last; 
                     last->next = last; }
  dlist( dlist& );
  virtual ~dlist() { clear(); }
  dlink* lastPtr() {return last;}
  dlist& operator=( dlist& );
} ;

class dlist_iterator {
  dlink* ce;
  dlist* cs;
public:
  dlist_iterator( dlist& s ) { cs = &s; ce = cs->last; }
  ent operator()();
} ;

class dlist_looper {
  dlink* ce;
  dlist* cs;
public:
  dlist_looper( dlist& s ) { cs = &s; ce = cs->last; }
  ent operator()();
} ;

class dlist_traversor {
  dlink* ce;
  dlist* cs;
public:
  dlist_traversor( dlist& s ) { cs = &s; ce = cs->last; }
  dlink* operator()();
} ;

class dlist_reverseIterator {
  dlink* ce;
  dlist* cs;
public:
  dlist_reverseIterator( dlist& s ) { cs = &s; ce = cs->last; }
  ent operator()();
} ;

#endif DLIST_HXX
End of dlist.hxx
echo menu.hxx 1>&2
cat >menu.hxx <<'End of menu.hxx'
/*************************************************************************
**************************************************************************
**************************************************************************
******                                                                ****
******  MENU: C++ object for creating VT terminal menus.              ****
******                                                                ****
******  Copyright (c) 1989  Universities Research Association, Inc.   ****
******                All Rights Reserved                             ****
******                                                                ****
******  Author:    Leo Michelotti                                     ****
******                                                                ****
******             Fermilab                                           ****
******             P.O.Box 500                                        ****
******             Mail Stop 345                                      ****
******             Batavia, IL   60510                                ****
******                                                                ****
******             Phone: (708) 840 4956                              ****
******             Email: MICHELOTTI@FNALAD                           ****
******                    MICHELOTTI@ADCALC.FNAL.GOV                  ****
******                    ALMOND::MICHELOTTI                          ****
******                                                                ****
******  Release    Version 1.0 : Sep. 20, 1989                        ****
******  Dates:                                                        ****
**************************************************************************
**************************************************************************
******                                                                ****
******  This material resulted from work developed under a            ****
******  Government Contract and is subject to the following           ****
******  license: The Government retains a paid-up, nonexclusive,      ****
******  irrevocable worldwide license to reproduce, prepare           ****
******  derivative works, perform publicly and display publicly       ****
******  by or for the Government, including the right to distribute   ****
******  to other Government contractors.  Neither the United          ****
******  States nor the United States Department of Energy, nor        ****
******  any of their employees, makes any warranty, express or        ****
******  implied, or assumes any legal liability or responsibility     ****
******  for the accuracy, completeness or usefulness of any           ****
******  information, apparatus, product, or process disclosed, or     ****
******  represents that its use would not infringe privately owned    ****
******  rights.                                                       ****
******                                                                ****
******  These files are made avaliable for use by specific            ****
******  individuals or a specific group.  They are not to be          ****
******  reproduced or redistributed.                                  ****
******                                                                ****
******  These files are provided "as is" with no warranties of any    ****
******  kind including the warranties of design,                      ****
******  merchantibility and fitness for a particular purpose,         ****
******  or arising from a course of dealing, usage or trade           ****
******  practice.                                                     ****
******                                                                ****
******  These files are provided with no support or obligation on     ****
******  the part of U.R.A. or Fermilab to assist in their use,        ****
******  correction, modification or enhancement.                      ****
******                                                                ****
******  Neither U.R.A. nor Fermilab shall be liable with              ****
******  respect to the infringement of copyrights, trade              ****
******  secrets or any patents by these files or any part             ****
******  thereof.                                                      ****
******                                                                ****
******  In no event will U.R.A., Fermilab, or the author(s) be        ****
******  liable for any lost revenue or profits or other               ****
******  special, indirect and consequential damages, even if          ****
******  they have been advised of the possibility of such             ****
******  damages.                                                      ****
******                                                                ****
**************************************************************************
*************************************************************************/

#ifndef MENU_HXX_LPJM
#define MENU_HXX_LPJM

typedef void (*MENUFUNC)();
#define MAXMENUCHOICES 10

class ttMenu {
  int numChoices;
  MENUFUNC menuFunction[ MAXMENUCHOICES ];
  char* menuMessage[ MAXMENUCHOICES ];
  char* promptMessage;
public:
  ttMenu();
  void go();
  void print();
  void setItem( char*, MENUFUNC );
  void setOperation( int, MENUFUNC );
  void setMessage( int, char* );
  void setPrompt( char* );
} ;

#endif MENU_HXX_LPJM
End of menu.hxx
echo mxyzptlk.hxx 1>&2
cat >mxyzptlk.hxx <<'End of mxyzptlk.hxx'
/*************************************************************************
**************************************************************************
**************************************************************************
******                                                                ****
******  MXYZPTLK:  A C++ implementation of differential algebra.      ****
******                                                                ****
******  Copyright (c) 1990  Universities Research Association, Inc.   ****
******                All Rights Reserved                             ****
******                                                                ****
******  Author:    Leo Michelotti                                     ****
******                                                                ****
******             Fermilab                                           ****
******             P.O.Box 500                                        ****
******             Mail Stop 345                                      ****
******             Batavia, IL   60510                                ****
******                                                                ****
******             Phone: (708) 840 4956                              ****
******             Email: michelot@hazel.fnal.gov                     ****
******                    michelotti@adcalc.fnal.gov                  ****
******                    almond::michelotti                          ****
******                                                                ****
******  Release    Version 1.0 : January 31, 1990                     ****
******  Dates:              .1 : October 11, 1990                     ****
******                      .2 : November 6, 1990                     ****
******                      .3 : October  2, 1992                     ****
******                      .4 : July    20, 1993                     ****
******                     2.0   August  12, 1993                     ****
******                                                                ****
**************************************************************************
**************************************************************************
******                                                                ****
******  This material resulted from work developed under a            ****
******  Government Contract and is subject to the following           ****
******  license: The Government retains a paid-up, nonexclusive,      ****
******  irrevocable worldwide license to reproduce, prepare           ****
******  derivative works, perform publicly and display publicly       ****
******  by or for the Government, including the right to distribute   ****
******  to other Government contractors.  Neither the United          ****
******  States nor the United States Department of Energy, nor        ****
******  any of their employees, makes any warranty, express or        ****
******  implied, or assumes any legal liability or responsibility     ****
******  for the accuracy, completeness or usefulness of any           ****
******  information, apparatus, product, or process disclosed, or     ****
******  represents that its use would not infringe privately owned    ****
******  rights.                                                       ****
******                                                                ****
******  These files are made avaliable for use by specific            ****
******  individuals or a specific group.  They are not to be          ****
******  reproduced or redistributed.                                  ****
******                                                                ****
******  These files are provided "as is" with no warranties of any    ****
******  kind including the warranties of design,                      ****
******  merchantibility and fitness for a particular purpose,         ****
******  or arising from a course of dealing, usage or trade           ****
******  practice.                                                     ****
******                                                                ****
******  These files are provided with no support or obligation on     ****
******  the part of U.R.A. or Fermilab to assist in their use,        ****
******  correction, modification or enhancement.                      ****
******                                                                ****
******  Neither U.R.A. nor Fermilab shall be liable with              ****
******  respect to the infringement of copyrights, trade              ****
******  secrets or any patents by these files or any part             ****
******  thereof.                                                      ****
******                                                                ****
******  In no event will U.R.A., Fermilab, or the author(s) be        ****
******  liable for any lost revenue or profits or other               ****
******  special, indirect and consequential damages, even if          ****
******  they have been advised of the possibility of such             ****
******  damages.                                                      ****
******                                                                ****
**************************************************************************
*************************************************************************/

#ifndef MXYZPTLK_HXX
#define MXYZPTLK_HXX

extern class DAterm;
extern class DA;
extern class DACterm;
extern class DAC;
extern class LieOperator;

#define DA__MAX_GARBAGE 8000

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <complex.h>
#include <iostream.h>

#include "dlist.hxx"
#include "Attic.hxx"
#include "matrix.h"

#include "mxyzptlk_real.hxx"
#include "mxyzptlk_complex.hxx"
#include "mxyzptlk_DAC.hxx"

#endif MXYZPTLK_HXX
End of mxyzptlk.hxx
echo mxyzptlk_real.hxx 1>&2
cat >mxyzptlk_real.hxx <<'End of mxyzptlk_real.hxx'
/*************************************************************************
**************************************************************************
**************************************************************************
******                                                                ****
******  MXYZPTLK:  A C++ implementation of differential algebra.      ****
******                                                                ****
******  Copyright (c) 1990  Universities Research Association, Inc.   ****
******                All Rights Reserved                             ****
******                                                                ****
******  Author:    Leo Michelotti                                     ****
******                                                                ****
******             Fermilab                                           ****
******             P.O.Box 500                                        ****
******             Mail Stop 345                                      ****
******             Batavia, IL   60510                                ****
******                                                                ****
******             Phone: (708) 840 4956                              ****
******             Email: michelot@hazel.fnal.gov                     ****
******                    michelotti@adcalc.fnal.gov                  ****
******                    almond::michelotti                          ****
******                                                                ****
******  Release    Version 1.0 : January 31, 1990                     ****
******  Dates:              .1 : October 11, 1990                     ****
******                      .2 : November 6, 1990                     ****
******                      .3 : October  2, 1992                     ****
******                      .4 : July    20, 1993                     ****
******                     2.0   August  12, 1993                     ****
******                                                                ****
**************************************************************************
**************************************************************************
******                                                                ****
******  This material resulted from work developed under a            ****
******  Government Contract and is subject to the following           ****
******  license: The Government retains a paid-up, nonexclusive,      ****
******  irrevocable worldwide license to reproduce, prepare           ****
******  derivative works, perform publicly and display publicly       ****
******  by or for the Government, including the right to distribute   ****
******  to other Government contractors.  Neither the United          ****
******  States nor the United States Department of Energy, nor        ****
******  any of their employees, makes any warranty, express or        ****
******  implied, or assumes any legal liability or responsibility     ****
******  for the accuracy, completeness or usefulness of any           ****
******  information, apparatus, product, or process disclosed, or     ****
******  represents that its use would not infringe privately owned    ****
******  rights.                                                       ****
******                                                                ****
******  These files are made avaliable for use by specific            ****
******  individuals or a specific group.  They are not to be          ****
******  reproduced or redistributed.                                  ****
******                                                                ****
******  These files are provided "as is" with no warranties of any    ****
******  kind including the warranties of design,                      ****
******  merchantibility and fitness for a particular purpose,         ****
******  or arising from a course of dealing, usage or trade           ****
******  practice.                                                     ****
******                                                                ****
******  These files are provided with no support or obligation on     ****
******  the part of U.R.A. or Fermilab to assist in their use,        ****
******  correction, modification or enhancement.                      ****
******                                                                ****
******  Neither U.R.A. nor Fermilab shall be liable with              ****
******  respect to the infringement of copyrights, trade              ****
******  secrets or any patents by these files or any part             ****
******  thereof.                                                      ****
******                                                                ****
******  In no event will U.R.A., Fermilab, or the author(s) be        ****
******  liable for any lost revenue or profits or other               ****
******  special, indirect and consequential damages, even if          ****
******  they have been advised of the possibility of such             ****
******  damages.                                                      ****
******                                                                ****
**************************************************************************
*************************************************************************/

#ifndef MXYZPTLK_REAL_HXX
#define MXYZPTLK_REAL_HXX

typedef char (*MX_R_FUNCPTR)(int*, double);

// *******************************************************************
extern struct DAtermData;
class DAterm : public Junk {    

  // Private data
  int* index;	  // An integer array giving the derivatives associated
                  //      with the DAterm.  For example, ( 1, 1, 0, 2 )
                  //            would correspond to D_1^1 D_2^1 D_4^2 .
  int weight;     // The sum of the values in index.  For the above example,
                  //                                        this would be 4.
  double value;   // The value associated with the DAterm.

  // Friends
  friend struct DAtermData;
  friend class DA;
  friend class LieOperator;
  friend class DACterm;

public:

  // Constructors and destructors
  DAterm(); 
  DAterm( int*, double );
  DAterm( DAterm* );
  DAterm( DAterm& );
  DAterm( DAtermData& );
  ~DAterm();

  // Operators
  void operator=( DAterm& );
/*
 *   Pool functions written by Michael Allen
 *   February, 1993
 */
#ifdef POOLED
  inline void* operator new(size_t);
  inline void operator delete(void* p, size_t);
#endif POOLED

  double coeff(){ return value; }

  // Friendly operators
  friend ostream& operator<<(ostream&, DA&);
  friend char operator==( DAterm&, DAterm& );
  friend char operator==( DA&,     double& );
  friend char operator==( double&, DA& );
  friend char operator<=( DAterm&, DAterm& );
  friend char operator%=( DAterm&, DAterm& );   // Acts like == but compares
                                                // indices only.
  friend DA& operator-( DA& );
  friend DA& operator-( DA&, DA& );
  friend DAterm& operator*( DAterm&, DAterm& );
  friend DA& operator*( DA&, DA& );   // Temporarily here for diagnostics.
  friend DA& operator*( DA&, double );
  friend DA& operator*( double, DA& );
  friend DA& operator*( DA&, int );
  friend DA& operator*( int, DA& );
  friend DA& operator/( DA&, DA& );   // Temporarily here for diagnostics.
  friend DA& operator/( DA&, double& ); //        ..y here for dia..
  friend DA& operator/( DA&, int& ); //        ..y here for dia..
  friend DA& operator|( DA&, DA& );   // Temporarily here for diagnostics.

  friend LieOperator& operator*( LieOperator&, LieOperator& );

  // Friendly functions
  friend class DA;
  friend DA& concat( DA& );
  // friend DA& acos( DA& );
  // friend DA& asin( DA& );
  // friend DA& atan( DA& );
  // friend DA& atan2( DA&, DA& );
  friend DA& cos( DA& );
  friend DA& cosh( DA& );
  friend DA& exp( DA& );
  friend DA& log( DA& );
  friend DA& log10( DA& );
  friend DA& pow( DA&, double );
  friend DA& sin( DA& );
  friend DA& sinh( DA& );
  friend DA& sqrt( DA& );
  friend DA& tan( DA& );
  friend DA& tanh( DA& );

  } ;


// *******************************************************************
class DA : public dlist, public Junk  {  

  // Additional private data__________________________________________
  int count;        // The number of DA terms in the variable
  int weight;       // The maximum weight of the terms
  int accuWgt;      // Highest weight computed accurately
  double* refPoint; // Point about which derivatives are to be expanded.

  // Private member functions_________________________________________
  void insert( DAterm* );
  void append( DAterm* );
  void peekAt( int );
  void printCoeffs( int );
  DAterm* remove( dlink* );
  void zap();
//  void addTerm( DAterm* );  Temporarily made public.

  // Friends
  friend class DAC;
  friend class LieOperator;
  friend DA& concat( DA& );
  friend DA& epsCos( DA& );
  friend DA& epsExp( DA& );
  friend DA& epsPow( DA&, double );
  friend DA& epsSin( DA& );
  friend DA& epsSqrt( DA& );
  friend void DASetup( const int, const int );
  friend void DASetup( const int, const int, const double* );
  friend void DASetup( const int, const int, const int );
  friend void DASetup( const int, const int, const int, const double* );

  friend LieOperator& operator*( LieOperator&, LieOperator& );
                                // This is concatenation.

  friend LieOperator& operator+( LieOperator&, LieOperator& );  // ??? Necessary?
  friend LieOperator& operator-( LieOperator&, LieOperator& );
  friend LieOperator& operator-( LieOperator& );
  friend LieOperator& operator*( double&, LieOperator& );
  friend LieOperator& operator*( LieOperator&, double& );
  friend LieOperator& operator*( DA&, LieOperator& );
  friend LieOperator& operator*( LieOperator&, DA& );

  friend DAC& operator*( const complex, const DA& );

public:

  // Constructors and destructors_____________________________________
  DA();
  DA( double );
  DA( DA& );     // This one is absolutely essential!!!
  ~DA();

  // Public member functions__________________________________________
  DAterm* get();            // Pops the top term, which should be the 
                            // one of lowest weight.
  void addTerm( DAterm* );  // Public only for diagnostic purposes.
  void fixReference( double* );
  void fixReference();
  void fixReference( DA& );
  void fixReferenceAtEnd( LieOperator& );
  void fixReferenceAtStart( LieOperator& );

  char isNilpotent();
  void peekAt();
  void printCoeffs();
  dlist image();
  void writeToFile( char*   /* Name of unopened file */ );
  void writeToFile( FILE* );

  void getReference( double* );
  void scaleBy( double );
  void setVariable( double, int );
  void setVariable( int );
  double standardPart();
  void clear();
  double weightedDerivative( int* );
  double derivative( int* );
  DA& filter( int, int );	   // Returns only those DAterms whose weight 
				   // are between two specified values, inclusive.
  DA& filter( char (*)( int*, double ) ); // Returns those DAterms for which the 
                                   // argument is satisfied.
  double operator()( double* );	   // Performs a multinomial evaluation of 
				   // the DA variable.  Essentially acts as a 
				   // power series expansion.
  DA& operator()( DA* );           // Self explanatory ...
  DA& operator()( LieOperator& );  // Self explanatory ...
  DA& D( int* );		   // Performs differentiation of a DA variable.

  // Operators________________________________________________________
  friend ostream& operator<<(ostream&, DA&);
  friend char operator==( DA&, DA& );
  friend char operator==( DA&, double& );
  friend char operator==( double&, DA& );
  DA& operator=( DA& );
  DA& operator+=( double& );
  friend DA& operator+( DA&, DA& );
  friend DA& operator+( DA&, double& );
  friend DA& operator+( double&, DA& );
  friend DA& operator-( DA&, DA& );
  friend DA& operator-( DA& );
  friend DA& operator*( DA&, DA& );
  friend DA& operator*( DA&, double );
  friend DA& operator*( double, DA& );
  friend DA& operator|( DA&, DA& );   // This is truncated multiplication,
                                      //    used by the division operator.
  friend DA& operator/( DA&, DA& );
  friend DA& operator/( DA&, double& ); 
  friend DA& operator^( DA&, DA& );   // Poisson bracket

  friend DA& operator*( DA&, int );
  friend DA& operator*( int, DA& );
  friend DA& operator/( DA&, int& ); 

  friend LieOperator& operator*( LieOperator&, LieOperator& );

  DA& inverse();             // Returns the inverse jet
                             //  only when the number of
                             //  coordinates = 1.

  // Overloaded analytic functions__________________________________
  friend DA& acos( DA& );
  friend DA& asin( DA& );
  friend DA& atan( DA& );
  //  friend DA& atan2( DA&, DA& );
  friend DA& cos( DA& );
  friend DA& cosh( DA& );
  friend DA& exp( DA& );
  friend DA& log( DA& );
  friend DA& log10( DA& );
  friend DA& pow( DA&, double );
  friend DA& sin( DA& );
  friend DA& sinh( DA& );
  friend DA& sqrt( DA& );
  friend DA& tan( DA& );
  friend DA& tanh( DA& );
} ;

struct DAtermData{
  int  numvar;
  int* index;
  int weight;
  double value;
  DAtermData();
  DAtermData( DAterm& );
  ~DAtermData();
};

/*
 *   Pool functions written by Michael Allen
 *   February, 1993
 */

#ifdef POOLED
class _DAterm_Shell
{
friend class _DAterm_Pool;

 private:
 
  union
  {
    _DAterm_Shell* next;
    char  dummy[sizeof(DAterm)];
  };
};

#define _DAterm_BLOCK_COUNT 1024

class _DAterm_Pool
{
friend class DAterm;
  
 private:
  _DAterm_Pool();
  
  inline static void* alloc();
  inline static void free(void*);
  
  _DAterm_Shell slot[_DAterm_BLOCK_COUNT];
  static _DAterm_Shell* top;
  static DAterm num_made;
};

inline void*
DAterm::operator new(size_t)
{
  return _DAterm_Pool::alloc();
}

inline void
DAterm::operator delete(void* p, size_t)
{
  _DAterm_Pool::free(p);
}

inline void*
_DAterm_Pool::alloc()
{
  if (0 == top)
    {
      new _DAterm_Pool;
    }
  void* ans = top;
  top = top->next;
  return ans;
}

inline void
_DAterm_Pool::free(void* p)
{
  ((_DAterm_Shell*)p)->next = top;
  top = (_DAterm_Shell*)p;
}

#endif POOLED

void operator+=( DA&, DA& );   // ??? Why are these void operators?
void operator-=( DA&, DA& );
void operator*=( DA&, DA& );
void operator/=( DA&, DA& );
char operator!=( DA&, DA& );
char operator!=( DA&, double& );
char operator!=( double&, DA& );


// *******************************************************************
class LieOperator : public Junk {
private:
  DA* v;
  int accuWgt;
  int weight;
  double* refPoint; // Point about which derivatives are to be expanded.

  // Friends
  friend class DA;
  friend class CLieOperator;
  friend void DASetup( const int, const int );
  friend void DASetup( const int, const int, const double* );
  friend void DASetup( const int, const int, const int );
  friend void DASetup( const int, const int, const int, const double* );
  friend void DAFixReferenceAtStart( LieOperator& );

public:

  // Constructors and destructors_____________________________________
  LieOperator();
  LieOperator( LieOperator& );
  LieOperator( DA* );     
  LieOperator( char* );   // Creates the identity function.  
  // ??? REMOVE  LieOperator( int );
  ~LieOperator();

  // Member functions (public)
  void reset();     // Resets the private data.
  void fixReference( double* );
  void fixReference();
  void fixReference( DA& );
  void fixReferenceAtEnd( LieOperator& );
  void fixReferenceAtStart( LieOperator& );
  void setVariable( DA&, int );
  void setVariable( double, int );
  void getReference( double* );
  void peekAt();
  void peekAt( char* );
  dlist* image();
  void printCoeffs();
  void printCoeffs( char* );
  void standardPart( double* );
  void weightedDerivative( int*, double* );
  void derivative( int*, double* );
  LieOperator& filter( int, int );
  LieOperator& filter( MX_R_FUNCPTR [] );
  doublematrix Jacobian();
  LieOperator& inverse();

  char isNilpotent();

  // Friendly operators ...........................
  LieOperator& operator()( LieOperator& );  // Self explanatory ...

  friend ostream& operator<<(ostream&, LieOperator&);
  friend char operator==( LieOperator&, LieOperator& );
  friend char operator!=( LieOperator&, LieOperator& );  
  char operator==( double );
  char operator!=( double );
  LieOperator& operator=( LieOperator& );
  DA operator[]( int );

  DA& operator^( DA& );         // Action as a Lie operator
  DA& expMap( double, DA& );    // Performs exponential map on
                                //  the second argument.
  DA& expMap( DA&,    DA& );    // The orbit parameter is here
                                //  a DA variable.
  LieOperator& expMap( double, LieOperator& ); // Performs exponential map 
                                               //  componenet wise.
  LieOperator& expMap( DA&,    LieOperator& );    

  friend LieOperator& operator*( LieOperator&, LieOperator& );
                                // This is concatenation.

  // Arithmetic
  friend LieOperator& operator+( LieOperator&, LieOperator& );
  friend LieOperator& operator-( LieOperator&, LieOperator& );
  friend LieOperator& operator-( LieOperator& );
  friend LieOperator& operator*( double&, LieOperator& );
  friend LieOperator& operator*( LieOperator&, double& );
  friend LieOperator& operator*( DA&, LieOperator& );
  friend LieOperator& operator*( LieOperator&, DA& );

  friend  LieOperator& operator*(  doublematrix&, LieOperator& );
  friend CLieOperator& operator*( complexmatrix&, LieOperator& );

} ;


// *******************************************************************
class coord : public DA {
private:
  int index;
public:
  coord();
  coord( double );
  coord( coord& );
  ~coord();
  coord& operator=( coord& );
  coord& operator=( DA& );
  void set( double );
} ;



// *******************************************************************
class HamiltonianLieOperator : public LieOperator {	 // ??? TO BE IMPLEMENTED
public:
  HamiltonianLieOperator( DA& );			 // ??? TO BE IMPLEMENTED
  ~HamiltonianLieOperator();                             // ??? TO BE IMPLEMENTED
};


// *******************************************************************
//
//     Definition of the DA environment
//

struct DA__environment {
 double* DA__monomial;       // Storage area for monomials used in multinomial
			     //   evaluation.  The area itself is defined by 
			     //   DASetup.
 DA*     DA__DAmonomial;     // Storage area for DA monomials used in concatenation.
			     //   The area itself is defined by DASetup.
 int*    DA__exponent;       // Used by nexcom (as called by DA::operator()
			     //   when storing monomials. The array DA__exponent 
			     //   is allocated by DASetup.
 char*   DA__expCode;        // The Wilf code of a monomial. 
 char    DA__PBOK;           // Taking Poisson brackets is OK: the dimension of 
			     //   phase space is even.
 int**   DA__numPaths;       // An array counting the number of paths to a vertex 
			     //   in the Wilf graph.  DASetup arranges that 
			     //   DA__numPaths[w][n] = number of compositions of
			     //   a weight  w  into  n  parts.
 int     DA__NumVar;         // Number of scalar variables associated with 
			     //   the DA variable.
 int     DA__MaxWeight;      // Maximum acceptable weight of a DA variable,
			     //   equivalent to the maximum order of derivatives
			     //   to be carried through calculations.
 int     DA__allSet;         // Records when DASetup has been called.
 int     DA__weightLimit;    // Used in truncated multiplication and division
 int     DA__SpaceDim;       // This is, if you will, the dimension of phase space.
 int     DA__dof;            // The number of degrees of freedom = DA__SpaceDim / 2.
 double* DA__refPoint;       // Default reference point in phase space about which 
			     //   derivatives are to be taken.
 int*    DA__AllZeroes;      // An integer array containing zeroes.  Used to 
			     //   filter the standard part of a DA variable.
 dlist   DA__predefDA;       // A list of DA variables whose declarations precede
			     //   a call to DASetup.  These are post-processed when
			     //   DASetup is finally called.
 dlist   DA__predefLieOp;    // A list of LieOperator variables whose declarations precede
                             //   a call to DASetup.  These are post-processed when
                             //   DASetup is finally called.

 DA__environment();
 ~DA__environment();
};


// *******************************************************************
//
//     Setup routines, etc.
//


extern void DASetup( const int, const int );
extern void DASetup( const int, const int, const double* );
extern void DASetup( const int, const int, const int );
extern void DASetup( const int, const int, const int, const double* );

extern void DAFixReference( double* );
extern void DAFixReference( DA& );
extern void DAFixReferenceAtStart( LieOperator& );
extern void DAFixReferenceAtEnd( LieOperator& );

#endif MXYZPTLK_REAL_HXX
End of mxyzptlk_real.hxx
echo mxyzptlk_complex.hxx 1>&2
cat >mxyzptlk_complex.hxx <<'End of mxyzptlk_complex.hxx'
#ifndef MXYZPTLK_COMPLEX_HXX
#define MXYZPTLK_COMPLEX_HXX

class ComplexDA : public Junk
{
private:
  DA  re;
  DA  im;
public:
  ComplexDA();
  ComplexDA( DA&,DA& );
  ComplexDA( ComplexDA& );
  ~ComplexDA();

  DA  real();
  DA  imag();           

  ComplexDA& operator= ( ComplexDA& );

  // _______ Arithmetic operations __________________________
  friend ComplexDA&  conj( ComplexDA& x );
  friend ComplexDA&  operator- ( ComplexDA& x );
  friend ComplexDA&  operator+ ( ComplexDA& x, ComplexDA& y );
  friend ComplexDA&  operator+ ( ComplexDA& x, DA& y );
  friend ComplexDA&  operator+ ( DA& x, ComplexDA& y );
  friend ComplexDA&  operator- ( ComplexDA& x, ComplexDA& y );
  friend ComplexDA&  operator- ( ComplexDA& x, DA& y );
  friend ComplexDA&  operator- ( DA& x, ComplexDA& y );
  friend ComplexDA&  operator* ( ComplexDA& x, ComplexDA& y );
  friend ComplexDA&  operator* ( ComplexDA& x, DA& y );
  friend ComplexDA&  operator* ( DA& x, ComplexDA& y );
  friend ComplexDA&  operator/  ( ComplexDA& x, DA& y );
  friend ComplexDA&  operator/  ( ComplexDA& x, ComplexDA& y );

  // _______ Utilities ______________________________________
  void peekAt();

} ;

inline DA  ComplexDA::real() { return re; }
inline DA  ComplexDA::imag() { return im; }

#endif MXYZPTLK_COMPLEX_HXX
End of mxyzptlk_complex.hxx
echo mxyzptlk_DAC.hxx 1>&2
cat >mxyzptlk_DAC.hxx <<'End of mxyzptlk_DAC.hxx'
/*************************************************************************
**************************************************************************
**************************************************************************
******                                                                ****
******  MXYZPTLK:  A C++ implementation of differential algebra.      ****
******                                                                ****
******  Copyright (c) 1990  Universities Research Association, Inc.   ****
******                All Rights Reserved                             ****
******                                                                ****
******  Author:    Leo Michelotti                                     ****
******                                                                ****
******             Fermilab                                           ****
******             P.O.Box 500                                        ****
******             Mail Stop 345                                      ****
******             Batavia, IL   60510                                ****
******                                                                ****
******             Phone: (708) 840 4956                              ****
******             Email: michelot@hazel.fnal.gov                     ****
******                    michelotti@adcalc.fnal.gov                  ****
******                    almond::michelotti                          ****
******                                                                ****
******  Release    Version 1.0 : January 31, 1990                     ****
******  Dates:              .1 : October 11, 1990                     ****
******                      .2 : November 6, 1990                     ****
******                      .3 : October  2, 1992                     ****
******                      .4 : July    20, 1993                     ****
******                     2.0   August  12, 1993                     ****
******                                                                ****
**************************************************************************
**************************************************************************
******                                                                ****
******  This material resulted from work developed under a            ****
******  Government Contract and is subject to the following           ****
******  license: The Government retains a paid-up, nonexclusive,      ****
******  irrevocable worldwide license to reproduce, prepare           ****
******  derivative works, perform publicly and display publicly       ****
******  by or for the Government, including the right to distribute   ****
******  to other Government contractors.  Neither the United          ****
******  States nor the United States Department of Energy, nor        ****
******  any of their employees, makes any warranty, express or        ****
******  implied, or assumes any legal liability or responsibility     ****
******  for the accuracy, completeness or usefulness of any           ****
******  information, apparatus, product, or process disclosed, or     ****
******  represents that its use would not infringe privately owned    ****
******  rights.                                                       ****
******                                                                ****
******  These files are made avaliable for use by specific            ****
******  individuals or a specific group.  They are not to be          ****
******  reproduced or redistributed.                                  ****
******                                                                ****
******  These files are provided "as is" with no warranties of any    ****
******  kind including the warranties of design,                      ****
******  merchantibility and fitness for a particular purpose,         ****
******  or arising from a course of dealing, usage or trade           ****
******  practice.                                                     ****
******                                                                ****
******  These files are provided with no support or obligation on     ****
******  the part of U.R.A. or Fermilab to assist in their use,        ****
******  correction, modification or enhancement.                      ****
******                                                                ****
******  Neither U.R.A. nor Fermilab shall be liable with              ****
******  respect to the infringement of copyrights, trade              ****
******  secrets or any patents by these files or any part             ****
******  thereof.                                                      ****
******                                                                ****
******  In no event will U.R.A., Fermilab, or the author(s) be        ****
******  liable for any lost revenue or profits or other               ****
******  special, indirect and consequential damages, even if          ****
******  they have been advised of the possibility of such             ****
******  damages.                                                      ****
******                                                                ****
**************************************************************************
*************************************************************************/

#ifndef MXYZPTLK_DAC_HXX
#define MXYZPTLK_DAC_HXX

#define DAC__MAX_GARBAGE 8000

typedef char (*MX_C_FUNCPTR)(int*, complex);

extern class DAC;
class DAterm;
class DA;
class LieOperator;


// *******************************************************************
extern struct DACtermData;
class DACterm : public Junk {    

  // Private data
  int* index;	  // An integer array giving the derivatives associated
                  //      with the DACterm.  For example, ( 1, 1, 0, 2 )
                  //            would correspond to D_1^1 D_2^1 D_4^2 .
  int weight;     // The sum of the values in index.  For the above example,
                  //                                        this would be 4.
  complex value;   // The value associated with the DACterm.

  // Friends
  friend struct DACtermData;
  friend class DAC;
  friend class CLieOperator;

public:

  // Constructors and destructors
  DACterm(); 
  DACterm( int*, complex );
  DACterm( DACterm* );
  DACterm( DAterm* );
  DACterm( DACterm& );
  DACterm( DACtermData& );
  ~DACterm();

  // Operators
  void operator=( DACterm& );
/*
 *   Pool functions written by Michael Allen
 *   February, 1993
 */
#ifdef POOLED
  inline void* operator new(size_t);
  inline void operator delete(void* p, size_t);
#endif POOLED

  // Friendly operators
  friend ostream& operator<<(ostream&, DAC&);
  friend char operator==( DACterm&, DACterm& );
  friend char operator==( DAC&, complex& );
  friend char operator==( complex&, DAC& );
  friend char operator<=( DACterm&, DACterm& );
  friend char operator%=( DACterm&, DACterm& );   // Acts like == but compares
                                                // indices only.
  friend DAC& operator-( DAC& );
  friend DAC& operator-( DAC&, DAC& );
  friend DACterm& operator*( DACterm&, DACterm& );
  friend DAC& operator*( DAC&, DAC& );   // Temporarily here for diagnostics.
  friend DAC& operator*( DAC&, const complex );
  friend DAC& operator*( const complex, DAC& );
  friend DAC& operator*( const complex, const DA& );
  friend DAC& operator*( const double, DAC& );
  friend DAC& operator*( DAC&, const int );
  friend DAC& operator*( const int, DAC& );
  friend DAC& operator/( DAC&, DAC& );   // Temporarily here for diagnostics.
  friend DAC& operator/( DAC&, const complex& ); //        ..y here for dia..
  friend DAC& operator/( DAC&, const double& ); //        ..y here for dia..
  friend DAC& operator/( DAC&, const int& ); //        ..y here for dia..
  friend DAC& operator|( DAC&, DAC& );   // Temporarily here for diagnostics.

  friend CLieOperator& operator*( CLieOperator&, CLieOperator& );

  // Friendly functions
  friend class DAC;
  friend DAC& concat( DAC& );
  // friend DAC& acos( DAC& );
  // friend DAC& asin( DAC& );
  // friend DAC& atan( DAC& );
  // friend DAC& atan2( DAC&, DAC& );
  friend DAC& cos( DAC& );
  friend DAC& cosh( DAC& );
  friend DAC& exp( DAC& );
  friend DAC& log( DAC& );
  friend DAC& log10( DAC& );
  friend DAC& pow( DAC&, double );
  friend DAC& sin( DAC& );
  friend DAC& sinh( DAC& );
  friend DAC& sqrt( DAC& );
  friend DAC& tan( DAC& );
  friend DAC& tanh( DAC& );

  } ;


// *******************************************************************
class DAC : public dlist, public Junk  {  

  // Additional private data__________________________________________
  int count;        // The number of DAC terms in the variable
  int weight;       // The maximum weight of the terms
  int accuWgt;      // Highest weight computed accurately
  complex* refPoint; // Point about which derivatives are to be expanded.

  // Private member functions_________________________________________
  void insert( DACterm* );
  void append( DACterm* );
  void printCoeffs( int );
  void peekAt( int );
  DACterm* remove( dlink* );
  void zap();
//  void addTerm( DACterm* );  Temporarily made public.

  // Friends
  friend class CLieOperator;
  friend DAC& concat( DAC& );
  friend DAC& epsCos( DAC& );
  friend DAC& epsExp( DAC& );
  friend DAC& epsPow( DAC&, double );
  friend DAC& epsSin( DAC& );
  friend DAC& epsSqrt( DAC& );
  friend void DACSetup( int, int );
  friend void DACSetup( int, int, complex* );
  friend void DACSetup( int, int, int );
  friend void DACSetup( int, int, int, complex* );

  friend CLieOperator& operator*( CLieOperator&, CLieOperator& );
                                // This is concatenation.

  friend CLieOperator& operator+( CLieOperator&, CLieOperator& );
  friend CLieOperator& operator-( CLieOperator&, CLieOperator& );
  friend CLieOperator& operator-( CLieOperator& );
  friend CLieOperator& operator*( complex&, CLieOperator& );
  friend CLieOperator& operator*( CLieOperator&, complex& );
  friend CLieOperator& operator*( DAC&, CLieOperator& );
  friend CLieOperator& operator*( CLieOperator&, DAC& );


  friend DAC& operator*( const complex, const DA& );

public:

  // Constructors and destructors_____________________________________
  DAC();
  DAC( complex );
  DAC( DAC& );     // This one is absolutely essential!!!
  DAC( DA& );
  ~DAC();

  // Public member functions__________________________________________
  DACterm* get();            // Pops the top term, which should be the 
                            // one of lowest weight.
  void addTerm( DACterm* );  // Public only for diagnostic purposes.
  void fixReference( complex* );
  void fixReference();
  void fixReference( DAC& );
  void fixReferenceAtEnd( CLieOperator& );
  void fixReferenceAtStart( CLieOperator& );

  char isNilpotent();
  void peekAt();
  void printCoeffs();
  dlist image();
  void writeToFile( char*   /* Name of unopened file */ );
  void writeToFile( FILE* );

  void getReference( complex* );
  void scaleBy( complex );
  void setVariable( complex, int );
  void setVariable( int );
  complex standardPart();
  void clear();
  complex weightedDerivative( int* );
  complex derivative( int* );
  DAC& filter( int, int );	    // Returns only those DACterms whose weight 
				    // are between two specified values, inclusive.
  DAC& filter( char (*)( int*, complex ) ); // Returns those DACterms for which the 
				    // argument is satisfied.
  complex operator()( complex* );   // Performs a multinomial evaluation of 
				    // the DAC variable.  Essentially acts as a 
				    // power series expansion.
  DAC& operator()( DAC* );	    // Self explanatory ...
  DAC& operator()( CLieOperator& ); // Self explanatory ...
  DAC& D( int* );                   // Performs differentiation of a DAC variable.

  // Operators________________________________________________________
  friend ostream& operator<<(ostream&, DAC&);
  friend char operator==( DAC&, DAC& );
  friend char operator==( DAC&, complex& );
  friend char operator==( complex&, DAC& );
  DAC& operator=( const DAC& );
  DAC& operator+=( complex& );
  friend DAC& operator+( DAC&, DAC& );
  friend DAC& operator+( DAC&, complex& );
  friend DAC& operator+( complex&, DAC& );
  friend DAC& operator-( DAC&, DAC& );
  friend DAC& operator-( DAC& );
  friend DAC& operator*( DAC&, DAC& );
  friend DAC& operator*( DAC&, const complex );
  friend DAC& operator*( const complex, DAC& );
  friend DAC& operator*( const complex, DA& );
  friend DAC& operator*( const double, DAC& );
  friend DAC& operator|( DAC&, DAC& );   // This is truncated multiplication,
                                      //    used by the division operator.
  friend DAC& operator/( DAC&, DAC& );
  friend DAC& operator/( DAC&, const complex& ); 
  friend DAC& operator/( DAC&, const double& ); 
  friend DAC& operator^( DAC&, DAC& );   // Poisson bracket

  friend DAC& operator*( DAC&, const int );
  friend DAC& operator*( const int, DAC& );
  friend DAC& operator/( DAC&, const int& ); 

  friend CLieOperator& operator*( CLieOperator&, CLieOperator& );

  // Overloaded arithmetic functions__________________________________
  //  friend DAC& acos( DAC& );
  //  friend DAC& asin( DAC& );
  //  friend DAC& atan( DAC& );
  //  friend DAC& atan2( DAC&, DAC& );
  friend DAC& cos( DAC& );
  friend DAC& cosh( DAC& );
  friend DAC& exp( DAC& );
  friend DAC& log( DAC& );
  friend DAC& log10( DAC& );
  friend DAC& pow( DAC&, double );
  friend DAC& sin( DAC& );
  friend DAC& sinh( DAC& );
  friend DAC& sqrt( DAC& );
  friend DAC& tan( DAC& );
  friend DAC& tanh( DAC& );
} ;

struct DACtermData{
  int  numvar;
  int* index;
  int weight;
  complex value;
  DACtermData();
  DACtermData( DACterm& );
  ~DACtermData();
};

/*
 *   Pool functions written by Michael Allen
 *   February, 1993
 */

#ifdef POOLED
class _DACterm_Shell
{
friend class _DACterm_Pool;

 private:
 
  union
  {
    _DACterm_Shell* next;
    char  dummy[sizeof(DACterm)];
  };
};

#define _DACterm_BLOCK_COUNT 1024

class _DACterm_Pool
{
friend class DACterm;
  
 private:
  _DACterm_Pool();
  
  inline static void* alloc();
  inline static void free(void*);
  
  _DACterm_Shell slot[_DACterm_BLOCK_COUNT];
  static _DACterm_Shell* top;
  static DACterm num_made;
};

inline void*
DACterm::operator new(size_t)
{
  return _DACterm_Pool::alloc();
}

inline void
DACterm::operator delete(void* p, size_t)
{
  _DACterm_Pool::free(p);
}

inline void*
_DACterm_Pool::alloc()
{
  if (0 == top)
    {
      new _DACterm_Pool;
    }
  void* ans = top;
  top = top->next;
  return ans;
}

inline void
_DACterm_Pool::free(void* p)
{
  ((_DACterm_Shell*)p)->next = top;
  top = (_DACterm_Shell*)p;
}

#endif POOLED

void operator+=( DAC&, DAC& );
void operator-=( DAC&, DAC& );
void operator*=( DAC&, DAC& );
void operator/=( DAC&, DAC& );
char operator!=( DAC&, DAC& );
char operator!=( DAC&, complex& );
char operator!=( complex&, DAC& );


// *******************************************************************
class CLieOperator : public Junk {
private:
  DAC* v;
  int accuWgt;
  int weight;
  complex* refPoint; // Point about which derivatives are to be expanded.

  // Friends
  friend class DAC;
  friend void DACSetup( int, int );
  friend void DACSetup( int, int, complex* );
  friend void DACSetup( int, int, int );
  friend void DACSetup( int, int, int, complex* );
  friend void DACFixReferenceAtStart( CLieOperator& );

public:

  // Constructors and destructors_____________________________________
  CLieOperator();
  CLieOperator( CLieOperator& );
  CLieOperator( LieOperator& );
  CLieOperator( char* );   // Creates the identity function.  
  // ??? REMOVE  CLieOperator( int );
  ~CLieOperator();

  // Member functions (public)
  void reset();      // Resets the private data.
  void fixReference( complex* );
  void fixReference();
  void fixReference( DAC& );
  void fixReferenceAtEnd( CLieOperator& );
  void fixReferenceAtStart( CLieOperator& );
  void setVariable( DAC&, int );
  void setVariable( complex, int );
  void getReference( complex* );
  void peekAt();
  void peekAt( char* );
  dlist* image();
  void printCoeffs();
  void printCoeffs( char* );
  void standardPart( complex* );
  void weightedDerivative( int*, complex* );
  void derivative( int*, complex* );
  CLieOperator& filter( int, int );
  CLieOperator& filter( MX_C_FUNCPTR [] );
  complexmatrix Jacobian();

  char isNilpotent();

  // Friendly operators ...........................
  CLieOperator& operator()( CLieOperator& );  // Self explanatory ...

  friend ostream& operator<<(ostream&, CLieOperator&);
  friend char operator==( CLieOperator&, CLieOperator& );
  CLieOperator& operator=( CLieOperator& );
  DAC operator[]( int );

  DAC& operator^( DAC& );         // Action as a Lie operator
  DAC& expMap( double, DAC& );    // Performs exponential map on
                                  //  the second argument.
  DAC& expMap( DAC&,    DAC& );   // The orbit parameter is here
                                  //  a DA variable.
  CLieOperator& expMap( double, CLieOperator& ); // Performs exponential map 
                                                 //  componenet wise.
  CLieOperator& expMap( DA&,    CLieOperator& );    
  CLieOperator& expMap( DAC&,   CLieOperator& );    

  friend CLieOperator& operator*( CLieOperator&, CLieOperator& );

  friend CLieOperator& operator+( CLieOperator&, CLieOperator& );
  friend CLieOperator& operator-( CLieOperator&, CLieOperator& );
  friend CLieOperator& operator-( CLieOperator& );
  friend CLieOperator& operator*( complex&, CLieOperator& );
  friend CLieOperator& operator*( CLieOperator&, complex& );
  friend CLieOperator& operator*( DAC&, CLieOperator& );
  friend CLieOperator& operator*( CLieOperator&, DAC& );

  friend CLieOperator& operator*(  doublematrix&, CLieOperator& );
  friend CLieOperator& operator*( complexmatrix&, CLieOperator& );
} ;


// *******************************************************************
class coordC : public DAC {
private:
  int index;
public:
  coordC();
  coordC( complex );
  coordC( coordC& );
  ~coordC();
  coordC& operator=( coordC& );
  coordC& operator=( DAC& );
  void set( complex );
} ;



// *******************************************************************
class HamiltonianCLieOperator : public CLieOperator {	 // ??? TO BE IMPLEMENTED
public:
  HamiltonianCLieOperator( DAC& );			 // ??? TO BE IMPLEMENTED
  ~HamiltonianCLieOperator();                             // ??? TO BE IMPLEMENTED
};


// *******************************************************************
//
//     Definition of the DAC environment
//

struct DAC__environment {
 complex* DAC__monomial;     // Storage area for monomials used in multinomial
			     //   evaluation.  The area itself is defined by 
			     //   DACSetup.
 DAC*     DAC__DAmonomial;   // Storage area for DAC monomials used in concatenation.
			     //   The area itself is defined by DACSetup.
 int*    DAC__exponent;      // Used by nexcom (as called by DAC::operator()) 
			     //   when storing monomials. The array DAC__exponent 
			     //   is allocated by DACSetup.
 char*   DAC__expCode;       // The Wilf code of a monomial. 
 char    DAC__PBOK;          // Taking Poisson brackets is OK: the dimension of 
			     //   phase space is even.
 int**   DAC__numPaths;      // An array counting the number of paths to a vertex 
			     //   in the Wilf graph.  DACSetup arranges that 
			     //   DAC__numPaths[w][n] = number of compositions of
			     //   a weight  w  into  n  parts.
 int     DAC__NumVar;        // Number of scalar variables associated with 
			     //   the DAC variable.
 int     DAC__MaxWeight;     // Maximum acceptable weight of a DAC variable,
			     //   equivalent to the maximum order of derivatives
			     //   to be carried through calculations.
 int     DAC__allSet;        // Records when DACSetup has been called.
 int     DAC__weightLimit;   // Used in truncated multiplication and division
 int     DAC__SpaceDim;      // This is, if you will, the dimension of phase space.
 int     DAC__dof;           // The number of degrees of freedom = DAC__SpaceDim / 2.
 complex* DAC__refPoint;     // Default reference point in phase space about which 
			     //   derivatives are to be taken.
 int*    DAC__AllZeroes;     // An integer array containing zeroes.  Used to 
			     //   filter the standard part of a DAC variable.
 dlist   DAC__predefDA;      // A list of DAC variables whose declarations precede
			     //   a call to DACSetup.  These are post-processed when
			     //   DACSetup is finally called.
 dlist   DAC__predefLieOp;   // A list of LieOperator variables whose declarations precede
                             //   a call to DACSetup.  These are post-processed when
                             //   DACSetup is finally called.

 DAC__environment();
 ~DAC__environment();
};



// *******************************************************************
//
//     Setup routines, etc.
//


extern void DACSetup( int, int );
extern void DACSetup( int, int, int );
extern void DACSetup( int, int, complex* );
extern void DACSetup( int, int, int, complex* );

extern void DACFixReference( complex* );
extern void DACFixReference( DAC& );
extern void DACFixReferenceAtStart( CLieOperator& );
extern void DACFixReferenceAtEnd( CLieOperator& );

#endif MXYZPTLK_DAC_HXX
End of mxyzptlk_DAC.hxx
echo mxyzptlk.rsc 1>&2
cat >mxyzptlk.rsc <<'End of mxyzptlk.rsc'
/*************************************************************************
**************************************************************************
**************************************************************************
******                                                                ****
******  MXYZPTLK:  A C++ implementation of differential algebra.      ****
******                                                                ****
******  Copyright (c) 1990  Universities Research Association, Inc.   ****
******                All Rights Reserved                             ****
******                                                                ****
******  Author:    Leo Michelotti                                     ****
******                                                                ****
******             Fermilab                                           ****
******             P.O.Box 500                                        ****
******             Mail Stop 345                                      ****
******             Batavia, IL   60510                                ****
******                                                                ****
******             Phone: (708) 840 4956                              ****
******             Email: michelot@hazel.fnal.gov                     ****
******                    michelotti@adcalc.fnal.gov                  ****
******                    almond::michelotti                          ****
******                                                                ****
******  Release    Version 1.0 : January 31, 1990                     ****
******  Dates:              .1 : October 11, 1990                     ****
******                      .2 : November 6, 1990                     ****
******                      .3 : October  2, 1992                     ****
******                      .4 : July    20, 1993                     ****
******                                                                ****
**************************************************************************
**************************************************************************
******                                                                ****
******  This material resulted from work developed under a            ****
******  Government Contract and is subject to the following           ****
******  license: The Government retains a paid-up, nonexclusive,      ****
******  irrevocable worldwide license to reproduce, prepare           ****
******  derivative works, perform publicly and display publicly       ****
******  by or for the Government, including the right to distribute   ****
******  to other Government contractors.  Neither the United          ****
******  States nor the United States Department of Energy, nor        ****
******  any of their employees, makes any warranty, express or        ****
******  implied, or assumes any legal liability or responsibility     ****
******  for the accuracy, completeness or usefulness of any           ****
******  information, apparatus, product, or process disclosed, or     ****
******  represents that its use would not infringe privately owned    ****
******  rights.                                                       ****
******                                                                ****
******  These files are made avaliable for use by specific            ****
******  individuals or a specific group.  They are not to be          ****
******  reproduced or redistributed.                                  ****
******                                                                ****
******  These files are provided "as is" with no warranties of any    ****
******  kind including the warranties of design,                      ****
******  merchantibility and fitness for a particular purpose,         ****
******  or arising from a course of dealing, usage or trade           ****
******  practice.                                                     ****
******                                                                ****
******  These files are provided with no support or obligation on     ****
******  the part of U.R.A. or Fermilab to assist in their use,        ****
******  correction, modification or enhancement.                      ****
******                                                                ****
******  Neither U.R.A. nor Fermilab shall be liable with              ****
******  respect to the infringement of copyrights, trade              ****
******  secrets or any patents by these files or any part             ****
******  thereof.                                                      ****
******                                                                ****
******  In no event will U.R.A., Fermilab, or the author(s) be        ****
******  liable for any lost revenue or profits or other               ****
******  special, indirect and consequential damages, even if          ****
******  they have been advised of the possibility of such             ****
******  damages.                                                      ****
******                                                                ****
**************************************************************************
*************************************************************************/

#ifndef MXYZPTLK_RSC
#define MXYZPTLK_RSC

#include "mxyzptlk.hxx"

Attic  DA__garbage( DA__MAX_GARBAGE );
struct DA__environment DA__1stEnv;
FILE  *DA__scratchFile;
dlist  DA__coordPool;
dlist  DA__coordPtrs;

struct DAC__environment DAC__1stEnv;
dlist  DAC__coordPool;
dlist  DAC__coordPtrs;


// Federally approved utilities ....................

extern void normalForm( LieOperator&,      /* Input:   map                    */
                        int,               /* Input:   order                  */
                        complexmatrix*,    /* Output:  matrix of eigenvectors */
                                           /*          of Jacobian of map     */
                        CLieOperator*,     /* Output:  normal form            */
                        CLieOperator* );   /* Output:  transformation         */

#endif MXYZPTLK_RSC
End of mxyzptlk.rsc
echo numrecip.hxx 1>&2
cat >numrecip.hxx <<'End of numrecip.hxx'
/*
**  Declarations are taken from the files nr.h and nrutil.h
**  of Numerical Recipes.  The only changes are to put the
**  extern "C" declearation in front, making the routines 
**  available to C++ programs.
*/

#ifndef NUMRECIP_HXX_LPJM
#define NUMRECIP_HXX_LPJM

// From nr.h

extern "C" {
 void gaussj(float **a, int n, float **b, int m);
 float ran0(long *idum);
}

// From nrutil.h

extern "C" {
 void nrerror(char error_text[]);
 int *ivector(long nl, long nh);
 void free_ivector(int *v, long nl, long nh);
 double *dvector(long nl, long nh);
 void free_dvector(double *v, long nl, long nh);
 float **matrix(long nrl, long nrh, long ncl, long nch);
 void free_matrix(float **m, long nrl, long nrh, long ncl, long nch);
 double **dmatrix(long nrl, long nrh, long ncl, long nch);
 void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
 int **imatrix(long nrl, long nrh, long ncl, long nch);
 void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
}

#endif NUMRECIP_HXX_LPJM
End of numrecip.hxx
echo slist.hxx 1>&2
cat >slist.hxx <<'End of slist.hxx'
/*************************************************************************
**************************************************************************
******                                                               *****
******  Leo Michelotti                                               *****
******                                                               *****
******  Taken from Stroustrup's book,                                *****
******  The C++ Programming Language                                 *****
******                                                               *****
**************************************************************************
**************************************************************************
*************************************************************************/

#ifndef SLIST_HXX
#define SLIST_HXX

typedef void* ent;

class slink {
friend class slist;
friend class slist_iterator;
  slink* next;
  ent e;
  slink( ent a, slink* p ) { e=a; next=p; }
} ;

class slist {
friend class slist_iterator;
  slink* last;
public:
  void insert( ent a );
  void append( ent a );
  ent get();
  slist& operator=( slist& );
  ent operator[]( int );
  int size();
  void clear();
  // -----------------------------
  slist()        { last = 0; }
  slist( ent a ) { last = new slink(a,0); last->next = last; }
  ~slist()       { clear(); }
} ;

class slist_iterator {
  slink* ce;
  slist* cs;
public:
  slist_iterator( slist& s ) { cs = &s; ce = cs->last; }
  // ---------------------------------
  ent operator()();
} ;

#endif SLIST_HXX
End of slist.hxx
echo threeVector.hxx 1>&2
cat >threeVector.hxx <<'End of threeVector.hxx'
#include <math.h>

#ifndef THREEVECTOR_HXX
#define THREEVECTOR_HXX

class threeVector 
{
private:
  double comp[3];
public:
  threeVector();
  threeVector( double, double, double );
  threeVector( double* );
  threeVector( threeVector& );
  ~threeVector();
  void        set              ( double, double, double );
  void        set              ( double* );
  double      operator*        ( threeVector& );   // dot product
  threeVector operator^        ( threeVector& );   // cross product
  threeVector operator=        ( threeVector& );
  char        operator==       ( threeVector& );
  char        operator!=       ( threeVector& );
  threeVector operator+        ( threeVector& );
  void        operator+=       ( threeVector& );
  threeVector operator-        ( threeVector& );
  double      operator[]       ( int );            // return component
  double&     operator()       ( int );            // return component
  friend threeVector operator- ( threeVector& );
  double      norm             ();
  threeVector unit             ();                 // returns unit vector
  void        rotate           ( threeVector& v, 
                                 double  theta );  // rotates v through 
                                                   // an angle theta using
                                                   // *this as the axis
  friend threeVector operator* ( double, threeVector& );
  friend threeVector operator* ( threeVector&, double );
         threeVector operator/ ( double );
         threeVector operator*=( double );
         threeVector operator/=( double );
} ;

#endif  THREEVECTOR_HXX
End of threeVector.hxx
echo threeVector.rsc 1>&2
cat >threeVector.rsc <<'End of threeVector.rsc'
#ifndef THREEVECTOR_RSC
#define THREEVECTOR_RSC

#include "threeVector.hxx"

threeVector THRV_buff;

#endif  THREEVECTOR_RSC
End of threeVector.rsc
echo twoVector.hxx 1>&2
cat >twoVector.hxx <<'End of twoVector.hxx'
#include <math.h>

#ifndef TWOVECTOR_HXX
#define TWOVECTOR_HXX

class twoVector 
{
private:
  double comp[2];
public:
  twoVector();
  twoVector( double, double );
  twoVector( double* );
  twoVector( twoVector& );
  ~twoVector();
  void        set              ( double, double );
  void        set              ( double* );
  double      operator*        ( twoVector& );     // dot product
  twoVector   operator=        ( twoVector& );
  char        operator==       ( twoVector& );
  char        operator!=       ( twoVector& );
  twoVector   operator+        ( twoVector& );
  void        operator+=       ( twoVector& );
  twoVector   operator-        ( twoVector& );
  double      operator[]       ( int );            // return component
  double&     operator()       ( int );            // return component
  friend twoVector operator-   ( twoVector& );
  double      norm             ();
  twoVector   unit             ();                 // returns unit vector
  twoVector   rotate           ( double theta );   // rotates through theta
  friend twoVector operator* ( double,     twoVector& );
  friend twoVector operator* ( twoVector&, double );
         twoVector operator/ ( double );
         twoVector operator*=( double );
         twoVector operator/=( double );
} ;

#endif  TWOVECTOR_HXX
End of twoVector.hxx
echo twoVector.rsc 1>&2
cat >twoVector.rsc <<'End of twoVector.rsc'
#ifndef TWOVECTOR_RSC
#define TWOVECTOR_RSC

#include "twoVector.hxx"

twoVector TWOV_buff;

#endif  TWOVECTOR_RSC
End of twoVector.rsc
