Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/GAP/pkg/fplsa/src/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 29.7.2025 mit Größe 246 kB image not shown  

Quelle  fplsa4.c   Sprache: C

 
/************************************************************************/
/*      File fplsa4.c   Last touch January 5, 1999                      */
/*      Calculation of finitely presented Lie superalgebras             */
/*      Version 4 of April 15, 1997.                                    */
/*      e-mail: kornyak@jinr.ru, gerdt@jinr.ru                          */
/*                      Contents                                        */
/*_0    Choice of compilation                                           */
/*_1    System constants                                                */
/*_2    Type definitions                                                */
/*_3    Constants and enumerations                                      */
/*_4    Macrodefinitions                                                */
/*_5    Global variables and arrays                                     */
/*_6    Function descriptions                                           */
/*_6_0    Main and top level functions                                  */
/*_6_1    Pairing functions                                             */
/*_6_2    Substitution (replacing) functions                            */
/*_6_3    Lie and scalar algebra functions                              */
/*_6_4    Scalar polynomial algebraic functions                         */
/*_6_5    Big number functions                                          */
/*_6_6    Copy and delete functions                                     */
/*_6_7    Technical functions                                           */
/*_6_8    Input functions                                               */
/*_6_9    Output functions                                              */
/*_6_10   Debugging functions                                           */
/************************************************************************/


/*_0    Choice of compilation============================================*/

#define RATIONAL_FIELD  /*  Working over the field R ??
                            otherwise over the ring Z */

#define ECHO_TO_SCREEN        /* Echo session to screen ?? */
#define RELATION_N_TO_SCREEN  /* Watch increasing RelationN ?? */
//#define SPP_2000  /* Big ending computer ?? */
#define SPACE_STATISTICS  /* Space statistics ?? */
//#define INTEGER_MAX_SIZE  /* Multiprecision number maximum size ?? */
//#define INTEGER_ALLOCATION_CHECK  /* Control of integer allocations ?? */
//#define POLY_ARRAY_ALLOCATION_CHECK /* Control of allocations of ?? polynomial arrays in stack */

/* GAP output ?? */
/* Avoid message file, session file,                              */
/*       compulsory suffix '.in' for input file,                  */
/*       and printing comments to the screen ?                    */
#define GAP
/**/

//#define DEBUG /* Debugging ?? */
//#define MEMORY /* Check memory balance ?? */

/* Include files */

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#if defined(SPP_2000)
#include <alloca.h>  /* This file the genuine SPP compiler requires */
#endif


#if defined(__GNUC__) || defined(__clang__)
#define ATTRIBUTE_NORETURN  __attribute__ ((noreturn))
#else
#define ATTRIBUTE_NORETURN
#endif


#if defined(DEBUG)  /* Debug definitions ===============================*/

/* Set condition for debug output ??
*/

#define D_CONDITION   if(Debug>=5873)
/*            Examples of D_CONDITION
      `empty' if(Debug>=11951211) current!!
      if(Debug>=25283LU)*e7* *e70*
      if(Debug%10 == 0)  if(Debug>=17566)    */

/* Set condition to stop debugging ??
*/

#define D_EXIT  if(Debug > 5882) EXIT;
/*            Examples of D_EXIT
      `empty' if(Debug > 21420LU) EXIT;
       if(Debug > 26969LU) EXIT;*e7* if(Debug > 21420LU) EXIT;*e70*
       if(Debug > 30881LU) EXIT; if(Debug >= 18399) EXIT;
*/


/* Switches for debugging particular functions ?? */

#define D_CHECK_EXACTNESS_OF_DIVISION
//#define D_ADD_PAIR_TO_LIE_MONOMIAL
#define D_GENERATE_RELATIONS
//#if defined(D_GENERATE_RELATIONS)  /* Put tables ?? */
//#define D_PUT_RELATIONS
//#define D_PUT_LIE_MONOMIAL
//#define D_GET_LIE_MONOMIAL
//#define D_GET_LIE_SUM
//#define D_GET_LIE_TERM
#define D_INTEGER_CANCELLATION
#define D_INTEGER_GCD
#define D_INTEGER_PRODUCT
#define D_INTEGER_QUOTIENT
#define D_INTEGER_SUM
#define D_LIE_SUM_ADDITION
#define D_LIE_SUM_DIV_INTEGER
//#define D_LIE_SUM_DIV_SCALAR_SUM
#define D_LIE_SUM_MULT_INTEGER
//#define D_LIE_SUM_MULT_SCALAR_SUM
#define D_MAKE_RELATION_RHS
//#define D_NEW_JACOBI_RELATION
#define D_NORMALIZE_RELATION
//#define D_PAIR_MONOMIAL_MONOMIAL
//#define D_PAIR_MONOMIAL_SUM
//#define D_PAIR_SUM_MONOMIAL
//#define D_PAIR_SUM_SUM
//#define D_POLY_CONTENT
//#define D_POLY_GCD
//#define D_POLY_QUOTIENT
//#define D_POLY_PSEUDO_REMAINDER
//#define D_SCALAR_SUM_CANCELLATION
#define D_SUBSTITUTE_RELATION_IN_RELATION
#define D_IN_SET     uint debug=Debug;\
                     D_CONDITION\
                       PutDebugHeader(debug, f_name, "in"),
#define D_IN_CLOSE   Debug++; D_EXIT

#define D_OUT_OPEN   D_CONDITION PutDebugHeader(debug, f_name, "out"),

#else      /* Empty definitions for DEBUG off */

#define D_IN_SET
#define D_IN_CLOSE
#define D_OUT_OPEN

#endif

/* Check memory balance definitions */

#if defined(MEMORY)              /* `n_...' are unique */
#define IN_SET_N_LT      int n_lt  = -CurrentNLT;
#define IN_SET_N_INT     int n_int = -CurrentNINT;
#define IN_SET_N_ST      int n_st  = -CurrentNST;
#define IN_SET_N_SF      int n_sf  = -CurrentNSF;

#define OUT_SET_N_LT     n_lt  += CurrentNLT;
#define OUT_SET_N_INT    n_int += CurrentNINT;
#define OUT_SET_N_ST     n_st  += CurrentNST;
#define OUT_SET_N_SF     n_sf  += CurrentNSF;

#define ADD_LIE_SUM_NS(a) \
    AddLieSumNs(a, PLUS, &n_lt, &n_int, &n_st, &n_sf);

#define SUBTRACT_LIE_SUM_NS(a) \
    AddLieSumNs(a, MINUS, &n_lt, &n_int, &n_st, &n_sf);

#define ADD_SCALAR_SUM_NS(a) \
    AddScalarSumNs(a, PLUS, &n_int, &n_st, &n_sf);

#define SUBTRACT_SCALAR_SUM_NS(a) \
    AddScalarSumNs(a, MINUS, &n_int, &n_st, &n_sf);

#define CHECK_NS \
  if(n_lt != 0) {PutNodeBalance("\nNodeLT (Lie terms)",\
                                f_name, n_lt); EXIT;}\
  if(n_int != 0) {PutIntegerBalance(f_name, n_int); EXIT;}\
  if(n_st != 0) {PutNodeBalance("\nNodeST (scalar terms)",\
                                f_name, n_st); EXIT;}\
  if(n_sf != 0) {PutNodeBalance("\nNodeSF (scalar factors)",\
                                f_name, n_sf); EXIT;}

/* Particular functions */
/*----------------------------------------------------------*/
#define M_OUT_GET_LIE_MONOMIAL \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(a)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_OUT_GET_LIE_SUM \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(lsum)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_OUT_GET_LIE_TERM \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(lterm)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_LIE_SUM_ADDITION  \
  ADD_LIE_SUM_NS(a)\
  ADD_LIE_SUM_NS(b)
#define M_OUT_LIE_SUM_ADDITION  \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(sum)\
  CHECK_NS
/*----------------------------------------------------------*/
/*   No sense to print debug information, memory check only */
#define IN_LIE_SUM_COPY  \
    IN_SET_FUNCTION_NAME("LieSumCopy...")\
    IN_SET_NS
#define OUT_LIE_SUM_COPY  \
    OUT_SET_NS\
    SUBTRACT_LIE_SUM_NS(ca)\
    CHECK_NS
/*----------------------------------------------------------*/
/*   No sense to print debug information, memory check only */
#define IN_LIE_SUM_KILL  \
    IN_SET_FUNCTION_NAME("LieSumKill...")\
    IN_SET_NS\
    ADD_LIE_SUM_NS(a)
#define OUT_LIE_SUM_KILL \
    OUT_SET_NS\
    CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_LIE_SUM_DIV_INTEGER  \
  ADD_LIE_SUM_NS(b)
#define M_OUT_LIE_SUM_DIV_INTEGER  \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(b)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_LIE_SUM_DIV_SCALAR_SUM  \
  ADD_LIE_SUM_NS(b)\
  ADD_SCALAR_SUM_NS(den)
#define M_OUT_LIE_SUM_DIV_SCALAR_SUM  \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(b)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_LIE_SUM_MULT_SCALAR_SUM  \
  ADD_LIE_SUM_NS(b)\
  ADD_SCALAR_SUM_NS(num)
#define M_OUT_LIE_SUM_MULT_SCALAR_SUM  \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(b)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_LIE_SUM_MULT_INTEGER  \
  ADD_LIE_SUM_NS(b)
#define M_OUT_LIE_SUM_MULT_INTEGER  M_OUT_LIE_SUM_DIV_INTEGER
/*----------------------------------------------------------*/
#define M_OUT_MAKE_RELATION_RHS    M_OUT_GET_LIE_MONOMIAL
/*----------------------------------------------------------*/
#define M_OUT_NEW_JACOBI_RELATION  M_OUT_GET_LIE_MONOMIAL
/*----------------------------------------------------------*/
#define M_IN_NORMALIZE_RELATION  \
  ADD_LIE_SUM_NS(a)
#define M_OUT_NORMALIZE_RELATION   M_OUT_GET_LIE_MONOMIAL
/*----------------------------------------------------------*/
#define M_OUT_PAIR_MONOMIAL_MONOMIAL  M_OUT_GET_LIE_MONOMIAL
/*----------------------------------------------------------*/
#define M_IN_PAIR_MONOMIAL_SUM  \
  ADD_LIE_SUM_NS(a)
#define M_OUT_PAIR_MONOMIAL_SUM  \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(s)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_PAIR_SUM_MONOMIAL  \
  ADD_LIE_SUM_NS(a)
#define M_OUT_PAIR_SUM_MONOMIAL  \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(s)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_PAIR_SUM_SUM  \
  ADD_LIE_SUM_NS(a)\
  ADD_LIE_SUM_NS(b)
#define M_OUT_PAIR_SUM_SUM  \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(a)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_POLY_CONTENT
#define M_OUT_POLY_CONTENT  \
  OUT_SET_NS\
  SUBTRACT_SCALAR_SUM_NS(b)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_POLY_GCD
#define M_OUT_POLY_GCD  \
  OUT_SET_NS\
  SUBTRACT_SCALAR_SUM_NS(b)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_POLY_QUOTIENT  \
  ADD_SCALAR_SUM_NS(a)\
  ADD_SCALAR_SUM_NS(b)
#define M_OUT_POLY_QUOTIENT  \
  OUT_SET_NS\
  SUBTRACT_SCALAR_SUM_NS(c)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_POLY_PSEUDO_REMAINDER  \
  ADD_SCALAR_SUM_NS(a)\
  ADD_SCALAR_SUM_NS(b)
#define M_OUT_POLY_PSEUDO_REMAINDER  \
  OUT_SET_NS\
  SUBTRACT_SCALAR_SUM_NS(a)\
  CHECK_NS
/*----------------------------------------------------------*/
/*   No sense to print debug information, memory check only */
#define IN_REDUCE_RELATIONS  \
    IN_SET_FUNCTION_NAME("ReduceRelations")\
    IN_SET_NS\
    {\
      int o;\
      for(o = 0; o < RelationN; o++)\
        ADD_LIE_SUM_NS(RELATION_LIE_SUM(o))\
    }
#define OUT_REDUCE_RELATIONS  \
    OUT_SET_NS\
    {\
      int o;\
      for(o = 0; o < RelationN; o++)\
        SUBTRACT_LIE_SUM_NS(RELATION_LIE_SUM(o))\
    }\
    CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_SCALAR_SUM_CANCELLATION  \
  ADD_SCALAR_SUM_NS(*pnum)\
  ADD_SCALAR_SUM_NS(*pden)
#define M_OUT_SCALAR_SUM_CANCELLATION  \
  OUT_SET_NS\
  SUBTRACT_SCALAR_SUM_NS(*pnum)\
  SUBTRACT_SCALAR_SUM_NS(*pden)\
  CHECK_NS
/*----------------------------------------------------------*/
#define M_IN_SUBSTITUTE_RELATION_IN_RELATION  \
  ADD_LIE_SUM_NS(a)
#define M_OUT_SUBSTITUTE_RELATION_IN_RELATION  \
  OUT_SET_NS\
  SUBTRACT_LIE_SUM_NS(a)\
  CHECK_NS

#define  MM_CURRENT_N_LT    ,--CurrentNLT
#define  PP_CURRENT_N_LT    ++CurrentNLT;

#define  MM_CURRENT_N_SF    ,--CurrentNSF
#define  PP_CURRENT_N_SF    ++CurrentNSF;

#define  MM_CURRENT_N_ST    ,--CurrentNST
#define  PP_CURRENT_N_ST    ++CurrentNST;

#define  MM_CURRENT_N_INT   ,--CurrentNINT
#define  PP_CURRENT_N_INT   ;++CurrentNINT

#else       /* MEMORY off */

#define  MM_CURRENT_N_LT
#define  PP_CURRENT_N_LT
#define  MM_CURRENT_N_SF
#define  PP_CURRENT_N_SF
#define  MM_CURRENT_N_ST
#define  PP_CURRENT_N_ST
#define  MM_CURRENT_N_INT
#define  PP_CURRENT_N_INT

#define IN_SET_N_LT
#define IN_SET_N_INT
#define IN_SET_N_ST
#define IN_SET_N_SF

#define OUT_SET_N_LT
#define OUT_SET_N_INT
#define OUT_SET_N_ST
#define OUT_SET_N_SF

#define M_OUT_GET_LIE_MONOMIAL
#define M_OUT_GET_LIE_SUM
#define M_OUT_GET_LIE_TERM
#define M_IN_LIE_SUM_ADDITION
#define M_OUT_LIE_SUM_ADDITION
#define IN_LIE_SUM_COPY
#define OUT_LIE_SUM_COPY
#define IN_LIE_SUM_KILL
#define OUT_LIE_SUM_KILL
#define M_IN_LIE_SUM_DIV_INTEGER
#define M_OUT_LIE_SUM_DIV_INTEGER
#define M_IN_LIE_SUM_DIV_SCALAR_SUM
#define M_OUT_LIE_SUM_DIV_SCALAR_SUM
#define M_IN_LIE_SUM_MULT_SCALAR_SUM
#define M_OUT_LIE_SUM_MULT_SCALAR_SUM
#define M_IN_LIE_SUM_MULT_INTEGER
#define M_OUT_LIE_SUM_MULT_INTEGER
#define M_OUT_MAKE_RELATION_RHS
#define M_OUT_NEW_JACOBI_RELATION
#define M_IN_NORMALIZE_RELATION
#define M_OUT_NORMALIZE_RELATION
#define M_OUT_PAIR_MONOMIAL_MONOMIAL
#define M_IN_PAIR_MONOMIAL_SUM
#define M_OUT_PAIR_MONOMIAL_SUM
#define M_IN_PAIR_SUM_MONOMIAL
#define M_OUT_PAIR_SUM_MONOMIAL
#define M_IN_PAIR_SUM_SUM
#define M_OUT_PAIR_SUM_SUM
#define M_IN_POLY_CONTENT
#define M_OUT_POLY_CONTENT
#define M_IN_POLY_GCD
#define M_OUT_POLY_GCD
#define M_IN_POLY_QUOTIENT
#define M_OUT_POLY_QUOTIENT
#define M_IN_POLY_PSEUDO_REMAINDER
#define M_OUT_POLY_PSEUDO_REMAINDER
#define IN_REDUCE_RELATIONS
#define OUT_REDUCE_RELATIONS
#define M_IN_SCALAR_SUM_CANCELLATION
#define M_OUT_SCALAR_SUM_CANCELLATION
#define M_IN_SUBSTITUTE_RELATION_IN_RELATION
#define M_OUT_SUBSTITUTE_RELATION_IN_RELATION
#endif

#define IN_SET_NS IN_SET_N_LT IN_SET_N_INT IN_SET_N_ST IN_SET_N_SF
#define OUT_SET_NS OUT_SET_N_LT OUT_SET_N_INT OUT_SET_N_ST OUT_SET_N_SF


#if defined(DEBUG) || defined(MEMORY)             /* `f_name' is unique */
#define IN_SET_FUNCTION_NAME(fname) char * f_name = fname;
#else
#define IN_SET_FUNCTION_NAME(fname)
#endif

#if defined(D_ADD_PAIR_TO_LIE_MONOMIAL) /*------------------------------*/
                                        /*   Only debugging makes sense */
#define IN_ADD_PAIR_TO_LIE_MONOMIAL \
    IN_SET_FUNCTION_NAME("AddPairToLieMonomial")\
    D_IN_SET\
      PutDebugLieMonomial("i", i),\
      PutDebugLieMonomial("j", j),\
      PutDebugLieMonomialTable(-1);\
    D_IN_CLOSE

#define OUT_ADD_PAIR_TO_LIE_MONOMIAL_OLD \
    D_OUT_OPEN\
      PutDebugLieMonomial("Old monomial", ijp);
#define OUT_ADD_PAIR_TO_LIE_MONOMIAL_NEW  \
    D_OUT_OPEN\
      PutDebugLieMonomialTable(ijp);
#else
#define IN_ADD_PAIR_TO_LIE_MONOMIAL     D_IN_CLOSE
#define OUT_ADD_PAIR_TO_LIE_MONOMIAL_OLD
#define OUT_ADD_PAIR_TO_LIE_MONOMIAL_NEW
#endif
#if defined(D_GENERATE_RELATIONS) /*-----------------------------------*/
                                       /*   Only debugging makes sense */
#define IN_GENERATE_RELATIONS  \
    IN_SET_FUNCTION_NAME("GenerateRelations")\
    D_IN_SET\
      IN_PUT_RELATIONS\
      IN_PUT_LIE_MONOMIAL\
      PutDebugLieSum("rel", a),\
      PutDebugLieMonomial("gen", gen);\
    D_IN_CLOSE

#define OUT_GENERATE_RELATIONS \
    D_OUT_OPEN\
      PutDebugLieSum("d_rel", a);
#else
#define  IN_GENERATE_RELATIONS     D_IN_CLOSE
#define  OUT_GENERATE_RELATIONS
#endif
#if defined(D_INTEGER_CANCELLATION) /*----- (k*n)/(k*d) -> n/d --------*/
                                    /* Only debugging makes sense      */
#define IN_INTEGER_CANCELLATION \
    IN_SET_FUNCTION_NAME("IntegerCancellation")\
    D_IN_SET\
      PutDebugInteger("num", num),\
      PutDebugInteger("den", den);\
    D_IN_CLOSE
#define OUT_INTEGER_CANCELLATION \
    D_OUT_OPEN\
      PutDebugInteger("num", num),\
      PutDebugInteger("den", den);
#else
#define IN_INTEGER_CANCELLATION    D_IN_CLOSE
#define OUT_INTEGER_CANCELLATION
#endif
#if defined(D_INTEGER_GCD) /*------------------------------------------*/
                                    /* Only debugging makes sense      */
#define IN_INTEGER_GCD  \
    IN_SET_FUNCTION_NAME("IntegerGCD")\
    D_IN_SET\
      PutDebugInteger("u", u),\
      PutDebugInteger("v", v);\
    D_IN_CLOSE
#define OUT_INTEGER_GCD  \
    D_OUT_OPEN\
      PutDebugInteger("GCD", u);
#else
#define IN_INTEGER_GCD       D_IN_CLOSE
#define OUT_INTEGER_GCD
#endif
#if defined(D_INTEGER_PRODUCT)  /*------------- n*m -------------------*/
                                    /* Only debugging makes sense      */
#define IN_INTEGER_PRODUCT  \
    IN_SET_FUNCTION_NAME("IntegerProduct")\
    D_IN_SET\
      PutDebugInteger("u", u),\
      PutDebugInteger("v", v);\
    D_IN_CLOSE
#define OUT_INTEGER_PRODUCT  \
    D_OUT_OPEN\
      PutDebugInteger("u*v", w0);
#else
#define IN_INTEGER_PRODUCT    D_IN_CLOSE
#define OUT_INTEGER_PRODUCT
#endif
#if defined(D_INTEGER_QUOTIENT)  /*------------------------------------*/
                                    /* Only debugging makes sense      */
#define IN_INTEGER_QUOTIENT  \
    IN_SET_FUNCTION_NAME("IntegerQuotient")\
    D_IN_SET\
      PutDebugInteger("a", a),\
      PutDebugInteger("b", b);\
    D_IN_CLOSE
#define OUT_INTEGER_QUOTIENT  \
    D_OUT_OPEN\
      PutDebugInteger("a/b", pm);
#else
#define IN_INTEGER_QUOTIENT    D_IN_CLOSE
#define OUT_INTEGER_QUOTIENT
#endif
#if defined(D_INTEGER_SUM)       /*------------------------------------*/
                                    /* Only debugging makes sense      */
#define IN_INTEGER_SUM  \
    IN_SET_FUNCTION_NAME("IntegerSum")\
    D_IN_SET\
      PutDebugInteger("a", a),\
      PutDebugInteger("b", b);\
    D_IN_CLOSE
#define OUT_INTEGER_SUM  \
    D_OUT_OPEN\
      PutDebugInteger("c", c);
#else
#define IN_INTEGER_SUM    D_IN_CLOSE
#define OUT_INTEGER_SUM
#endif

#if defined(D_GET_LIE_MONOMIAL) /*-------------------------------------*/
#define D_IN_GET_LIE_MONOMIAL   D_IN_SET\
                                  PutDebugString("*pstr", *pstr);\
                                D_IN_CLOSE
#define D_OUT_GET_LIE_MONOMIAL  D_OUT_OPEN\
                                  PutDebugLieSum("a", a);
#else
#define D_IN_GET_LIE_MONOMIAL   D_IN_CLOSE
#define D_OUT_GET_LIE_MONOMIAL
#endif
#if defined(D_GET_LIE_SUM) /*------------------------------------------*/
#define D_IN_GET_LIE_SUM     D_IN_SET\
                               PutDebugString("*pstr", *pstr);\
                             D_IN_CLOSE
#define D_OUT_GET_LIE_SUM    D_OUT_OPEN\
                               PutDebugLieSum("lsum", lsum);
#else
#define D_IN_GET_LIE_SUM     D_IN_CLOSE
#define D_OUT_GET_LIE_SUM
#endif
#if defined(D_GET_LIE_TERM) /*-----------------------------------------*/
#define D_IN_GET_LIE_TERM  D_IN_SET\
                             PutDebugString("*pstr", *pstr);\
                           D_IN_CLOSE
#define D_OUT_GET_LIE_TERM D_OUT_OPEN\
                             PutDebugLieSum("lterm", lterm);
#else
#define D_IN_GET_LIE_TERM  D_IN_CLOSE
#define D_OUT_GET_LIE_TERM
#endif
#if defined(D_LIE_SUM_ADDITION) /*---------- a + b (Lie) --------------*/
#define D_IN_LIE_SUM_ADDITION  D_IN_SET\
                                 PutDebugLieSum("a", a),\
                                 PutDebugLieSum("b", b);\
                               D_IN_CLOSE
#define D_OUT_LIE_SUM_ADDITION D_OUT_OPEN\
                                 PutDebugLieSum("sum", sum);
#else
#define D_IN_LIE_SUM_ADDITION  D_IN_CLOSE
#define D_OUT_LIE_SUM_ADDITION
#endif
#if defined(D_LIE_SUM_DIV_INTEGER)  /*--------- uint/BIGINT ----------------*/
#define D_IN_LIE_SUM_DIV_INTEGER   D_IN_SET\
                                     PutDebugLieSum("lsum", b),\
                                     PutDebugInteger("den", den);\
                                   D_IN_CLOSE
#define D_OUT_LIE_SUM_DIV_INTEGER  D_OUT_OPEN\
                                     PutDebugLieSum("lsum", b);
#else
#define D_IN_LIE_SUM_DIV_INTEGER   D_IN_CLOSE
#define D_OUT_LIE_SUM_DIV_INTEGER
#endif
#if defined(D_LIE_SUM_DIV_SCALAR_SUM)  /*--------- uint/uint --------------*/
#define D_IN_LIE_SUM_DIV_SCALAR_SUM   D_IN_SET\
                                        PutDebugLieSum("lsum", b),\
                                        PutDebugScalarSum("den", den);\
                                      D_IN_CLOSE
#define D_OUT_LIE_SUM_DIV_SCALAR_SUM  D_OUT_OPEN\
                                        PutDebugLieSum("lsum", b);
#else
#define D_IN_LIE_SUM_DIV_SCALAR_SUM   D_IN_CLOSE
#define D_OUT_LIE_SUM_DIV_SCALAR_SUM
#endif
#if defined(D_LIE_SUM_MULT_SCALAR_SUM)  /*--------- uint*uint --------------*/
#define D_IN_LIE_SUM_MULT_SCALAR_SUM   D_IN_SET\
                                         PutDebugLieSum("lsum", b),\
                                         PutDebugScalarSum("num", num);\
                                       D_IN_CLOSE
#define D_OUT_LIE_SUM_MULT_SCALAR_SUM  D_OUT_OPEN\
                                         PutDebugLieSum("lsum", b);
#else
#define D_IN_LIE_SUM_MULT_SCALAR_SUM   D_IN_CLOSE
#define D_OUT_LIE_SUM_MULT_SCALAR_SUM
#endif
#if defined(D_LIE_SUM_MULT_INTEGER)  /*------- uint*BIGINT -----------------*/
#define D_IN_LIE_SUM_MULT_INTEGER   D_IN_SET\
                                      PutDebugLieSum("lsum", b),\
                                      PutDebugInteger("num", num);\
                                    D_IN_CLOSE
#define D_OUT_LIE_SUM_MULT_INTEGER  D_OUT_OPEN\
                                      PutDebugLieSum("lsum", b);
#else
#define D_IN_LIE_SUM_MULT_INTEGER   D_IN_CLOSE
#define D_OUT_LIE_SUM_MULT_INTEGER
#endif
#if defined(D_MAKE_RELATION_RHS)   /*----------------------------------*/
#define D_IN_MAKE_RELATION_RHS     D_IN_SET\
                                     PutDebugLieSum("rel",\
                                         RELATION_LIE_SUM(i));\
                                   D_IN_CLOSE
#define D_OUT_MAKE_RELATION_RHS    D_OUT_OPEN\
                                     PutDebugLieSum("r.h.s", a);
#else
#define D_IN_MAKE_RELATION_RHS     D_IN_CLOSE
#define D_OUT_MAKE_RELATION_RHS
#endif
#if defined(D_NEW_JACOBI_RELATION) /*----------------------------------*/
#define D_IN_NEW_JACOBI_RELATION   D_IN_SET\
                                     PutDebugLieMonomial("l", l);\
                                   D_IN_CLOSE
#define D_OUT_NEW_JACOBI_RELATION  D_OUT_OPEN\
                                     PutDebugLieSum("a", a);
#else
#define D_IN_NEW_JACOBI_RELATION   D_IN_CLOSE
#define D_OUT_NEW_JACOBI_RELATION
#endif
#if defined(D_NORMALIZE_RELATION) /*-----------------------------------*/
#define D_IN_NORMALIZE_RELATION    D_IN_SET\
                                     PutDebugLieSum("a", a);\
                                   D_IN_CLOSE
#define D_OUT_NORMALIZE_RELATION   D_OUT_OPEN\
                                     PutDebugLieSum("a", a);
#else
#define D_IN_NORMALIZE_RELATION    D_IN_CLOSE
#define D_OUT_NORMALIZE_RELATION
#endif
#if defined(D_PAIR_MONOMIAL_MONOMIAL) /*---------[mona, monb]----------*/
#define D_IN_PAIR_MONOMIAL_MONOMIAL    D_IN_SET\
                                         PutDebugLieMonomial("i", i),\
                                         PutDebugLieMonomial("j", j);\
                                       D_IN_CLOSE
#define D_OUT_PAIR_MONOMIAL_MONOMIAL   D_OUT_OPEN\
                                         PutDebugLieSum("a", a);
#else
#define D_IN_PAIR_MONOMIAL_MONOMIAL    D_IN_CLOSE
#define D_OUT_PAIR_MONOMIAL_MONOMIAL
#endif
#if defined(D_PAIR_MONOMIAL_SUM) /*-----------[mon, a]-----------------*/
#define D_IN_PAIR_MONOMIAL_SUM  D_IN_SET\
                                  PutDebugLieMonomial("mon", mon),\
                                  PutDebugLieSum("a", a);\
                                D_IN_CLOSE
#define D_OUT_PAIR_MONOMIAL_SUM D_OUT_OPEN\
                                  PutDebugLieSum("s", s);
#else
#define D_IN_PAIR_MONOMIAL_SUM  D_IN_CLOSE
#define D_OUT_PAIR_MONOMIAL_SUM
#endif
#if defined(D_PAIR_SUM_MONOMIAL) /*-----------[a, mon]-----------------*/
#define D_IN_PAIR_SUM_MONOMIAL  D_IN_SET\
                                  PutDebugLieSum("a", a),\
                                  PutDebugLieMonomial("mon", mon);\
                                D_IN_CLOSE
#define D_OUT_PAIR_SUM_MONOMIAL D_OUT_OPEN\
                                  PutDebugLieSum("s", s);
#else
#define D_IN_PAIR_SUM_MONOMIAL  D_IN_CLOSE
#define D_OUT_PAIR_SUM_MONOMIAL
#endif
#if defined(D_PAIR_SUM_SUM)    /*----------------[a, b]---------------*/
#define D_IN_PAIR_SUM_SUM  D_IN_SET\
                             PutDebugLieSum("a", a),\
                             PutDebugLieSum("b", b);\
                           D_IN_CLOSE
#define D_OUT_PAIR_SUM_SUM D_OUT_OPEN\
                             PutDebugLieSum("a", a);
#else
#define D_IN_PAIR_SUM_SUM    D_IN_CLOSE
#define D_OUT_PAIR_SUM_SUM
#endif
#if defined(D_POLY_CONTENT) /*--------------------------------------------*/
#define D_IN_POLY_CONTENT  D_IN_SET\
                             PutDebugScalarSum("a", a),\
                             PutDebugString("mp", \
                                ParameterName + mp*NameLength1);\
                           D_IN_CLOSE
#define D_OUT_POLY_CONTENT D_OUT_OPEN\
                             PutDebugScalarSum("b", b);
#else
#define D_IN_POLY_CONTENT  D_IN_CLOSE
#define D_OUT_POLY_CONTENT
#endif
#if defined(D_POLY_GCD) /*--------------------------------------------*/
#define D_IN_POLY_GCD  D_IN_SET\
                         PutDebugScalarSum("a", a),\
                         PutDebugScalarSum("b", b);\
                       D_IN_CLOSE
#define D_OUT_POLY_GCD D_OUT_OPEN\
                         PutDebugScalarSum("b", b);
#else
#define D_IN_POLY_GCD    D_IN_CLOSE
#define D_OUT_POLY_GCD
#endif
#if defined(D_POLY_QUOTIENT) /*--------------------------------------------*/
#define D_IN_POLY_QUOTIENT  D_IN_SET\
                              PutDebugScalarSum("a", a),\
                              PutDebugScalarSum("b", b);\
                            D_IN_CLOSE
#define D_OUT_POLY_QUOTIENT D_OUT_OPEN\
                              PutDebugScalarSum("c", c);
#else
#define D_IN_POLY_QUOTIENT    D_IN_CLOSE
#define D_OUT_POLY_QUOTIENT
#endif
#if defined(D_POLY_PSEUDO_REMAINDER) /*------------------------------------*/
#define D_IN_POLY_PSEUDO_REMAINDER  D_IN_SET\
                                      PutDebugScalarSum("a", a),\
                                      PutDebugScalarSum("b", b);\
                                    D_IN_CLOSE
#define D_OUT_POLY_PSEUDO_REMAINDER D_OUT_OPEN\
                                      PutDebugScalarSum("a", a);
#else
#define D_IN_POLY_PSEUDO_REMAINDER  D_IN_CLOSE
#define D_OUT_POLY_PSEUDO_REMAINDER
#endif
#if defined(D_SCALAR_SUM_CANCELLATION) /*----- (k*n)/(k*d) -> n/d ----*/
#define D_IN_SCALAR_SUM_CANCELLATION  D_IN_SET\
                                        PutDebugScalarSum("*pnum", *pnum),\
                                        PutDebugScalarSum("*pden", *pden);\
                                      D_IN_CLOSE
#define D_OUT_SCALAR_SUM_CANCELLATION D_OUT_OPEN\
                                        PutDebugScalarSum("*pnum", *pnum),\
                                        PutDebugScalarSum("*pden", *pden);
#else
#define D_IN_SCALAR_SUM_CANCELLATION    D_IN_CLOSE
#define D_OUT_SCALAR_SUM_CANCELLATION
#endif
#if defined(D_SUBSTITUTE_RELATION_IN_RELATION)  /*--------------------*/
#define D_IN_SUBSTITUTE_RELATION_IN_RELATION  D_IN_SET\
                                                PutDebugLieSum("r", r),\
                                                PutDebugLieSum("a", a);\
                                              D_IN_CLOSE
#define D_OUT_SUBSTITUTE_RELATION_IN_RELATION  D_OUT_OPEN\
                                                 PutDebugLieSum("a", a);
#else
#define D_IN_SUBSTITUTE_RELATION_IN_RELATION  D_IN_CLOSE
#define D_OUT_SUBSTITUTE_RELATION_IN_RELATION
#endif

/* Set INs and OUTs for particular functions */

/*--------------------------------------------------------------------*/
#define IN_GET_LIE_MONOMIAL \
    IN_SET_FUNCTION_NAME("GetLieMonomial")\
    IN_SET_NS\
    D_IN_GET_LIE_MONOMIAL
#define OUT_GET_LIE_MONOMIAL \
    D_OUT_GET_LIE_MONOMIAL\
    M_OUT_GET_LIE_MONOMIAL
/*--------------------------------------------------------------------*/
#define IN_GET_LIE_SUM \
    IN_SET_FUNCTION_NAME("GetLieSum")\
    IN_SET_NS\
    D_IN_GET_LIE_SUM
#define OUT_GET_LIE_SUM \
    D_OUT_GET_LIE_SUM\
    M_OUT_GET_LIE_SUM
/*--------------------------------------------------------------------*/
#define IN_GET_LIE_TERM \
    IN_SET_FUNCTION_NAME("GetLieTerm")\
    IN_SET_NS\
    D_IN_GET_LIE_TERM
#define OUT_GET_LIE_TERM \
    D_OUT_GET_LIE_TERM\
    M_OUT_GET_LIE_TERM
/*--------------------------------------------------------------------*/
#define IN_LIE_SUM_ADDITION  \
    IN_SET_FUNCTION_NAME("LieSumAddition")\
    IN_SET_NS\
    D_IN_LIE_SUM_ADDITION\
    M_IN_LIE_SUM_ADDITION
#define OUT_LIE_SUM_ADDITION  \
    D_OUT_LIE_SUM_ADDITION\
    M_OUT_LIE_SUM_ADDITION
/*--------------------------------------------------------------------*/
#define IN_LIE_SUM_DIV_INTEGER  \
    LS_B_LSUM_DIV_INT\
    IN_SET_FUNCTION_NAME("LieSumDivInteger")\
    IN_SET_NS\
    D_IN_LIE_SUM_DIV_INTEGER\
    M_IN_LIE_SUM_DIV_INTEGER
#define OUT_LIE_SUM_DIV_INTEGER  \
    D_OUT_LIE_SUM_DIV_INTEGER\
    M_OUT_LIE_SUM_DIV_INTEGER
/*--------------------------------------------------------------------*/
#define IN_LIE_SUM_DIV_SCALAR_SUM  \
    LS_B_LSUM_DIV_SS\
    IN_SET_FUNCTION_NAME("LieSumDivScalarSum")\
    IN_SET_NS\
    D_IN_LIE_SUM_DIV_SCALAR_SUM\
    M_IN_LIE_SUM_DIV_SCALAR_SUM
#define OUT_LIE_SUM_DIV_SCALAR_SUM  \
    D_OUT_LIE_SUM_DIV_SCALAR_SUM\
    M_OUT_LIE_SUM_DIV_SCALAR_SUM
/*--------------------------------------------------------------------*/
#define IN_LIE_SUM_MULT_SCALAR_SUM  \
    LS_B_LSUM_MULT_SS\
    IN_SET_FUNCTION_NAME("LieSumMultScalarSum")\
    IN_SET_NS\
    D_IN_LIE_SUM_MULT_SCALAR_SUM\
    M_IN_LIE_SUM_MULT_SCALAR_SUM
#define OUT_LIE_SUM_MULT_SCALAR_SUM  \
    D_OUT_LIE_SUM_MULT_SCALAR_SUM\
    M_OUT_LIE_SUM_MULT_SCALAR_SUM
/*--------------------------------------------------------------------*/
#define IN_LIE_SUM_MULT_INTEGER  \
    LS_B_LSUM_MULT_INT\
    IN_SET_FUNCTION_NAME("LieSumMultInteger")\
    IN_SET_NS\
    D_IN_LIE_SUM_MULT_INTEGER\
    M_IN_LIE_SUM_MULT_INTEGER
#define OUT_LIE_SUM_MULT_INTEGER  \
    D_OUT_LIE_SUM_MULT_INTEGER\
    M_OUT_LIE_SUM_MULT_INTEGER
/*--------------------------------------------------------------------*/
#define IN_MAKE_RELATION_RHS \
    IN_SET_FUNCTION_NAME("MakeRelationRHS...")\
    IN_SET_NS\
    D_IN_MAKE_RELATION_RHS
#define OUT_MAKE_RELATION_RHS \
    D_OUT_MAKE_RELATION_RHS\
    M_OUT_MAKE_RELATION_RHS
/*--------------------------------------------------------------------*/
#define IN_NEW_JACOBI_RELATION  \
    IN_SET_FUNCTION_NAME("NewJacobiRelation")\
    IN_SET_NS\
    D_IN_NEW_JACOBI_RELATION
#define OUT_NEW_JACOBI_RELATION  \
    D_OUT_NEW_JACOBI_RELATION\
    M_OUT_NEW_JACOBI_RELATION
/*--------------------------------------------------------------------*/
#define IN_NORMALIZE_RELATION  \
    IN_SET_FUNCTION_NAME("NormalizeRelation...")\
    IN_SET_NS\
    D_IN_NORMALIZE_RELATION\
    M_IN_NORMALIZE_RELATION
#define OUT_NORMALIZE_RELATION  \
    D_OUT_NORMALIZE_RELATION\
    M_OUT_NORMALIZE_RELATION
/*--------------------------------------------------------------------*/
#define IN_PAIR_MONOMIAL_MONOMIAL  \
    IN_SET_FUNCTION_NAME("PairMonomialMonomial...")\
    IN_SET_NS\
    D_IN_PAIR_MONOMIAL_MONOMIAL
#define OUT_PAIR_MONOMIAL_MONOMIAL  \
    D_OUT_PAIR_MONOMIAL_MONOMIAL\
    M_OUT_PAIR_MONOMIAL_MONOMIAL
/*--------------------------------------------------------------------*/
#define IN_PAIR_MONOMIAL_SUM  \
    IN_SET_FUNCTION_NAME("PairMonomialSum...")\
    IN_SET_NS\
    D_IN_PAIR_MONOMIAL_SUM\
    M_IN_PAIR_MONOMIAL_SUM
#define OUT_PAIR_MONOMIAL_SUM  \
    D_OUT_PAIR_MONOMIAL_SUM\
    M_OUT_PAIR_MONOMIAL_SUM
/*--------------------------------------------------------------------*/
#define IN_PAIR_SUM_MONOMIAL  \
    IN_SET_FUNCTION_NAME("PairSumMonomial...")\
    IN_SET_NS\
    D_IN_PAIR_SUM_MONOMIAL\
    M_IN_PAIR_SUM_MONOMIAL
#define OUT_PAIR_SUM_MONOMIAL  \
    D_OUT_PAIR_SUM_MONOMIAL\
    M_OUT_PAIR_SUM_MONOMIAL
/*--------------------------------------------------------------------*/
#define IN_PAIR_SUM_SUM  \
    IN_SET_FUNCTION_NAME("PairSumSum...")\
    IN_SET_NS\
    D_IN_PAIR_SUM_SUM\
    M_IN_PAIR_SUM_SUM
#define OUT_PAIR_SUM_SUM  \
    D_OUT_PAIR_SUM_SUM\
    M_OUT_PAIR_SUM_SUM
/*--------------------------------------------------------------------*/
#define IN_POLY_CONTENT  \
    IN_SET_FUNCTION_NAME("PolyContent")\
    IN_SET_NS\
    D_IN_POLY_CONTENT\
    M_IN_POLY_CONTENT
#define OUT_POLY_CONTENT  \
    D_OUT_POLY_CONTENT\
    M_OUT_POLY_CONTENT
/*--------------------------------------------------------------------*/
#define IN_POLY_GCD  \
    IN_SET_FUNCTION_NAME("PolyGCD")\
    IN_SET_NS\
    D_IN_POLY_GCD\
    M_IN_POLY_GCD
#define OUT_POLY_GCD  \
    D_OUT_POLY_GCD\
    M_OUT_POLY_GCD
/*--------------------------------------------------------------------*/
#define IN_POLY_QUOTIENT  \
    IN_SET_FUNCTION_NAME("PolyQuotient")\
    IN_SET_NS\
    D_IN_POLY_QUOTIENT\
    M_IN_POLY_QUOTIENT
#define OUT_POLY_QUOTIENT  \
    D_OUT_POLY_QUOTIENT\
    M_OUT_POLY_QUOTIENT
/*--------------------------------------------------------------------*/
#define IN_POLY_PSEUDO_REMAINDER  \
    IN_SET_FUNCTION_NAME("PolyPseudoRemainder")\
    IN_SET_NS\
    D_IN_POLY_PSEUDO_REMAINDER\
    M_IN_POLY_PSEUDO_REMAINDER
#define OUT_POLY_PSEUDO_REMAINDER  \
    D_OUT_POLY_PSEUDO_REMAINDER\
    M_OUT_POLY_PSEUDO_REMAINDER
/*--------------------------------------------------------------------*/
#define IN_SCALAR_SUM_CANCELLATION  \
    IN_SET_FUNCTION_NAME("ScalarSumCancellation")\
    IN_SET_NS\
    D_IN_SCALAR_SUM_CANCELLATION\
    M_IN_SCALAR_SUM_CANCELLATION
#define OUT_SCALAR_SUM_CANCELLATION  \
    D_OUT_SCALAR_SUM_CANCELLATION\
    M_OUT_SCALAR_SUM_CANCELLATION
/*--------------------------------------------------------------------*/
#define IN_SUBSTITUTE_RELATION_IN_RELATION  \
    IN_SET_FUNCTION_NAME("SubstituteRelationInRelation...")\
    IN_SET_NS\
    D_IN_SUBSTITUTE_RELATION_IN_RELATION\
    M_IN_SUBSTITUTE_RELATION_IN_RELATION
#define OUT_SUBSTITUTE_RELATION_IN_RELATION  \
    D_OUT_SUBSTITUTE_RELATION_IN_RELATION\
    M_OUT_SUBSTITUTE_RELATION_IN_RELATION
/* Conditional print of Relation and Monomial tables */

#if defined(D_PUT_RELATIONS)   /*-------------------------------------*/
#define IN_PUT_RELATIONS       PutDebugRelations(),
#define OUT_PUT_RELATIONS      D_CONDITION PutDebugRelations();
#else
#define IN_PUT_RELATIONS
#define OUT_PUT_RELATIONS
#endif

#if defined(D_PUT_LIE_MONOMIAL)   /*-------------------------------------*/
#define IN_PUT_LIE_MONOMIAL       PutDebugLieMonomialTable(-1),
#define OUT_PUT_LIE_MONOMIAL      D_CONDITION PutDebugLieMonomialTable(-1);
#else
#define IN_PUT_LIE_MONOMIAL
#define OUT_PUT_LIE_MONOMIAL
#endif

#if defined(D_LIE_SUM_DIV_INTEGER) || defined(MEMORY)
#define LS_B_LSUM_DIV_INT  uint b = lsum; /* For "LieSumDivInteger" */
#else
#define LS_B_LSUM_DIV_INT
#endif
#if defined(D_LIE_SUM_MULT_INTEGER) || defined(MEMORY)
#define LS_B_LSUM_MULT_INT  uint b = lsum; /* For "LieSumMultInteger" */
#else
#define LS_B_LSUM_MULT_INT
#endif
#if defined(D_LIE_SUM_DIV_SCALAR_SUM) || defined(MEMORY)
#define LS_B_LSUM_DIV_SS  uint b = lsum; /* For "LieSumDivScalarSum" */
#else
#define LS_B_LSUM_DIV_SS
#endif
#if defined(D_LIE_SUM_MULT_SCALAR_SUM) || defined(MEMORY)
#define LS_B_LSUM_MULT_SS  uint b = lsum; /* For "LieSumMultScalarSum" */
#else
#define LS_B_LSUM_MULT_SS
#endif

/* Test of char functions ?? */
//#define TEST_FUNCTION

#if defined(INTEGER_ALLOCATION_CHECK)
#define INTEGER_IN_STACK(n) ;if((n)==NULL) Error(E_A_STACK_INTEGER)
#define INTEGER_IN_HEAP(n)  ;if((n)==NULL) Error(E_A_HEAP_INTEGER) \
                            PP_CURRENT_N_INT
#else
#define INTEGER_IN_STACK(n)
#define INTEGER_IN_HEAP(n)  PP_CURRENT_N_INT
#endif

#if defined(POLY_ARRAY_ALLOCATION_CHECK)
#define POLY_ARRAY_IN_STACK(a) ;if((a)==NULL) Error(E_A_STACK_POLY_ARRAY)
#else
#define POLY_ARRAY_IN_STACK(a)
#endif

/*_1    System constants=================================================*/

#define NIL                                           (0u)
#define NOTHING                                     (~NIL)

#define INTEGER_SIGN_MASK                   ((LIMB)0x8000)
                      /* 1 << 15 or 0000 0000 0000 0001 */
#define INTEGER_N_LIMBS_MASK  ((LIMB)(~INTEGER_SIGN_MASK))
                                 /* 1111 1111 1111 1110 */
#define BITS_PER_LIMB                                 (16)
#define BASE_LIMB                              (0x10000lu)
#define MAX_LIMB                                 (0xFFFFu)
#define FIRST_GENUINE_PARAMETER  1 /* Skip i number */

/*_2    Type definitions================================================*/

typedef unsigned char byte;
typedef unsigned short LIMB; /* Limb of big integer */
typedef LIMB * BIGINT;  /* (Pointer to) big integer array */
typedef unsigned int uint;

/* Element of LieMonomial table */

typedef struct
{
  int order;       /* Order of this position element */
  int position;    /* Position of this order */
  int left;        /* (Position of) left submonomial of Lie bracket */
                   /* or ~(index of generator) if not commutator */
  int right;       /* (Position of) right submonomial of Lie bracket  */
                   /* or 1 for 1st generator and 0 for nexts */
  struct
  {
    uint parity : 1;
    int index : 23;  /* Index if basis element or */
                   /* ~(index of relation with leading ordinal) */
                   /* Number of relations < 4194303 */
    uint weight : 8;  /* Weight of Lie monomial < 256 */
  } info;
} LIE_MON;

/* Element of NodeLT pool for Lie terms */

typedef struct
{
  int monomial;   /* (Position of) Lie monomial in LieMonomial table */
  union
  {
    uint  scalar_sum;
    BIGINT integer;
  } numerator;
  union
  {
    uint  scalar_sum;
    BIGINT integer;
  } denominator;  /* Pointer to next Lie term */
  uint rptr;
} NODE_LT;

/* Element of NodeSF pool for scalar factors */

typedef struct
{
#if defined(SPP_2000)
  byte parameter; /* Parameter ordinal   */
  byte degree;    /* Degree of parameter */
#else
  byte degree;    /* Degree of parameter */
  byte parameter; /* Parameter ordinal   */
#endif
  uint   rptr;      /* Pointer to next parametric factor */
} NODE_SF;

/* Element of NodeST pool for scalar terms */

typedef struct
{
  uint  monomial;  /* Scalar monomial */
  BIGINT numerator; /* Integer coefficient */
  uint  rptr;      /* Pointer to next parametric term */
} NODE_ST;

/* Element of Relation table */

typedef struct
{
  uint    lie_sum;           /* Expression of relation (Lie sum) */
  byte  min_generator;     /* Minimal generator for differentiation */
  byte to_be_substituted; /* YES if relation must be substituted */
} REL;                     /* into higher relations */

/*_3    Constants and enumerations======================================*/

/* Enumeration constants */

enum boolean {NO = 0, YES = 1};
enum signs {PLUS = 0, MINUS = 1};
enum parity {EVEN = 0, ODD = 1};
enum orders {ORDER12 = -1, ORDER11 = 0, ORDER21 = 1};
enum scalar_types   /* Types of scalar factors */
{
  I_NUMBER  =  0
};
enum init_file_cases   /* Initiating file fplsa4.ini (fplsa416.ini) */
{
  COEFFICIENT_SUM_TABLE_SIZE =  0,
  CRUDE_TIME                 =  1,
  ECHO_INPUT_FILE            =  2,
  EVEN_BASIS_SYMBOL          =  3,
  GAP_ALGEBRA_NAME           =  4,
  GAP_BASIS_NAME             =  5,
  GAP_RELATIONS_NAME         =  6,
  GAP_OUTPUT_BASIS           =  7,
  GAP_OUTPUT_COMMUTATORS     =  8,
  GAP_OUTPUT_RELATIONS       =  9,
  GENERATOR_MAX_N            = 10,
  INPUT_DIRECTORY            = 11,
  INPUT_INTEGER_SIZE         = 12,
  INPUT_STRING_SIZE          = 13,
  LEFT_NORMED_OUTPUT         = 14,
  LIE_MONOMIAL_SIZE          = 15,
  LINE_LENGTH                = 16,
  NAME_LENGTH                = 17,
  NODE_LT_SIZE               = 18,
  NODE_SF_SIZE               = 19,
  NODE_ST_SIZE               = 20,
  ODD_BASIS_SYMBOL           = 21,
  OUT_LINE_SIZE              = 22,
  PARAMETER_MAX_N            = 23,
  PUT_BASIS_ELEMENTS         = 24,
  PUT_COMMUTATORS            = 25,
  PUT_HILBERT_SERIES         = 26,
  PUT_INITIAL_RELATIONS      = 27,
  PUT_NON_ZERO_COEFFICIENTS  = 28,
  PUT_PROGRAM_HEADING        = 29,
  PUT_REDUCED_RELATIONS      = 30,
  PUT_STATISTICS             = 31,
  RELATION_SIZE              = 32,
  N_INIT_CASES               = 33
};
enum input_file_cases   /* Items of input files */
{
  GENERATORS      = 0,
  LIMITING_WEIGHT = 1,
  PARAMETERS      = 2,
  RELATIONS       = 3,
  WEIGHTS         = 4,
  N_INPUT_CASES   = 5
};
enum messages
{
  /* Head messages */

  H_PROGRAM               =  0,
  H_ENTER_FILE            =  1,
  H_INPUT_FILE            =  2,
  H_CREATE_NEW_FILE       =  3,
  H_ENTER_GENERATORS      =  4,
  H_ENTER_WEIGHTS_IN_FILE =  5,
  H_ENTER_LIMITING_WEIGHT =  6,
  H_ENTER_PARAMETERS      =  7,
  H_ENTER_RELATIONS       =  8,
  H_SHOW_INPUT            =  9,
  H_IN_RELATIONS          = 10,
  H_NON_ZERO_COEFFICIENTS = 11,
  H_REDUCED_RELATIONS     = 12,
  H_BASIS_ELEMENTS        = 13,
  H_HILBERT_SERIES        = 14,
  H_COMMUTATORS           = 15,
  H_NO_PUT_COMMUTATORS    = 16,

  /* Error messages */

  ERROR                            = 17,
  E_WRONG_INI_CASE                 = 18,
  E_WRONG_INPUT_CASE               = 19,
  E_CANCEL_PROGRAM                 = 20,
  E_UNEXPECTED_EOF                 = 21,
  E_A_GENERATOR_NAME               = 22,
  E_A_PARAMETER_NAME               = 23,
  E_A_OUT_LINE                     = 24,
  E_A_RELATION                     = 25,
  E_A_LIE_MONOMIAL                 = 26,
  E_A_NODE_LT                      = 27,
  E_A_NODE_ST                      = 28,
  E_A_NODE_SF                      = 29,
  E_A_HEAP_INTEGER                 = 30,
  E_A_COEFF_PARA_TABLE             = 31,
  E_A_COEFF_SUM_TABLE              = 32,
  E_ALLOC                          = 33,
  E_A_STACK_INPUT_STRING           = 34,
  E_A_STACK_INTEGER                = 35,
  E_A_STACK_INTEGER_DECIMAL_STRING = 36,
  E_A_STACK_POLY_ARRAY             = 37,
  E_INPUT_STRING_SIZE              = 38,
  E_OUT_LINE_SIZE                  = 39,
  E_LIE_MONOMIAL_SIZE              = 40,
  E_RELATION_SIZE                  = 41,
  E_NODE_LT_SIZE                   = 42,
  E_NODE_SF_SIZE                   = 43,
  E_NODE_ST_SIZE                   = 44,
  E_COEFF_SUM_TABLE_SIZE           = 45,
  E_GENERATOR_MAX_N                = 46,
  E_PARAMETER_MAX_N                = 47,
  E_TOO_MUCH_INPUT_WEIGHTS         = 48,
  E_NON_NUM_INPUT_WEIGHT           = 49,
  E_NO_R_PARENTHESIS               = 50,
  E_NO_GENERAL_POWER               = 51,
  E_UNDECLARED_GENERATOR           = 52,
  E_NO_COMMUTATOR_COMMA            = 53,
  E_NO_COMMUTATOR_BRACKET          = 54,
  E_INVALID_CHARACTER              = 55,
  E_MESSAGE                        = 56
};

/* Constants for input and output */

#define LEFT_COMMENT              '<'  /* In *.ini and input files */
#define RIGHT_COMMENT             '>'
#define SUBSCRIPT_INPUT_SIGN   '_'
#define ODD_GENERATOR_INPUT_SIGN  '-'  /* At input */

#define LEVEL                   '\xFF'
#define MAIN_LEVEL              '\x2'
#define MARGIN                  (LEVEL-1)

#define CASE_STRING_SIZE      256    /* Size of string to match case */
#define GAP_NAME_SIZE          64    /* Including ending '\0' */
#define GAP_WIDTH              79    /* Width of GAP page */

/*_4    Macrodefinitions==================================================*/
#define COUNT_LEADING_ZERO_BITS_IN_LIMB(n,w) n=CountLeadingZeroBitsInLimb((LIMB)(w))
#if 0 /* ?? Exclude the macro: the above function is slightly faster */
#define COUNT_LEADING_ZERO_BITS_IN_LIMB(n, w)  (n) = (w);\
                                          if((n) >= 0x100) \
                                            if((n) >= 0x1000) \
                                              if((n) >= 0x4000) \
                                                if((n) >= 0x8000) \
                                                  (n) = 0; \
                                                else \
                                                  (n) = 1; \
                                              else \
                                                if((n) >= 0x2000) \
                                                  (n) = 2; \
                                                else \
                                                  (n) = 3; \
                                            else \
                                              if((n) >= 0x400) \
                                                if((n) >= 0x800) \
                                                  (n) = 4; \
                                                else \
                                                  (n) = 5; \
                                              else \
                                                if((n) >= 0x200) \
                                                  (n) = 6; \
                                                else \
                                                  (n) = 7; \
                                          else \
                                            if((n) >= 0x10) \
                                              if((n) >= 0x40) \
                                                if((n) >= 0x80) \
                                                  (n) = 8; \
                                                else \
                                                  (n) = 9; \
                                              else \
                                                if((n) >= 0x20) \
                                                  (n) = 10; \
                                                else \
                                                  (n) = 11; \
                                            else \
                                              if((n) >= 0x4) \
                                                if((n) >= 0x8) \
                                                  (n) = 12; \
                                                else \
                                                  (n) = 13; \
                                              else \
                                                if((n) >= 0x2) \
                                                  (n) = 14; \
                                                else \
                                                  if((n)) \
                                                    (n) = 15; \
                                                  else \
                                                    (n) = 16
#endif

#define CUT_ARRAY(arr, type, n) (arr)=(type *)realloc(arr,sizeof(type)*(n))

#define EXIT     do { TIME_OFF; PutStatistics(); exit(1); } while(0)

#define IN_LINE_MARGIN    OutLine[++PosOutLine]=MARGIN

#define INTEGER_MINUS(ia)  do {  if(INTEGER_IS_NEGATIVE(ia))\
                                   (ia)[0] &= INTEGER_N_LIMBS_MASK;\
                                 else\
                                   (ia)[0] |= INTEGER_SIGN_MASK; } while(0)
#define INTEGER_IS_NEGATIVE(ia)  (((ia)[0]&INTEGER_SIGN_MASK)!=0)
#define INTEGER_IS_POSITIVE(ia)  (((ia)[0]&INTEGER_SIGN_MASK)==0)

#define INTEGER_IS_UNIT(ia)  (((ia)[0]==1) && ((ia)[1]==1))
#define INTEGER_IS_UNIT_ABS(ia)  ((((ia)[0]&INTEGER_N_LIMBS_MASK)==1) &&\
                              ((ia)[1]==1))
#define INTEGER_IS_NOT_UNIT(ia)  (((ia)[0]!=1) || ((ia)[1]!=1))
#define INTEGER_IS_NOT_UNIT_ABS(ia)  ((((ia)[0]&INTEGER_N_LIMBS_MASK)!=1) ||\
                                  ((ia)[1]!=1))
#define INTEGER_N_LIMBS(ia)  ((ia)[0]&INTEGER_N_LIMBS_MASK)

#define INTEGER_SET_MINUS(ia)       (ia)[0] |= INTEGER_SIGN_MASK
#define INTEGER_SET_PLUS(ia)        (ia)[0] &= INTEGER_N_LIMBS_MASK
#define INTEGER_SIGN(ia)            ((ia)[0]&INTEGER_SIGN_MASK)

#define INTEGER_HEAP_NEW(n,i)       (n)=(BIGINT)malloc(sizeof(LIMB)*(i))\
                                    INTEGER_IN_HEAP(n)
#define INTEGER_HEAP_COPY(n,o,i)    (i)=INTEGER_N_LIMBS(o);\
                                    INTEGER_HEAP_NEW(n,++(i));\
                                    do{(i)--; (n)[i] = (o)[i];}while(i)
#define INTEGER_HEAP_COPY_DOUBLE_1(n1,n2,o,i) \
                                    (i)=INTEGER_N_LIMBS(o);\
                                    INTEGER_HEAP_NEW(n1,++(i)+1);\
                                    INTEGER_HEAP_NEW(n2,i);\
                                    do{(i)--; (n1)[i] = (n2)[i] = (o)[i];}\
                                    while(i)
#define INTEGER_KILL(bn)            free(bn) MM_CURRENT_N_INT


#define INTEGER_STACK_NEW(n,i)      (n)=(BIGINT)alloca(sizeof(LIMB)*(i))\
                                    INTEGER_IN_STACK(n)

#define INTEGER_STACK_COPY(n,o,i)   (i)=INTEGER_N_LIMBS(o);\
                                    INTEGER_STACK_NEW(n,++(i));\
                                    do{(i)--; (n)[i] = (o)[i];}while(i)

#define INTEGER_STACK_COPY_1(n,o,i) (i)=INTEGER_N_LIMBS(o);\
                                    INTEGER_STACK_NEW(n,++(i)+1);\
                                    do{(i)--; (n)[i] = (o)[i];}while(i)

#define LIE_MONOMIAL_I_RELATION(pos)    (~LIE_MONOMIAL_INDEX(pos))
#define LIE_MONOMIAL_INDEX_BY_ORDER(ord) \
                         LIE_MONOMIAL_INDEX(LIE_MONOMIAL_POSITION(ord))
#define LIE_MONOMIAL_IS_EVEN(pos)       (LIE_MONOMIAL_PARITY(pos)==EVEN)
#define LIE_MONOMIAL_IS_LEADING_BY_ORDER(ord) \
                    LIE_MONOMIAL_IS_LEADING(LIE_MONOMIAL_POSITION(ord))
#define LIE_MONOMIAL_IS_OCCUPIED(pos)   LIE_MONOMIAL_WEIGHT(pos)
#define LIE_MONOMIAL_IS_GENERATOR(pos)  ((pos) < GeneratorN)
#define LIE_MONOMIAL_IS_GENERATOR_BY_ORDER(ord) \
                              (LIE_MONOMIAL_POSITION(ord) < GeneratorN)
#define LIE_MONOMIAL_IS_COMMUTATOR(pos) ((pos) >= GeneratorN)
#define LIE_MONOMIAL_IS_ODD(pos)        LIE_MONOMIAL_PARITY(pos)
#define LIE_MONOMIAL_IS_SQUARE(pos)     (LIE_MONOMIAL_LEFT(pos)==\
                                         LIE_MONOMIAL_RIGHT(pos))
#define LIE_MONOMIAL_IS_NOT_SQUARE(pos)  (LIE_MONOMIAL_LEFT(pos)!=\
                                          LIE_MONOMIAL_RIGHT(pos))
#define LIE_MONOMIAL_LEFT(pos)          (LieMonomial[pos].left)
#define LIE_MONOMIAL_RIGHT(pos)         (LieMonomial[pos].right)
#define LIE_MONOMIAL_ORDER(pos)         (LieMonomial[pos].order)
#define LIE_MONOMIAL_LEFT_ORDER(pos)   \
                      LIE_MONOMIAL_ORDER(LIE_MONOMIAL_LEFT(pos))
#define LIE_MONOMIAL_RIGHT_ORDER(pos)   \
                      LIE_MONOMIAL_ORDER(LIE_MONOMIAL_RIGHT(pos))
#define LIE_MONOMIAL_POSITION(ord)      (LieMonomial[ord].position)
#define LIE_MONOMIAL_WEIGHT_BY_ORDER(ord) \
                      LIE_MONOMIAL_WEIGHT(LIE_MONOMIAL_POSITION(ord))
#define LIE_MONOMIAL_INDEX(pos)         (LieMonomial[pos].info.index)
#define LIE_MONOMIAL_IS_BASIS(pos)      (LieMonomial[pos].info.index >= 0)
#define LIE_MONOMIAL_IS_LEADING(pos)    (LieMonomial[pos].info.index < 0)
#define LIE_MONOMIAL_PARITY(pos)        (LieMonomial[pos].info.parity)
#define LIE_MONOMIAL_WEIGHT(pos)        (LieMonomial[pos].info.weight)

#define LIE_TERM_MONOMIAL(a)               (NodeLT[a].monomial)
#define LIE_TERM_MONOMIAL_ORDER(a)         LIE_MONOMIAL_ORDER(\
                                             (NodeLT[a].monomial))
#define LIE_TERM_R(a)                      (NodeLT[a].rptr)
#define LIE_TERM_NUMERATOR_INTEGER(a)      (NodeLT[a].numerator.integer)
#define LIE_TERM_MINUS_INTEGER(a) \
                        INTEGER_MINUS(NodeLT[a].numerator.integer)
#define LIE_TERM_NUMERATOR_SCALAR_SUM(a)   (NodeLT[a].numerator.scalar_sum)
#define LIE_TERM_DENOMINATOR_INTEGER(a)    (NodeLT[a].denominator.integer)
#define LIE_TERM_DENOMINATOR_SCALAR_SUM(a) (NodeLT[a].denominator.scalar_sum)

#define MAX(a,b)    (((a) > (b)) ? (a) : (b))

#define NODE_LT_KILL(a)    LIE_TERM_R(a)=NodeLTTop,NodeLTTop=(a)\
                                                     MM_CURRENT_N_LT
#define NODE_SF_KILL(a)    SCALAR_FACTOR_R(a)=NodeSFTop,NodeSFTop=(a)\
                                                        MM_CURRENT_N_SF
#define NODE_ST_KILL(a)    SCALAR_TERM_R(a)=NodeSTTop,NodeSTTop=(a)\
                                                      MM_CURRENT_N_ST

#define RELATION_LIE_SUM(i)           (Relation[i].lie_sum)
#define RELATION_MIN_GENERATOR(i)     (Relation[i].min_generator)
#define RELATION_TO_BE_SUBSTITUTED(i) (Relation[i].to_be_substituted)

#define SCALAR_SUM_IS_UNIT(a)  (SCALAR_TERM_MONOMIAL(a)==NIL&&\
                                INTEGER_IS_UNIT(SCALAR_TERM_NUMERATOR(a)))

#define SCALAR_SUM_IS_UNIT_ABS(a)  (SCALAR_TERM_MONOMIAL(a)==NIL&&\
                              INTEGER_IS_UNIT_ABS(SCALAR_TERM_NUMERATOR(a)))

#define SCALAR_SUM_IS_NOT_UNIT(a)  (SCALAR_TERM_MONOMIAL(a)!=NIL||\
                                    INTEGER_IS_NOT_UNIT(\
                                          SCALAR_TERM_NUMERATOR(a)))

#define SCALAR_TERM_MONOMIAL(a)  (NodeST[a].monomial)
#define SCALAR_TERM_NUMERATOR(a) (NodeST[a].numerator)
#define SCALAR_TERM_R(a)         (NodeST[a].rptr)

#define SCALAR_FACTOR_PARAMETER(a)    (NodeSF[a].parameter)
#define SCALAR_FACTOR_IS_I_NUMBER(a)  (NodeSF[a].parameter==I_NUMBER)
#define SCALAR_FACTOR_DEGREE(a)       (NodeSF[a].degree)
#define SCALAR_FACTOR_WORD(a)         (*(unsigned short *)(NodeSF+(a)))
#define SCALAR_FACTOR_R(a)            (NodeSF[a].rptr)

#define SCALAR_TERM_MINUS(a)  INTEGER_MINUS(NodeST[a].numerator)
#define SCALAR_TERM_MAIN_PARAMETER(a) \
                           SCALAR_FACTOR_PARAMETER(SCALAR_TERM_MONOMIAL(a))
#define SCALAR_TERM_MAIN_PARAMETER_WORD(a) \
                                SCALAR_FACTOR_WORD(SCALAR_TERM_MONOMIAL(a))
#define SCALAR_TERM_MAIN_DEGREE(a) \
                              SCALAR_FACTOR_DEGREE(SCALAR_TERM_MONOMIAL(a))
#define POLY_MAIN_PARAMETER(a) ((SCALAR_TERM_MONOMIAL(a)==NIL) ? -1 :\
                          SCALAR_FACTOR_PARAMETER(SCALAR_TERM_MONOMIAL(a)))
#define POLY_ARRAY_STACK_NEW(a,n)   (a)=(uint*)alloca(sizeof(uint)*(n))\
                                    POLY_ARRAY_IN_STACK(a)

#define TIME_OFF  TimeC += (CrudeTime ? time(NULL) : clock()) - TimeA
#define TIME_ON   TimeA = (CrudeTime ? time(NULL) : clock())

/*_5    Global variables and arrays=====================================*/

/* Files */

#if !defined(GAP)
FILE *MessageFile;
FILE *SessionFile;
#endif

/* Single variables */

int IncompletedBasis;
int IncompletedRelations;
int IsParametric;
int LieMonomialIsNew;
int SubstitutionIsDone;
uint LimitingWeight;
int GeneratorN;
int ParameterN;

/* Arrays */

LIE_MON *LieMonomial;    /* Set of Lie monomials */
int LieMonomialSize;
int LieMonomialN;
int LieMonomialFreePosition; /* Start search of free position */
#if defined(SPACE_STATISTICS)
int LieMonomialMaxN;
#endif


NODE_LT *NodeLT;         /* Pool of nodes for Lie terms */
uint NodeLTSize;
uint NodeLTTop = 1;
#if defined(SPACE_STATISTICS)
uint NodeLTTopMax;
#endif

NODE_SF *NodeSF;         /* Pool of nodes for scalar factors */
uint NodeSFSize;
uint NodeSFTop = 1;
#if defined(SPACE_STATISTICS)
uint NodeSFTopMax;
#endif

NODE_ST *NodeST;         /* Pool of nodes for scalar terms */
uint NodeSTSize;
uint NodeSTTop = 1;
#if defined(SPACE_STATISTICS)
uint NodeSTTopMax;
#endif

REL *Relation;           /* Ordered set of relations */
int RelationSize;
int RelationN;
#if defined(SPACE_STATISTICS)
int MaxNRelation;
#endif
#if defined(INTEGER_MAX_SIZE)
LIMB IntegerMaxSize;
#endif

int CoeffSumTableSize; /* Non-zero coefficient tables variables */
int CoeffSumTableN;
uint *CoeffSumTable;     /* Non-zero parametric sums */
int *CoeffParamTable;   /* Table for memorizing single */
                         /* non-zero parameters */

/* Input and output variables */

char BasisSymbolEven;
char BasisSymbolOdd;
int CurrentLevel;
char * GeneratorName;     /* Input names */
char * ParameterName;
int GeneratorMaxN;     /* Maximum number of input generators */
uint InputIntegerSize;  /* Maximum size of input integer in LIMBs */
int InputStringSize;   /* Size of string for reading input */
int LastItemEnd;
int LineLength;
int Margin;
int MaxLevel;
int MinLevel;
int NameLength1;       /* Maximum length of input name (with ending '\0') */
int NewMargin;
int ParameterMaxN = 1; /* Maximum number of input parameters (i at least) */
int BasisElementsPut;
int CommutatorsPut;
int CrudeTime;         /* Prevent time variable wrapping for large tasks */
int EchoInput;
int GAPOutputCommutators;
int GAPOutputBasis;
int GAPOutputRelations;
char GAPAlgebraName[GAP_NAME_SIZE];
char GAPBasisName[GAP_NAME_SIZE];
char GAPRelationsName[GAP_NAME_SIZE];
int HeadingPut;
int HilbertSeriesPut;
int InitialRelationsPut;
int NonZeroCoefficientsPut;
int ReducedRelationsPut;
int StatisticsPut;
char * OutLine;           /* String for preparation of output block */
int OutLineSize;
int PosOutLine;
int PreviousEnd;
int PrintEnd;

uint TimeA, TimeC;

#if defined(DEBUG)
uint Debug;
#endif
#if defined(MEMORY)
int CurrentNLT;
int CurrentNSF;
int CurrentNST;
int CurrentNINT;

#endif

/*_6    Function descriptions===========================================*/

/*_6_0          Main and top level functions============================*/

void ConstructFreeAlgebraBasis(void);       /* 1 call! */
int FindNewPositionInRelation(int lmo);
void GenerateRelations(void);               /* 1 call! */
uint NewJacobiRelation(int l);           /* 1 call! */
int ReduceRelations(int i);

/*_6_1          Pairing functions=======================================*/

int AddPairToLieMonomial(int i, int j);
uint MakeRelationRHSInteger(int i);             /* 1 call!! */
uint MakeRelationRHSParametric(int i);          /* 1 call!! */
uint PairMonomialMonomialInteger(int i, int j);
uint PairMonomialMonomialParametric(int i, int j);
uint PairMonomialSumInteger(int mon, uint a);
uint PairMonomialSumParametric(int mon, uint a);
uint PairSumMonomialInteger(uint a, int mon);
uint PairSumMonomialParametric(uint a, int mon);
uint PairSumSumInteger(uint a, uint b);
uint PairSumSumParametric(uint a, uint b);

/*_6_2          Substitution (replacing) functions======================*/

int IsMonomialInMonomial(int submon, int mon);
uint SubstituteRelationInRelationInteger(uint r, uint a);
uint SubstituteRelationInRelationParametric(uint r, uint a);
uint SubstituteRHSInMonomialInteger(int mon, int lmonr, uint r);
uint SubstituteRHSInMonomialParametric(int mon, int lmonr, uint r);

/*_6_3          Lie and scalar algebra functions========================*/

int LieLikeTermsCollectionInteger(uint a, uint b);
int LieLikeTermsCollectionParametric(uint a, uint b);
uint LieSumAddition(uint a, uint b);
void LieSumDivInteger(uint lsum, BIGINT den);
void LieSumDivScalarSum(uint lsum, uint den);
void LieSumMinusInteger(uint a);
void LieSumMinusParametric(uint a);
void LieSumMultInteger(uint lsum, BIGINT num);
#if defined(RATIONAL_FIELD)
void LieSumMultRationalInteger(int a, BIGINT num, BIGINT den);
#endif
void LieSumMultScalarSum(uint lsum, uint num);
void NormalizeRelationInteger(uint a);
void NormalizeRelationParametric(uint a);
uint ScalarMonomialMultiplication(int *pchange_sign, uint ma, uint mb);
uint ScalarSumAddition(uint a, uint b);
void ScalarSumCancellation(uint *pnum, uint *pden);
void ScalarSumMinus(uint a);
uint ScalarSumMultiplication(uint a, uint b);
void ScalarTermMultiplication(uint a, uint b);     /* 1 call! */

/*_6_4          Scalar polynomial algebraic functions===================*/

uint ContentOfScalarSum(uint cont, uint a);
void InCoeffParamTable(uint cont);
void InCoeffSumTable(uint sum);
void InCoeffTable(uint coe);
uint PolyCoeffAtMainParameter(uint *pa, int mp);
uint PolyContent(uint a, int mp);
uint PolyGCD(uint a, uint b);
uint PolyMainParameterTerm(uint *pa, int mp, int mpdeg);
int PolynomialsAreEqual(uint a, uint b);
uint PolyPseudoRemainder(uint a, uint b, int mp);  /* 1 call! */
uint PolyTermGCD(uint a, uint b);
void PolyTermQuotient(uint a, uint b);
uint PolyQuotient(uint a, uint b);

/*_6_5          Big number functions====================================*/

int BigNMinusBigN(BIGINT a, int na, BIGINT b, int nb);
LIMB BigNShiftLeft(BIGINT bign, int n, int cnt);
int BigNShiftRight(BIGINT bign, int n, int cnt);
int CountLeadingZeroBitsInLimb(LIMB w);
void IntegerCancellation(BIGINT num, BIGINT den);
BIGINT IntegerGCD(BIGINT u, BIGINT v);
void IntegerProduct(BIGINT w, BIGINT u, BIGINT v);
void IntegerQuotient(BIGINT c, BIGINT a, BIGINT b);
void IntegerSum(BIGINT c, BIGINT a, BIGINT b);

/*_6_6          Copy and delete functions===============================*/

uint LieSumCopyInteger(uint a);
uint LieSumCopyIntegerNegative(uint a);
uint LieSumCopyParametric(uint a);
void LieSumKillInteger(uint a);
void LieSumKillParametric(uint a);
uint LieTermFromMonomialInteger(int mon);
uint LieTermFromMonomialParametric(int mon);
uint ScalarSumCopy(uint a);
void ScalarSumKill(uint a);
uint ScalarTermCopy(uint a);

/*_6_7          Technical functions=====================================*/

void Error(int i_message) ATTRIBUTE_NORETURN;
void Initialization(void);
void *NewArray(uint n, uint size, int i_message);
uint NodeLTNew(void);
uint NodeSFNew(void);
uint NodeSTNew(void);
FILE *OpenFile(char * file_name, char * file_type);

/*_6_8          Input functions=========================================*/

int BinaryQuestion(int i_message);
int FindNameInTable(char * name, char * nametab, int n_nametab);
void GetGenerator(char * str);
void GetInput(int n, char * fin);
void GetInteger(BIGINT a, char **pstr);
uint GetLieMonomial(char **pstr);
uint GetLieSum(char **pstr);
uint GetLieTerm(char **pstr);
uint GetUInteger(char **pstr);
void GetParameter(char * str);
void GetRelation(char * str);
uint GetScalarSum(char **pstr);
uint GetScalarTerm(char **pstr);
void GetWeight(char * str);
int KeyBoardBytesToString(char * str);
int KeyBoardStringToFile(int i_m, char * prefix, char * str, FILE *file);
void ReadAndProcessStringsFromFile(void (*proc_func)(char * str), FILE *inf,
                                                        char sep, char end);
int ReadBooleanFromFile(FILE *file);
int ReadCaseFromFile(FILE * file, char * case_str[], int n_cases);
uint ReadDecimalFromFile(FILE *file);
short ReadStringFromFile(char * str, FILE *file);
short SkipCommentInFile(FILE *file);
void SkipName(char **pstr);
void SkipSpaces(char **pstr);
short SkipSpacesInFile(FILE *file);

/*_6_9          Output functions========================================*/

void AddSymbolToOutLine(char c, int position);
void InLineLevel(int level);
void InLineNumberInBrackets(uint n);
void InLineString(char * str);
void InLineSubscript(char * s);
void InLineSymbol(char symbol);
void InLineTableName(char * name);
char * UToString(uint n);
void PutBasis(void);
#if defined(GAP)
void PutBasisGAP(void);
#endif
void PutBlock(void);
void PutCharacter(char c);
#if defined(GAP)
void PutCharacterGAP(char c);
#endif
void PutCoefficientTable(void);
void PutCommutators(void);
#if defined(GAP)
void PutCommutatorsGAP(void);
#endif
void PutDegree(uint deg);
void PutDimensions(void);
void PutDots(void);
void PutEnd(void);
void PutFormattedU(char * format, uint i);
void PutIntegerUnsigned(BIGINT bn);
#if defined(GAP)
void PutIntegerUnsignedGAP(BIGINT bn);
#endif
void PutLieBareTerm(void (*put_lie_mon)(int a), uint a);
void PutLieBasisElement(int pos);
void PutLieMonomialLeftNormed(int pos);
void PutLieMonomialStandard(int pos);
#if defined(GAP)
void PutLieMonomialGAP(int pos);
#endif
void PutLieSum(void (*put_lie_mon)(int a), uint a);
void PutMessage(int i_message);
void PutRelations(int i);
#if defined(GAP)
void PutRelationsGAP(void);
#endif
void PutScalarBareTerm(uint a);
void PutScalarFactor(uint a);
void PutScalarSum(uint a);
void PutStart(void);
void PutStatistics(void);
void PutString(char * str);
#if defined(GAP)
void PutStringGAP(char * str);
#endif
void PutStringStandard(char * str);
void PutSymbol(char c);

/* Global function variables */

int (*LieLikeTermsCollection)(uint a, uint b) = LieLikeTermsCollectionInteger;
uint (*LieSumCopy)(uint a) = LieSumCopyInteger;
void (*LieSumKill)(uint a) = LieSumKillInteger;
void (*LieSumMinus)(uint a) = LieSumMinusInteger;
uint (*LieTermFromMonomial)(int mon) = LieTermFromMonomialInteger;
void (*NormalizeRelation)(uint a) = NormalizeRelationInteger;
uint (*PairMonomialMonomial)(int i, int j) = PairMonomialMonomialInteger;
uint (*PairMonomialSum)(int mon, uint a) = PairMonomialSumInteger;
uint (*PairSumMonomial)(uint a, int mon) = PairSumMonomialInteger;
uint (*PairSumSum)(uint a, uint b) = PairSumSumInteger;
void (*PutLieMonomial)(int pos) = PutLieMonomialStandard;
uint (*SubstituteRelationInRelation)(uint r, uint a) =
SubstituteRelationInRelationInteger;

/*_6_10   Debugging functions===========================================*/

#if defined(DEBUG)
void PutDebugHeader(uint debug, char * f_name, char * in_out);
void PutDebugInteger(char * name, BIGINT u);
void PutDebugLieMonomial(char * name, int a);
void PutDebugLieMonomialTable(int newmon);
void PutDebugLieSum(char * name, uint a);
void PutDebugLieTerm(char * name, uint a);
void PutDebugU(char * name, uint i);
#if defined(D_PUT_RELATIONS)
void PutDebugRelations(void);
#endif
void PutDebugScalarSum(char * name, uint a);
void PutDebugString(char * strname, char * str);
#endif
#if defined(MEMORY)
--> --------------------

--> maximum size reached

--> --------------------

95%


¤ Dauer der Verarbeitung: 0.37 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.