Index: Singular/ChangeLog
===================================================================
--- Singular/ChangeLog	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/ChangeLog	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -1,5 +1,8 @@
 1998-03-18  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
 
-	* polys-impl.h: Cleaned up COMP_FAST and related #defines
+	* Makefile.in: added Singularb target for bprof
+
+	* polys-impl.h, polys-comp.h: Cleaned up COMP_FAST and related
+	#defines 
 
 1998-03-16  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
Index: Singular/ipid.h
===================================================================
--- Singular/ipid.h	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/ipid.h	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: ipid.h,v 1.8 1998-01-16 14:29:53 krueger Exp $ */
+/* $Id: ipid.h,v 1.9 1998-03-19 16:05:43 obachman Exp $ */
 /*
 * ABSTRACT: identfier handling
@@ -37,8 +37,5 @@
 
   // what follows below here should be set by rComplete, _only_
-#ifdef COMP_FAST
   short     VarOffset; /* controls indexing of exponents */
-  short     CompIndex; /* index of component in exponent vector */
-#endif    
 
 #ifdef RDEBUG
Index: Singular/kstd1.cc
===================================================================
--- Singular/kstd1.cc	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/kstd1.cc	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kstd1.cc,v 1.15 1998-03-16 14:56:31 obachman Exp $ */
+/* $Id: kstd1.cc,v 1.16 1998-03-19 16:05:44 obachman Exp $ */
 /*
 * ABSTRACT:
@@ -1643,7 +1643,7 @@
   initBuchMoraPos(strat);
   initMora(F,strat);
-#ifdef COMP_FAST
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif  
+  strat->spSpolyLoop = spGetSpolyLoop(currRing, 
+                                      MAX(strat->ak,pMaxComp(q)),
+                                      strat->syzComp, FALSE);
   strat->enterS = enterSMoraNF;
   /*- set T -*/
@@ -1738,7 +1738,7 @@
   strat->enterS = enterSMoraNF;
   /*- set T -*/
-#ifdef COMP_FAST
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif  
+  strat->spSpolyLoop = spGetSpolyLoop(currRing, 
+                                      MAX(strat->ak,idRankFreeModule(q)),
+                                      strat->syzComp, FALSE);
   strat->tl = -1;
   strat->tmax = setmax;
@@ -1876,7 +1876,5 @@
   strat->homog=h;
   spSet(currRing);
-#ifdef COMP_FAST
   strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif  
   if (pOrdSgn==-1)
   {
@@ -2077,7 +2075,5 @@
   strat->homog=h;
   spSet(currRing);
-#ifdef COMP_FAST
   strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif
   if (pOrdSgn==-1)
   {
@@ -2153,7 +2149,4 @@
   strat->syzComp = syzComp;
   spSet(currRing);
-#ifdef COMP_FAST
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif  
   if (pOrdSgn==-1)
     p=kNF1(F,Q,p,strat,lazyReduce);
@@ -2174,7 +2167,4 @@
   kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
   strat->syzComp = syzComp;
-#ifdef COMP_FAST
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif  
   if (pOrdSgn==-1)
     res=kNF1(F,Q,p,strat,lazyReduce);
@@ -2217,7 +2207,5 @@
   strat->tmax        = setmax;
   strat->T           = initT();
-#ifdef COMP_FAST
   strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif  
   if (pOrdSgn == -1)   strat->honey = TRUE;
   initS(F,Q,strat);
Index: Singular/kstd2.cc
===================================================================
--- Singular/kstd2.cc	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/kstd2.cc	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kstd2.cc,v 1.12 1998-03-16 14:56:32 obachman Exp $ */
+/* $Id: kstd2.cc,v 1.13 1998-03-19 16:05:46 obachman Exp $ */
 /*
 *  ABSTRACT -  Kernel: alg. of Buchberger
@@ -1547,7 +1547,7 @@
   /*- set S -*/
   strat->sl = -1;
-#ifdef COMP_FAST
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif
+  // strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
+  strat->spSpolyLoop = spGetSpolyLoop(currRing, MAX(strat->ak, pMaxComp(q)),
+                                      strat->syzComp, FALSE);
   /*- init local data struct.---------------------------------------- -*/
   /*Shdl=*/initS(F,Q,strat);
@@ -1592,7 +1592,7 @@
   /*- set S -*/
   strat->sl = -1;
-#ifdef COMP_FAST
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif
+  strat->spSpolyLoop =  spGetSpolyLoop(currRing, 
+                                       MAX(strat->ak, idRankFreeModule(q)),
+                                       strat->syzComp, FALSE);
   /*- init local data struct.---------------------------------------- -*/
   /*Shdl=*/initS(F,Q,strat);
@@ -1684,7 +1684,5 @@
   strat->homog=h;
   spSet(currRing);
-#ifdef COMP_FAST
   strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
-#endif
   initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
   initBuchMoraPos(strat);
Index: Singular/kutil.cc
===================================================================
--- Singular/kutil.cc	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/kutil.cc	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kutil.cc,v 1.12 1998-03-16 14:56:34 obachman Exp $ */
+/* $Id: kutil.cc,v 1.13 1998-03-19 16:05:47 obachman Exp $ */
 /*
 * ABSTRACT: kernel: utils for std
@@ -3808,7 +3808,7 @@
 }
 
-rOrderType_t spGetOrderType(ring r, kStrategy strat)
-{
-  if (strat->syzComp > 0)
+rOrderType_t spGetOrderType(ring r, int modrank, int syzcomp)
+{
+  if (syzcomp > 0)
     return rOrderType_Syz;
   else
@@ -3817,5 +3817,5 @@
   
     if ((rot == rOrderType_CompExp || rot == rOrderType_ExpComp) &&
-        (strat->ak == 0))
+        (modrank == 0))
       return rOrderType_Exp;
     else
Index: Singular/kutil.h
===================================================================
--- Singular/kutil.h	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/kutil.h	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kutil.h,v 1.5 1998-03-16 14:56:35 obachman Exp $ */
+/* $Id: kutil.h,v 1.6 1998-03-19 16:05:48 obachman Exp $ */
 /*
 * ABSTRACT: kernel: utils for std
@@ -173,5 +173,17 @@
 BOOLEAN homogTest(polyset F, int Fmax);
 BOOLEAN newHEdge(polyset S, int ak,kStrategy strat);
-rOrderType_t spGetOrderType(ring r, kStrategy strat);
+
+rOrderType_t spGetOrderType(ring r, int modrank, int syzcomp);
+inline rOrderType_t spGetOrderType(ring r, kStrategy strat)
+{
+  return spGetOrderType(r, strat->ak, strat->syzComp);
+}
+
+inline int MAX(int a, int b)
+{
+  if (a > b) return a;
+  else return b;
+}
+
 
 inline TSet initT () { return (TSet)Alloc0(setmax*sizeof(TObject)); }
Index: Singular/polys-impl.cc
===================================================================
--- Singular/polys-impl.cc	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/polys-impl.cc	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: polys-impl.cc,v 1.10 1998-03-18 14:28:48 obachman Exp $ */
+/* $Id: polys-impl.cc,v 1.11 1998-03-19 16:05:49 obachman Exp $ */
 
 /***************************************************************
@@ -29,30 +29,10 @@
 #include "ipid.h"
 
+#ifdef COMP_FAST
 /***************************************************************
  *
- * definition of global variables
+ * Low - level routines for which deal with var indicies
  *
  ***************************************************************/
-
-int pVariables;
-int pMonomSize;
-int pMonomSizeW;
-
-#ifdef COMP_FAST
-int pVariables1W;
-int pVariablesW;
-int pVarOffset;
-int pCompIndex;
-int pVarLowIndex;
-int pVarHighIndex;
-#endif
-int pLexSgn;
-
-/***************************************************************
- *
- * Low - level routines for which deal with var indicies
- *
- ***************************************************************/
-#ifdef COMP_FAST
 // gets var indicies w.r.t. the ring r
 void pGetVarIndicies(ring r, int &VarOffset, 
@@ -105,18 +85,6 @@
 
 
-// assumes that pVarOffset != src_r->VarOffset
 inline void RingCopy2ExpV(poly dest, poly src, ring src_r)
 {
-#if 0
-  if (_pHasReverseExp)
-  {
-#ifdef WORDS_BIGENDIAN
-    for (int i=0, offset = src_r->VarOffset - 1; i<pVariables; i++)
-      dest->exp[i] = src->exp[offset - i];
-#else
-#endif
-  }
-
-#endif
   for (int i=pVariables; i; i--)
     pSetExp(dest, i, pRingGetExp(src_r, src, i));
@@ -144,5 +112,5 @@
   if (r->VarOffset == pVarOffset)
   {
-    memcpy(a,p,pMonomSize);
+    pCopy2(a,p);
     a->coef=nCopy(p->coef);
     pSetm(a);
@@ -157,5 +125,5 @@
         a = pNext(a) = pNew();
 #endif
-        memcpy(a,p,pMonomSize);
+        pCopy2(a,p);
         a->coef=nCopy(p->coef);
         pSetm(a);
@@ -594,5 +562,5 @@
   pCopy2(ptemp, p1);
 
-  _pMonAddFast(p1, p2);
+  __pMonAddFast(p1, p2);
 
   for (int i=1; i<=pVariables; i++)
Index: Singular/polys.cc
===================================================================
--- Singular/polys.cc	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/polys.cc	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: polys.cc,v 1.17 1998-03-18 14:28:50 obachman Exp $ */
+/* $Id: polys.cc,v 1.18 1998-03-19 16:05:50 obachman Exp $ */
 
 /*
@@ -21,8 +21,5 @@
 #include "binom.h"
 #include "ipid.h"
-
-#ifdef COMP_FAST
 #include "polys-comp.h"
-#endif
 
 /* ----------- global variables, set by pChangeRing --------------------- */
@@ -34,8 +31,17 @@
 pFDegProc pFDeg;
 /* the monomial ordering of the head monomials a and b */
+/* returns -1 if a comes before b, 0 if a=b, 1 otherwise */
 pCompProc pComp0;
-/* returns -1 if a comes before b, 0 if a=b, 1 otherwise */
-
-/* the number of variables             */
+
+int pVariables;     // number of variables 
+int pVariablesW;    // number of words of pVariables exponents
+int pVariables1W;   // number of words of (pVariables+1) exponents
+int pMonomSize;     // size of monom (in bytes)
+int pMonomSizeW;    // size of monom (in words)
+int pLexSgn;        // 1, for lex monom comps; -1 otherwise (exception: ls)
+int pVarOffset;     // controls the way exponents are stored in a vector
+int pVarLowIndex;   // lowest exponent index 
+int pVarHighIndex;  // highest exponent index 
+
 /* 1 for polynomial ring, -1 otherwise */
 int     pOrdSgn;
@@ -47,10 +53,6 @@
 /* TRUE if the monomial ordering has polynomial and power series blocks */
 BOOLEAN pMixedOrder;
-
-#if defined(TEST_MAC_ORDER) || defined(COMP_FAST)
+/* 1 for c ordering, -1 otherwise (i.e. for C ordering) */
 int  pComponentOrder;
-#else
-static int  pComponentOrder;
-#endif
 
 #ifdef DRING
@@ -76,10 +78,6 @@
 /*is the basic comparing procedure during a computation of syzygies*/
 static pCompProc pCompOld;
-/*for grouping module indecees during computations*/
-#ifndef COMP_FAST
-static int maxBound = 0;
-#else
-int maxBound = 0;
-#endif
+/*for grouping module indicies during computations*/
+int pMaxBound = 0;
 
 /*contains the headterms for the Schreyer orderings*/
@@ -126,14 +124,4 @@
 {
   p->Order = pExpQuerSum1(p, firstBlockEnds);
-#ifdef COMP_DEBUG  
-    int i, j = pGetExp(p,1);
-
-  for (i = firstBlockEnds; i > 1; i--) j += pGetExp(p,i);
-  if (j != p->Order)
-  {
-    Print("Error in setdeg1");
-    pExpQuerSum1(p, firstBlockEnds);
-  }
-#endif  
 }
 
@@ -155,54 +143,4 @@
 
 /*-------- IMPLEMENTATION OF MONOMIAL COMPARISONS ---------------------*/
-
-
-/***************************************************************
- ***************************************************************  
- *
- * MONOMIAL COMPARIONS:
- * They are influenced by the following macros:
- * COMP_TRADITIONAL -- (un)set in polys-impl.h
-     Keeps the traditional comparison routines
-     defined -- needed as long as their might be comparisons with
-     negativ components.
-     All the traditional routines are prefixed by t_
-     
- * COMP_FAST -- (un)set in polys-impl.h
-     Implements monomial comparisons using the fast
-     techniques. Undefine in case there are problems. All the fast
-     routines are prefixed by f_
-     
- * COMP_STATISTIC -- (un)set in polys-impl.h
-     Provides several routines for accumulating statistics on monomial
-     comparisons
-     
- * COMP_DEBUG -- (un)set in polys-impl.h
-     Turns on debugging of COMP_FAST by comparing the resutsl of fast
-     comparison with traditional comparison
-
- *    
- *
- ***************************************************************  
- ***************************************************************/
-
-#ifdef COMP_DEBUG
-static int debug_comp(poly p1, poly p2);
-#endif // COMP_DEBUG
-
-#ifdef COMP_STATISTICS
-// Initializes, resets and outputs Comp statistics
-void InitCompStatistics(int nvars);
-void ResetCompStatistics();
-void OutputCompStatistics();
-unsigned long MonomCountTotal = 0;
-unsigned long MonomCountOrderS = 0;
-unsigned long MonomCountOrderG = 0;
-unsigned long* MonomCountExp = NULL;
-unsigned long MonomCountExpS = 0;
-unsigned long MonomCountExpG = 0;
-unsigned long MonomCountCompS = 0;
-unsigned long MonomCountCompG = 0;
-unsigned long MonomCountEqual = 0;
-#endif // COMP_STATISTICS
 
 
@@ -219,24 +157,4 @@
 while(0)
   
-/***************************************************************
- *
- * FAST COMPARISONS
- *
- ***************************************************************/
-#ifdef COMP_FAST
-static pCompProc f_pComp0 = NULL;
-static int f_comp_otEXP_nwONE(poly p1, poly p2);
-static int f_comp_otCOMPEXP_nwONE(poly p1, poly p2);
-static int f_comp_otEXPCOMP_nwONE(poly p1, poly p2);
-static int f_comp_otEXP_nwTWO(poly p1, poly p2);
-static int f_comp_otCOMPEXP_nwTWO(poly p1, poly p2);
-static int f_comp_otEXPCOMP_nwTWO(poly p1, poly p2);
-static int f_comp_otEXP_nwEVEN(poly p1, poly p2);
-static int f_comp_otCOMPEXP_nwEVEN(poly p1, poly p2);
-static int f_comp_otEXPCOMP_nwEVEN(poly p1, poly p2);
-static int f_comp_otEXP_nwODD(poly p1, poly p2);
-static int f_comp_otCOMPEXP_nwODD(poly p1, poly p2);
-static int f_comp_otEXPCOMP_nwODD(poly p1, poly p2);
-
 #define Mreturn(d, multiplier)                      \
 {                                                   \
@@ -244,7 +162,22 @@
   return -multiplier;                               \
 }                                               
+
+static int pComp_otEXP_nwONE(poly p1, poly p2);
+static int pComp_otCOMPEXP_nwONE(poly p1, poly p2);
+static int pComp_otEXPCOMP_nwONE(poly p1, poly p2);
+static int pComp_otEXP_nwTWO(poly p1, poly p2);
+static int pComp_otCOMPEXP_nwTWO(poly p1, poly p2);
+static int pComp_otEXPCOMP_nwTWO(poly p1, poly p2);
+static int pComp_otEXP_nwEVEN(poly p1, poly p2);
+static int pComp_otCOMPEXP_nwEVEN(poly p1, poly p2);
+static int pComp_otEXPCOMP_nwEVEN(poly p1, poly p2);
+static int pComp_otEXP_nwODD(poly p1, poly p2);
+static int pComp_otCOMPEXP_nwODD(poly p1, poly p2);
+static int pComp_otEXPCOMP_nwODD(poly p1, poly p2);
+
   
-// comp_nwONE is used if pVariables1W == 1 and component is compatible with ordering
-static int f_comp_otEXP_nwONE(poly p1, poly p2)  
+// comp_nwONE is used if pVariables1W == 1 and component is compatible
+// with ordering
+static int pComp_otEXP_nwONE(poly p1, poly p2)  
 {
   register long d = pGetOrder(p1) - pGetOrder(p2);
@@ -257,7 +190,7 @@
 }
 
-// comp_otEXPCOMP_nwONE is used if pVariables1W == 1, priority is given to exponents,
-// component is incompatible with ordering
-static int f_comp_otEXPCOMP_nwONE(poly p1, poly p2)  
+// comp_otEXPCOMP_nwONE :  pVariables1W == 1, priority is
+// given to exponents, component is incompatible with ordering
+static int pComp_otEXPCOMP_nwONE(poly p1, poly p2)  
 {
   register long d = pGetOrder(p1) - pGetOrder(p2);
@@ -270,7 +203,7 @@
 }
 
-// comp_otEXPCOMP_nwONE is used if pVariables1W == 1, priority is given to component,
+// comp_otEXPCOMP_nwONE :  pVariables1W == 1, priority is given to component,
 // component is incompatible with ordering
-static int f_comp_otCOMPEXP_nwONE(poly p1, poly p2)  
+static int pComp_otCOMPEXP_nwONE(poly p1, poly p2)  
 {
   register long d = pGetComp(p2) - pGetComp(p1);
@@ -284,6 +217,6 @@
 }
 
-// comp_nwTWO is used if pVariables1W == 2 and component is compatible with ordering
-static int f_comp_otEXP_nwTWO(poly p1, poly p2)  
+// comp_nwTWO :  pVariables1W == 2 and component is compatible with ordering
+static int pComp_otEXP_nwTWO(poly p1, poly p2)  
 {
   register long d = pGetOrder(p1) - pGetOrder(p2);
@@ -296,7 +229,7 @@
 }
 
-// comp_otEXPCOMP_nwTWO is used if pVariables1W == 2, priority is given to exponents,
+// comp_otEXPCOMP_nwTWO :  pVariables1W == 2, priority is given to exponents,
 // component is incompatible with ordering
-static int f_comp_otEXPCOMP_nwTWO(poly p1, poly p2)  
+static int pComp_otEXPCOMP_nwTWO(poly p1, poly p2)  
 {
   register long d = pGetOrder(p1) - pGetOrder(p2);
@@ -309,7 +242,7 @@
 }
 
-// comp_otEXPCOMP_nwTWO is used if pVariables1W == 2, priority is given to component,
+// comp_otEXPCOMP_nwTWO :  pVariables1W == 2, priority is given to component,
 // component is incompatible with ordering
-static int f_comp_otCOMPEXP_nwTWO(poly p1, poly p2)  
+static int pComp_otCOMPEXP_nwTWO(poly p1, poly p2)  
 {
   register long d = pGetComp(p2) - pGetComp(p1);
@@ -323,7 +256,7 @@
 }
 
-// comp_nwEVEN is used if pVariables1W == 2*i and component is compatible
+// comp_nwEVEN :  pVariables1W == 2*i and component is compatible
 // with ordering
-static int f_comp_otEXP_nwEVEN(poly p1, poly p2)  
+static int pComp_otEXP_nwEVEN(poly p1, poly p2)  
 {
   register long d = pGetOrder(p1) - pGetOrder(p2);
@@ -336,7 +269,7 @@
 }
 
-// comp_otEXPCOMP_nwEVEN is used if pVariables1W == 2*i, priority is given to exponents,
+// comp_otEXPCOMP_nwEVEN : pVariables1W == 2*i, priority is given to exponents,
 // component is incompatible with ordering
-static int f_comp_otEXPCOMP_nwEVEN(poly p1, poly p2)  
+static int pComp_otEXPCOMP_nwEVEN(poly p1, poly p2)  
 {
   register long d = pGetOrder(p1) - pGetOrder(p2);
@@ -349,7 +282,7 @@
 }
 
-// comp_otEXPCOMP_nwEVEN is used if pVariables1W == 2*i, priority is given to component,
+// comp_otEXPCOMP_nwEVEN : pVariables1W == 2*i, priority is given to component,
 // component is incompatible with ordering
-static int f_comp_otCOMPEXP_nwEVEN(poly p1, poly p2)  
+static int pComp_otCOMPEXP_nwEVEN(poly p1, poly p2)  
 {
   register long d = pGetComp(p2) - pGetComp(p1);
@@ -363,7 +296,7 @@
 }
 
-// comp_nwODD is used if pVariables1W == 2*i and component is compatible
+// comp_nwODD : pVariables1W == 2*i and component is compatible
 // with ordering
-static int f_comp_otEXP_nwODD(poly p1, poly p2)  
+static int pComp_otEXP_nwODD(poly p1, poly p2)  
 {
   register long d = pGetOrder(p1) - pGetOrder(p2);
@@ -376,7 +309,7 @@
 }
 
-// comp_otEXPCOMP_nwODD is used if pVariables1W == 2*i, priority is given to exponents,
+// comp_otEXPCOMP_nwODD : pVariables1W == 2*i, priority is given to exponents,
 // component is incompatible with ordering
-static int f_comp_otEXPCOMP_nwODD(poly p1, poly p2)  
+static int pComp_otEXPCOMP_nwODD(poly p1, poly p2)  
 {
   register long d = pGetOrder(p1) - pGetOrder(p2);
@@ -393,7 +326,7 @@
 }
 
-// comp_otCOMPEXP_nwODD is used if pVariables1W == 2*i, priority is given to component,
+// comp_otCOMPEXP_nwODD : pVariables1W == 2*i, priority is given to component,
 // component is incompatible with ordering
-static int f_comp_otCOMPEXP_nwODD(poly p1, poly p2)  
+static int pComp_otCOMPEXP_nwODD(poly p1, poly p2)  
 {
   register long d = pGetComp(p2) - pGetComp(p1);
@@ -406,96 +339,4 @@
   Mreturn(d, pLexSgn);
 }
-#endif // COMP_FAST
-
-/***************************************************************
- *
- * FAST COMPARISONS
- *
- ***************************************************************/
-#ifdef COMP_TRADITIONAL
-
-static int t_comp_otCOMPEXP_nwONE(poly p1, poly p2);
-static int t_comp_otEXPCOMP_nwONE(poly p1, poly p2);
-static int t_comp_lex_otCOMPEXP_i(poly p1, poly p2);
-static int t_comp_otCOMPEXP_lex_i(poly p1, poly p2);
-static int t_comp_revlex_otCOMPEXP_i(poly p1, poly p2);
-static int t_comp_otCOMPEXP_revlex_i(poly p1, poly p2);
-
-inline long LexComp(poly p1, poly p2)
-{
-  long d, i;
-  for (i=1; i<pVariables; i++)
-  {
-    d = pGetExpDiff(p1, p2, i);
-    if (d) return d;
-  }
-  return pGetExpDiff(p1, p2, pVariables);
-}
-
-inline long RevLexComp(poly p1, poly p2)
-{
-  long d, i;
-  for (i=pVariables; i>1; i--)
-  {
-    d = pGetExpDiff(p1, p2, i);
-    if (d) return d;
-  }
-  return pGetExpDiff(p1, p2, 1);
-}
-
-static int t_comp_otCOMPEXP_nwONE(poly p1, poly p2)
-{
-  NonZeroR(pGetComp(p1) - pGetComp(p2),
-           return -pComponentOrder, return pComponentOrder);
-  NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);
-  return 0;
-}
-
-static int t_comp_otEXPCOMP_nwONE(poly p1, poly p2)
-{
-  NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);
-  NonZeroR(pGetComp(p1) - pGetComp(p2),
-           return -pComponentOrder, return pComponentOrder);
-  return 0;
-}
-
-static int t_comp_lex_otCOMPEXP_i(poly p1, poly p2)
-{
-  NonZeroR(pGetComp(p1) - pGetComp(p2),
-           return -pComponentOrder, return pComponentOrder);
-  NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);
-  NonZeroR(LexComp(p1, p2), return pLexSgn, return -pLexSgn);
-  return 0;
-}
-
-static int t_comp_otEXPCOMP_lex_i(poly p1, poly p2)
-{
-  NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);
-  NonZeroR(LexComp(p1, p2), return pLexSgn, return -pLexSgn);
-  NonZeroR(pGetComp(p1) - pGetComp(p2),
-           return -pComponentOrder, return pComponentOrder);
-  return 0;
-}
-
-static int t_comp_revlex_otCOMPEXP_i(poly p1, poly p2)
-{
-  NonZeroR(pGetComp(p1) - pGetComp(p2),
-           return -pComponentOrder, return pComponentOrder);
-  NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);
-  NonZeroR(RevLexComp(p1, p2), return pLexSgn, return -pLexSgn);
-  return 0;
-}
-
-static int t_comp_otEXPCOMP_revlex_i(poly p1, poly p2)
-{
-  NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);
-  NonZeroR(RevLexComp(p1, p2), return pLexSgn, return -pLexSgn);
-  NonZeroR(pGetComp(p1) - pGetComp(p2),
-           return -pComponentOrder, return pComponentOrder);
-  return 0;
-}
-
-#endif // COMP_TRADITIONAL
-
 /*2
 * compare the head monomial of p1 and p2 with weight vector
@@ -503,5 +344,5 @@
 static int comp1a  ( poly p1, poly p2, int f, int l, short * w )
 {
-  int d= p1->Order - p2->Order;
+  int d= pGetOrder(p1) - pGetOrder(p2);
   if ( d > 0 /*p1->Order > p2->Order*/ )
     return 1;
@@ -1023,9 +864,9 @@
 static int mcompSyz(poly p1,poly p2)
 {
-  if (pGetComp(p1)<=maxBound)
-  {
-    if (pGetComp(p2)>maxBound) return 1;
-  }
-  else if (pGetComp(p2)<=maxBound)
+  if (pGetComp(p1)<=pMaxBound)
+  {
+    if (pGetComp(p2)>pMaxBound) return 1;
+  }
+  else if (pGetComp(p2)<=pMaxBound)
   {
     return -1;
@@ -1038,17 +879,17 @@
   if (k!=0)
   {
-    if (maxBound==0)
+    if (pMaxBound==0)
     {
       pCompOld = pComp0;
       pComp0 = mcompSyz;
     }
-    maxBound = k;
+    pMaxBound = k;
   }
   else
   {
-    if (maxBound!=0)
+    if (pMaxBound!=0)
     {
       pComp0 = pCompOld;
-      maxBound = 0;
+      pMaxBound = 0;
     }
   }
@@ -1165,5 +1006,5 @@
   int ll=1;
 
-  if (maxBound/*syzComp*/==0)
+  if (pMaxBound/*syzComp*/==0)
   {
     while ((p=pNext(p))!=NULL)
@@ -1177,5 +1018,5 @@
     while ((p=pNext(p))!=NULL)
     {
-      if (pGetComp(p)<=maxBound/*syzComp*/)
+      if (pGetComp(p)<=pMaxBound/*syzComp*/)
       {
         o=pFDeg(p);
@@ -1245,5 +1086,5 @@
   while ((p=pNext(p))!=NULL)
   {
-    if ((maxBound/*syzComp*/==0) || (pGetComp(p)<=maxBound/*syzComp*/))
+    if ((pMaxBound/*syzComp*/==0) || (pGetComp(p)<=pMaxBound/*syzComp*/))
     {
        if ((t=pFDeg(p))>max) max=t;
@@ -1260,15 +1101,10 @@
 
 
-/*2
-* sets the comparision routine for monomials: for the first block
-* of variables (o_r is the number of the ordering)
-*/
-#ifdef COMP_FAST
+/*
+* sets the comparision routine for monomials: for simple monomial orderings
+* Priority is given to exponent vector
+*/
 static void SimpleChoose(int o_r, int comp_order, pCompProc *p)
-#else  
-static void SimpleChoose(int o_r, pCompProc *p)
-#endif  
-{
-#ifdef COMP_FAST
+{
   switch(o_r)
   {
@@ -1283,23 +1119,16 @@
         if (comp_order == ringorder_C || o_r == ringorder_unspec)
         {
-          if (pVariables1W == 1)
-            f_pComp0 = f_comp_otEXPCOMP_nwONE;
-          else if (pVariables1W == 2)
-            f_pComp0 = f_comp_otEXPCOMP_nwTWO;
-          else if (pVariables1W & 1)
-            f_pComp0 = f_comp_otEXPCOMP_nwODD;
-          else
-            f_pComp0 = f_comp_otEXPCOMP_nwEVEN;
+          if (pVariables1W == 1)        *p = pComp_otEXPCOMP_nwONE;
+          else if (pVariables1W == 2)   *p = pComp_otEXPCOMP_nwTWO;
+          else if (pVariables1W & 1)    *p = pComp_otEXPCOMP_nwODD;
+          else                          *p = pComp_otEXPCOMP_nwEVEN;
         }
         else
         {
-          if (pVariables1W == 1)
-            f_pComp0 = f_comp_otEXP_nwONE;
-          else if (pVariables1W == 2)
-            f_pComp0 = f_comp_otEXP_nwTWO;
-          else if (pVariables1W & 1)
-            f_pComp0 = f_comp_otEXP_nwODD;
-          else
-            f_pComp0 = f_comp_otEXP_nwEVEN;
+          // component is compatible with exponent vector 
+          if (pVariables1W == 1)        *p = pComp_otEXP_nwONE;
+          else if (pVariables1W == 2)   *p = pComp_otEXP_nwTWO;
+          else if (pVariables1W & 1)    *p = pComp_otEXP_nwODD;
+          else                          *p = pComp_otEXP_nwEVEN;
         }
         break;
@@ -1318,23 +1147,16 @@
         if (comp_order == ringorder_c)
         {
-          if (pVariables1W == 1)
-            f_pComp0 = f_comp_otEXPCOMP_nwONE;
-          else if (pVariables1W == 2)
-            f_pComp0 = f_comp_otEXPCOMP_nwTWO;
-          else if (pVariables1W & 1)
-            f_pComp0 = f_comp_otEXPCOMP_nwODD;
-          else
-            f_pComp0 = f_comp_otEXPCOMP_nwEVEN;
+          if (pVariables1W == 1)        *p = pComp_otEXPCOMP_nwONE;
+          else if (pVariables1W == 2)   *p = pComp_otEXPCOMP_nwTWO;
+          else if (pVariables1W & 1)    *p = pComp_otEXPCOMP_nwODD;
+          else                          *p = pComp_otEXPCOMP_nwEVEN;
         }
         else
         {
-          if (pVariables1W == 1)
-            f_pComp0 = f_comp_otEXP_nwONE;
-          else if (pVariables1W == 2)
-            f_pComp0 = f_comp_otEXP_nwTWO;
-          else if (pVariables1W & 1)
-            f_pComp0 = f_comp_otEXP_nwODD;
-          else
-            f_pComp0 = f_comp_otEXP_nwEVEN;
+          // component is compatible with exponent vector 
+          if (pVariables1W == 1)        *p = pComp_otEXP_nwONE;
+          else if (pVariables1W == 2)   *p = pComp_otEXP_nwTWO;
+          else if (pVariables1W & 1)    *p = pComp_otEXP_nwODD;
+          else                          *p = pComp_otEXP_nwEVEN;
         }
 #ifdef PDEBUG
@@ -1353,7 +1175,64 @@
       pSetVarIndicies_Lex(pVariables);
   }
-  *p = f_pComp0;
-#endif // COMP_FAST  
-
+}
+
+/*
+* sets the comparision routine for monomials: for simple monomial orderings
+* Priority is given to component
+*/
+static void SimpleChooseC(int o_r, pCompProc *p)
+{
+  switch(o_r)
+  {
+      case ringorder_dp:
+      case ringorder_wp:
+      case ringorder_ds:
+      case ringorder_ls:
+      case ringorder_ws:
+        pSetVarIndicies_RevLex(pVariables);
+        pLexSgn = -1;
+        if (pVariablesW == 1)
+          *p = pComp_otCOMPEXP_nwONE;
+        else if (pVariablesW == 2)
+          *p = pComp_otCOMPEXP_nwTWO;
+        else if (pVariablesW & 1)
+          *p = pComp_otCOMPEXP_nwODD;
+        else
+          *p = pComp_otCOMPEXP_nwEVEN;
+        break;
+        
+#ifdef PDEBUG
+      case ringorder_lp:
+      case ringorder_Dp:
+      case ringorder_Wp:
+      case ringorder_Ds:
+      case ringorder_Ws:
+#else
+      default:
+#endif
+        pSetVarIndicies_Lex(pVariables);
+        pLexSgn = 1;
+        if (pVariablesW == 1)
+          *p = pComp_otCOMPEXP_nwONE;
+        else if (pVariablesW == 2)
+          *p = pComp_otCOMPEXP_nwTWO;
+        else if (pVariablesW & 1)
+          *p = pComp_otCOMPEXP_nwODD;
+        else
+          *p = pComp_otCOMPEXP_nwEVEN;
+#ifdef PDEBUG
+        break;
+      default:
+        Werror("wrong internal ordering:%d at %s, l:%d\n",o_r,__FILE__,__LINE__);
+#endif
+  }
+  if (o_r == ringorder_lp || o_r == ringorder_ls)
+  {
+    pLexOrder=TRUE;
+    pFDeg = pTotaldegree;
+    pLDeg = ldeg1c;
+    if (o_r == ringorder_ls)
+     pSetVarIndicies_Lex(pVariables);
+  }
 }
 
@@ -1401,74 +1280,4 @@
 }
 
-/*2
-* sets the comparision routine for monomials: for the first block
-* of variables (o_r is the number of the ordering)
-*/
-#ifdef COMP_FAST
-static void SimpleChooseC(int o_r, int comp_order, pCompProc *p)
-#else  
-static void SimpleChooseC(int o_r, pCompProc *p)
-#endif  
-{
-#ifdef COMP_FAST
-  switch(o_r)
-  {
-      case ringorder_dp:
-      case ringorder_wp:
-      case ringorder_ds:
-      case ringorder_ls:
-      case ringorder_ws:
-        pSetVarIndicies_RevLex(pVariables);
-        pLexSgn = -1;
-        if (pVariablesW == 1)
-          f_pComp0 = f_comp_otCOMPEXP_nwONE;
-        else if (pVariablesW == 2)
-          f_pComp0 = f_comp_otCOMPEXP_nwTWO;
-        else if (pVariablesW & 1)
-          f_pComp0 = f_comp_otCOMPEXP_nwODD;
-        else
-          f_pComp0 = f_comp_otCOMPEXP_nwEVEN;
-        break;
-        
-#ifdef PDEBUG
-      case ringorder_lp:
-      case ringorder_Dp:
-      case ringorder_Wp:
-      case ringorder_Ds:
-      case ringorder_Ws:
-#else
-      default:
-#endif
-        pSetVarIndicies_Lex(pVariables);
-        pLexSgn = 1;
-        if (pVariablesW == 1)
-          f_pComp0 = f_comp_otCOMPEXP_nwONE;
-        else if (pVariablesW == 2)
-          f_pComp0 = f_comp_otCOMPEXP_nwTWO;
-        else if (pVariablesW & 1)
-          f_pComp0 = f_comp_otCOMPEXP_nwODD;
-        else
-          f_pComp0 = f_comp_otCOMPEXP_nwEVEN;
-#ifdef PDEBUG
-        break;
-      default:
-        Werror("wrong internal ordering:%d at %s, l:%d\n",o_r,__FILE__,__LINE__);
-#endif
-  }
-  if (o_r == ringorder_lp || o_r == ringorder_ls)
-  {
-    pLexOrder=TRUE;
-    pFDeg = pTotaldegree;
-    pLDeg = ldeg1c;
-    if (o_r == ringorder_ls)
-     pSetVarIndicies_Lex(pVariables);
-  }
-  *p = f_pComp0;
-#endif // COMP_FAST  
-
-#ifdef COMP_DEBUG
-    *p = debug_comp;
-#endif  
-}
 
 /*2
@@ -1541,261 +1350,4 @@
 }
 
-#ifdef DIV_COUNT
-struct div_triple
-{
-  unsigned long greater;
-  unsigned long equal;
-  unsigned long smaller;
-};
-
-static div_triple* DivTriples = NULL;
-static int NumberOfDivTriples = 0;
-static unsigned long DivCountTotal = 0;
-static unsigned long DivCountDiv = 0;
-static unsigned long LexDivCount = 0;
-static unsigned long RevLexDivCount = 0;
-static unsigned long LexDivCount2 = 0;
-static unsigned long RevLexDivCount2 = 0;
-static int pVariables2;
-static int pVariablesEven;
-
-void InitDivCount(int nvars)
-{
-  if (nvars & 1) pVariablesEven = 0;
-  else pVariablesEven = 1;
-
-  pVariables2 = (pVariables -1) / 2;
-
-  if (DivTriples == NULL)
-    {
-      DivTriples = (div_triple*) Alloc0(nvars*sizeof(div_triple));
-      NumberOfDivTriples = nvars;
-    }
-  else if (nvars > NumberOfDivTriples)
-    {
-      DivTriples = (div_triple*) ReAlloc(DivTriples, 
-					 NumberOfDivTriples*sizeof(div_triple),
-					 nvars*sizeof(div_triple));
-      for (int i=NumberOfDivTriples; i<nvars; i++)
-	{
-	  DivTriples[i].greater = 0;
-	  DivTriples[i].smaller = 0;
-	  DivTriples[i].equal = 0;
-	}
-
-      NumberOfDivTriples = nvars;
-    }
-}
-
-void ResetDivCount()
-{
-  int i;
-  for (i=0; i<NumberOfDivTriples;i++)
-    {
-      DivTriples[i].greater = 0;
-      DivTriples[i].equal = 0;
-      DivTriples[i].smaller = 0;
-    }
-
-  DivCountTotal = 0;
-  DivCountDiv = 0;
-  LexDivCount = 0;
-  RevLexDivCount = 0;
-  LexDivCount2 = 0;
-  RevLexDivCount2 = 0;
-}
-
-void OutputDivCount()
-{
-  printf("Total      : %10u\n", DivCountTotal);
-  if (DivCountTotal == 0) DivCountTotal++;
-  printf("Div        : %10u \t %.4f\n", DivCountDiv,
-	 (float) DivCountDiv / (float) DivCountTotal);
-  printf("LexCount   :  %10u \t %.4f\n", LexDivCount,
-	 (float) LexDivCount / (float) DivCountTotal);
-  printf("RevLexCount:  %10u \t %.4f\n", RevLexDivCount,
-	 (float) RevLexDivCount / (float) DivCountTotal);
-  printf("LexCount2   :  %10u \t %.4f\n", LexDivCount2,
-	 (float) LexDivCount2 / (float) DivCountTotal);
-  printf("RevLexCount2:  %10u \t %.4f\n", RevLexDivCount2,
-	 (float) RevLexDivCount2 / (float) DivCountTotal);
-
-  for (int i=0; i<NumberOfDivTriples; i++)
-    {
-      unsigned long total = DivTriples[i].greater + 
-	DivTriples[i].equal + DivTriples[i].smaller;
-      // avoid total==0
-      if (total == 0) total=1;
-      printf("  [%d]: %10u (%.4f)  %10u (%.4f)  %10u (%.4f)\n", i,
-	     DivTriples[i].greater, 
-	     (float) DivTriples[i].greater / (float) total ,
-	     DivTriples[i].equal, 
-	     (float) DivTriples[i].equal / (float) total  ,
-	     DivTriples[i].smaller, 
-	     (float) DivTriples[i].smaller / (float) total  );
-    }
-}
-
-BOOLEAN pDivisibleBy(poly a, poly b)
-{
-  if ((a!=NULL)&&(( pGetComp(a)==0) || ( pGetComp(a) ==  pGetComp(b))))
-  {
-    int i;
-    Exponent_t *e1=&( pGetExp(a,1));
-    Exponent_t *e2=&( pGetExp(b,1));
-    BOOLEAN res = TRUE, res2 = TRUE;
-    DivCountTotal++;
-
-    for (i=0; i<pVariables; i++)
-    {
-      if (res == TRUE) LexDivCount++;
-      if (*e1 > *e2) 
-      {
-        DivTriples[i].greater++;
-        res = FALSE;
-      }
-      else if (*e1 == *e2)  DivTriples[i].equal++;
-      else DivTriples[i].smaller++;
-      e1++;
-      e2++;
-    } 
-    if (res == TRUE) DivCountDiv++;
-    e1 = &(pGetExp(a,pVariables));
-    e2 = &(pGetExp(b,pVariables));
-
-    for (i=0; i<pVariables; i++)
-    {
-      RevLexDivCount++;
-      if (*e1 > *e2)
-      {
-        res2 = FALSE;
-        break;
-      }
-      e1--;
-      e2--;
-    }
-    if (res != res2)
-      fprintf(stderr, "Error in RevLexCount\n");
-    
-    if (pVariables < 4) return res;
-    LexTop:
-    res2 = TRUE;
-    int* s1 = (int*) &( pGetExp(a,2));
-    int* s2 = (int*) &( pGetExp(b,2));
-    for (i=0; i<pVariables2; i++, s1++, s2++)
-    {
-      LexDivCount2++;
-      if (*s1 > *s2)
-	  {
-	    res2 = FALSE;
-	    break;
-	  }
-    }
-    if (res2 == TRUE)
-    {
-      LexDivCount2++;
-      if ( pGetExp(a,1) >  pGetExp(b,1)) res2 = FALSE;
-      if (res2 == TRUE && pVariablesEven)
-	  {
-	    LexDivCount2++;
-	    if (pGetExp(a,pVariables) > pGetExp(b,pVariables))
-	      res2 = FALSE;
-	  }
-    }
-    if (res2 == TRUE)
-    {
-      e1 = &( pGetExp(a,2));
-      e2 = &( pGetExp(b,2));
-      for (i=0; i<pVariables2; i++, e1 += 2, e2 += 2)
-      {
-        LexDivCount++;
-#ifdef WORDS_BIG_ENDIAN
-        if (e1[1] > e2[1])
-#else
-        if (*e1 > *e2)
-#endif
-        {
-          res2 = FALSE;
-          break;
-        }
-      }
-    }
-    if (res != res2)
-    {
-      fprintf(stderr, "Error in LexDivCount2\n");
-      // goto LexTop;
-    }
-    
-    RevLexTop:
-    res2 = TRUE;
-    if (pVariablesEven)
-    {
-      s1 = (int*) &(pGetExp(a,pVariables-2));
-      s2 = (int*) &(pGetExp(b,pVariables-2));
-    }
-    else
-    {
-      s1 = (int*) &(pGetExp(a,pVariables-1));
-      s2 = (int*) &(pGetExp(b,pVariables-1));
-    }
-    for (i=0; i< pVariables2; i++, s1--, s2--)
-    {
-      RevLexDivCount2++;
-      if (*s1 > *s2)
-	  {
-	    res2 = FALSE;
-	    break;
-	  }
-    }
-    if (res2 == TRUE)
-    {
-      if (pVariablesEven)
-	  {
-	    RevLexDivCount2++;
-	    if (pGetExp(a,pVariables) > pGetExp(b,pVariables))
-	      res2 = FALSE;
-	  }
-      if (res2 == TRUE)
-	  {
-	    RevLexDivCount2++;
-	    if ( pGetExp(a,1) >  pGetExp(b,1)) res2 = FALSE;
-	  }
-    }
-    if (res2 == TRUE)
-    {
-      if (pVariablesEven)
-      {
-        e1 = &(pGetExp(a,pVariables-2));
-        e2 = &(pGetExp(b,pVariables-2));
-      }
-      else
-      {
-        e1 = &(pGetExp(a,pVariables-1));
-        e2 = &(pGetExp(b,pVariables-1));
-      }
-      for (i=0; i<pVariables2; i++, e1 -= 2, e2 -= 2)
-      {
-#ifdef WORDS_BIG_ENDIAN      
-      if (e1[1] > e2[1])
-#else
-      if (*e1 > *e2)  
-#endif        
-        {
-          res2 = FALSE;
-          break;
-        }
-      }
-    }
-    if (res != res2)
-    {
-      fprintf(stderr, "Error in RevLexDivCount2\n");
-      // goto RevLexTop;
-    }
-    return res;
-  }
-  return FALSE;
-}
-#endif
-
 /* -------------------------------------------------------- */
 /*2
@@ -1819,7 +1371,4 @@
 void pSetGlobals(ring r, BOOLEAN complete)
 {
-#ifdef TEST_MAC_ORDER
-  bNoAdd=FALSE;
-#endif
   int i;
   pComponentOrder=1;
@@ -1829,34 +1378,32 @@
   pAltVars=r->N+1;
 #endif
-#ifdef COMP_FAST
-  f_pComp0 = NULL;
-#endif  
   pVariables = r->N;
 
   // set the various size parameters and initialize memory
-  pMonomSize = POLYSIZE + (pVariables + 1) * sizeof(Exponent_t);
-  if ((pMonomSize % sizeof(void*)) == 0)
-  {
-    pMonomSizeW = pMonomSize/sizeof(void*);
-  }
-  else
-  {
-    pMonomSizeW = pMonomSize/sizeof(void*) + 1;
-    pMonomSize = pMonomSizeW*sizeof(void*);
-  }
-
-#ifdef COMP_FAST  
   if ((((pVariables+1)*sizeof(Exponent_t)) % sizeof(void*)) == 0)
     pVariables1W = (pVariables+1)*sizeof(Exponent_t) / sizeof(void*);
   else
     pVariables1W = ((pVariables+1)*sizeof(Exponent_t) / sizeof(void*)) + 1;
+
   if ((((pVariables)*sizeof(Exponent_t)) % sizeof(void*)) == 0)
     pVariablesW = (pVariables)*sizeof(Exponent_t) / sizeof(void*);
   else
     pVariablesW = ((pVariables)*sizeof(Exponent_t) / sizeof(void*)) + 1;
+
+  pMonomSize = POLYSIZE + (pVariables + 1) * sizeof(Exponent_t);
+  if ((pMonomSize % sizeof(void*)) == 0)
+  {
+    pMonomSizeW = pMonomSize/sizeof(void*);
+  }
+  else
+  {
+    pMonomSizeW = pMonomSize/sizeof(void*) + 1;
+    pMonomSize = pMonomSizeW*sizeof(void*);
+  }
   
   // Set default Var Indicies
   pSetVarIndicies(pVariables);
-#endif
+
+  // Initialize memory management 
   mmSpecializeBlock(pMonomSize);
   
@@ -1886,14 +1433,6 @@
       pComponentOrder=-1;
     if (pOrdSgn == -1) pLDeg = ldeg0c;
-#ifdef COMP_FAST    
     SimpleChoose(order[0],order[1], &pComp0);
-#else    
-    SimpleChoose(order[0],&pComp0);
-#endif    
     SetpSetm(order[0],0);
-#ifdef TEST_MAC_ORDER
-    if (order[0]==ringorder_dp)
-       bBinomSet(order);
-#endif
   }
   /*======== ordering type is (c,_) =========================*/
@@ -1905,14 +1444,6 @@
     if (order[0]==ringorder_C)
       pComponentOrder=-1;
-#ifdef COMP_FAST
-    SimpleChooseC(order[1],pComponentOrder, &pComp0);
-#else    
-    SimpleChooseC(order[1],&pComp0);
-#endif    
+    SimpleChooseC(order[1], &pComp0);
     SetpSetm(order[1],1);
-#ifdef TEST_MAC_ORDER
-    if (order[1]==ringorder_dp)
-       bBinomSet(order);
-#endif
   }
   /*------- more than one block ----------------------*/
@@ -1955,13 +1486,4 @@
     test &= ~Sy_bit(OPT_REDTAIL); /* noredTail */
   }
-
-#ifdef COMP_FAST
-  if (f_pComp0 == NULL)
-    f_pComp0 = pComp0;
-#endif
-  
-#ifdef DIV_COUNT
-  InitDivCount(pVariables);
-#endif
 }
 
@@ -2635,5 +2157,4 @@
 * pair has no common factor ? or is no polynomial
 */
-#ifdef COMP_FAST
 BOOLEAN pHasNotCF(poly p1, poly p2)
 {
@@ -2645,113 +2166,12 @@
   if (pGetComp(p1) > 0 || pGetComp(p2) > 0)
     return FALSE;
-  Exponent_t * m1 = &(p1->exp[pVarLowIndex]);
-  Exponent_t * m2 = &(p2->exp[pVarLowIndex]);
   int i = 1;
   loop
   {
-    if (((*m1) > 0) && ((*m2) > 0))
-      return FALSE;
-    if (i == pVariables)
-      return TRUE;
-    m1++;m2++;
+    if ((pGetExp(p1, i) > 0) && (pGetExp(p2, i) > 0))   return FALSE;
+    if (i == pVariables)                                return TRUE;
     i++;
   }
 }
-#else
-BOOLEAN pHasNotCF(poly p1, poly p2)
-{
-#ifdef SRING
-  if (pSRING)
-    return FALSE;
-#endif
-  short * m1 = p1->exp;
-  short * m2 = p2->exp;
-
-  if (((*m1) > 0)||((*m2) > 0))
-    return FALSE;
-  int i = 1;
-  loop
-  {
-    m1++;m2++;
-    if (((*m1) > 0) && ((*m2) > 0))
-      return FALSE;
-    if (i == pVariables)
-      return TRUE;
-    i++;
-  }
-}
-#endif
-/*
-*void    pSFactors(poly f, poly g, poly a, poly b)
-*{
-*  int i,d;
-*
-*  for (i=pVariables;i>0;i--)
-*  {
-*    d =  pGetExp(f,i)- pGetExp(g,i);
-*    if (d >= 0)
-*    {
-*       pGetExp(a,i) = 0;
-*       pGetExp(b,i) = d;
-*    }
-*    else
-*    {
-*       pGetExp(a,i) = -d;
-*       pGetExp(b,i) = 0;
-*    }
-*  }
-*   pGetComp(a) = 0;
-*   pGetComp(b) = 0;
-*  pSetm(a);
-*  pSetm(b);
-*}
-*/
-
-/*
-*void    pSDiv(poly f, poly g, poly b)
-*{
-*  int i,d;
-*
-*  for (i=pVariables;i>0;i--)
-*  {
-*    d =  pGetExp(f,i)- pGetExp(g,i);
-*     pGetExp(b,i) = d;
-*  }
-*   pGetComp(b) = 0;
-*  pSetm(b);
-*}
-*/
-
-/*2
-* update the initial term of a polynomial a by multipying it by
-* the (number) coefficient
-* and the exponent vector (of) exp (a well initialized polynomial)
-*/
-/*
-*void    pSMultBy(poly f, poly m)
-*{
-*  number t;
-*  int i;
-* //  short notok;
-*
-*  t=nMult(f->coef, m->coef);
-*  nDelete(&(f->coef));
-*  f->coef = t;
-*  f->Order  += m->Order;
-*  for (i=pVariables; i; i--)
-*     pGetExp(f,i) +=  pGetExp(m,i);
-* //  if (notok)
-* //  {
-*    if (!( pGetComp(f)))
-*    {
-*       pGetComp(f) =  pGetComp(m);
-*    }
-* //    else
-* //    {
-* //      HALT;
-* //    }
-* //  }
-*}
-*/
 
 
@@ -2761,26 +2181,27 @@
 *              0 otherwise
 */
-#ifdef COMP_FAST
 int     pDivComp(poly p, poly q)
 {
   if (pGetComp(p) == pGetComp(q))
   {
-    Exponent_t * mp = &(p->exp[pVarLowIndex]);
-    Exponent_t * mq = &(q->exp[pVarLowIndex]);
     int i=pVariables;
+    long d;
     BOOLEAN a=FALSE, b=FALSE;
     for (; i>0; i--)
     {
-      if (*mp<*mq)
+      d = pGetExpDiff(p, q, i);
+      if (d)
       {
-        if (b) return 0;
-        a =TRUE;
+        if (d < 0)
+        {
+          if (b) return 0;
+          a =TRUE;
+        }
+        else
+        {
+          if (a) return 0;
+          b = TRUE;
+        }
       }
-      else if (*mp>*mq)
-      {
-        if (a) return 0;
-        b = TRUE;
-      }
-      mp++;mq++;
     }
     if (a) return 1;
@@ -2789,34 +2210,4 @@
   return 0;
 }
-#else
-int     pDivComp(poly p, poly q)
-{
-  short * mp = p->exp;
-  short * mq = q->exp;
-
-  if (*mp==*mq)
-  {
-    int i=pVariables;
-    BOOLEAN a=FALSE, b=FALSE;
-    for (; i>0; i--)
-    {
-      mp++;mq++;
-      if (*mp<*mq)
-      {
-        if (b) return 0;
-        a =TRUE;
-      }
-      else if (*mp>*mq)
-      {
-        if (a) return 0;
-        b = TRUE;
-      }
-    }
-    if (a) return 1;
-    else if (b)  return -1;
-  }
-  return 0;
-}
-#endif
 /*2
 *divides p1 by its leading monomial
@@ -2951,6 +2342,5 @@
       if (pGetExp(p,j)!=pGetExp(lcm,j))
       {
-        for (k=pVariables; k>j; k--)
-        {
+        for (k=pVariables; k>j; k--)        {
           if ((pGetExp(p,k)!=pGetExp(lcm,k))
           && (pGetExp(p2,k)!=pGetExp(lcm,k)))
@@ -2999,162 +2389,2 @@
 
 
-#ifdef COMP_STATISTICS
-static int s_comp_lp_otCOMPEXP_1(poly p1, poly p2)  
-{
-  MonomCountTotal++;
-
-  OrderCmp(p2, p1,
-           {MonomCountOrderS++; return -1;},
-           {MonomCountOrderG++; return 1;});
-  
-  CompCmp(p2, p1,
-          {MonomCountCompS++; return -pComponentOrder},
-          {MonomCountCompG++; return pComponentOrder});
-
-  MonomCountEqual++;
-  return 0;
-}
-#endif
-
-#ifdef COMP_STATISTICS
-static int s_comp_lp_otCOMPEXP_i(poly p1, poly p2)  
-{
-  MonomCountTotal++;
-
-  OrderCmp(p2, p1,
-           {MonomCountOrderS++; return -1;},
-           {MonomCountOrderG++; return 1;});
-
-  int i = SIZEOF_ORDER / SIZEOF_EXPONENT + 1;
-  Exponent_t d;
-  
-
-  for (;;)
-  {
-    d = pGetExp(p1, i)  - pGetExp(p2, i);
-    if (d)
-    {
-      MonomCountExp[i]++;
-      if (d < 0)
-      {
-        return -1;
-        MonomCountExpS++;
-      }
-      MonomCountExpG++;
-      return 1;
-    }
-    i++;
-    if (i == pVariables) break;
-  }
-  
-  CompCmp(p2, p1,
-          {MonomCountCompS++; return -pComponentOrder},
-          {MonomCountCompG++; return pComponentOrder});
-
-  MonomCountEqual++;
-  return 0;
-}
-#endif
-
-#ifdef MONOM_COUNT
-static void InitMonomCount(unsigned int nvars)
-{
-  if (gMonomCount == NULL)
-  {
-    gMonomCount = (unsigned long *) Alloc0(nvars*sizeof(int));
-    gMonomCountLength = nvars;
-  }
-  else if (gMonomCountLength < nvars)
-  {
-    int i;
-    gMonomCount = (unsigned long *) ReAlloc(gMonomCount,
-                                          gMonomCountLength*sizeof(int),
-                                          nvars*sizeof(int));
-    for (i = gMonomCountLength; i< nvars; i++)
-      gMonomCount[i] = 0; 
-    gMonomCountLength = nvars;
-  }
-}
-
-void OutputMonomCount()
-{
-  unsigned int i;
-  unsigned long max = gMonomCount0;
-  float fmax;
-  unsigned long sum = 0;
-  
-
-  // check that everything went ok
-  if (gMonomCountS !=
-      gMonomCount0 + gMonomCountOrder + gMonomCountL + gMonomCountG)
-  {
-    printf("MonomCountTotalError: %10lu %10lu\n", gMonomCountS,
-           gMonomCount0 + gMonomCountOrder + gMonomCountL + gMonomCountG);
-  }
-  for (i=0; i<gMonomCountLength; i++)
-    sum += gMonomCount[i];
-  if (sum != gMonomCountL + gMonomCountG)
-  {
-    printf("MonomCountNotEqualError: %10lu %10lu\n",
-           gMonomCountL + gMonomCountG, sum);
-  }
-
-  printf("Total   : %10lu\n", gMonomCountS);
-  if (gMonomCountS == 0) gMonomCountS = 1;
-  
-  printf("Order   : %10lu \t %.4f\n",gMonomCountOrder,
-         (float) gMonomCountOrder / (float) gMonomCountS);
-  printf("Equal   : %10lu \t %.4f\n",gMonomCount0,
-         (float) gMonomCount0 / (float) gMonomCountS);
-  printf("NotEqual: %10lu \t %.4f\n",gMonomCountL + gMonomCountG,
-         ((float) gMonomCountL + gMonomCountG) / (float) gMonomCountS);
-  printf("\tGreater: %10lu \t %.4f\n",gMonomCountG,
-         (float) gMonomCountG / (float) gMonomCountS);
-  printf("\tLess   : %10lu \t %.4f\n",gMonomCountL,
-         (float) gMonomCountL / (float) gMonomCountS);
-
-  for (i=0; i<gMonomCountLength; i++)
-  {
-    printf("\t\t[%d]    : %10lu \t %.4f\n", i, gMonomCount[i],
-           (float) gMonomCount[i] / (float) gMonomCountS);
-  }
-  printf("E1Neg   : %10lu \t %.4f\n",gMonomCountN1,
-         (float) gMonomCountN1 / (float) gMonomCountS);
-  printf("E2Neg   : %10lu \t %.4f\n",gMonomCountN2,
-         (float) gMonomCountN2 / (float) gMonomCountS);
-  printf("BothNeg : %10lu \t %.4f\n",gMonomCountNN,
-         (float) gMonomCountNN / (float) gMonomCountS);
-  printf("Mcount2 : %u\n", gMcount2);
-}
-
-void ResetMonomCount()
-{
-  int i;
-
-  for (i=0; i<gMonomCountLength; i++)
-    gMonomCount[i] = 0;
-  gMonomCountOrder = 0;
-  gMonomCount0 = 0;
-  gMonomCountS = 0;
-  gMonomCountG = 0;
-  gMonomCountL = 0;
-  gMonomCountN1 = 0;
-  gMonomCountN2 = 0;
-  gMonomCountNN = 0;
-  gMcount2 = 0;
-}
-
-#endif
-#ifdef MONOM_COUNT
-unsigned long  gMonomCount0 = 0;
-unsigned long  gMonomCountLength = 0;
-unsigned long  gMonomCountOrder = 0;
-unsigned long  gMonomCountG = 0;
-unsigned long  gMonomCountL = 0;
-unsigned long  gMonomCountS = 0;
-unsigned long  gMonomCountN1 = 0;
-unsigned long  gMonomCountN2 = 0;
-unsigned long  gMonomCountNN = 0;
-unsigned long  gMcount2 = 0;
-unsigned long* gMonomCount = NULL;
-#endif
Index: Singular/ring.cc
===================================================================
--- Singular/ring.cc	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/ring.cc	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: ring.cc,v 1.17 1998-03-18 14:28:52 obachman Exp $ */
+/* $Id: ring.cc,v 1.18 1998-03-19 16:05:51 obachman Exp $ */
 
 /*
@@ -1672,7 +1672,28 @@
         r->order[0] != ringorder_M)))
   {
-    if ((r->order[1]==ringorder_c)||(r->order[1]==ringorder_C))
-    {
-      return rOrderType_ExpComp;
+    if ((r->order[1] == ringorder_c) || (r->order[1] == ringorder_C))
+    {
+      switch(r->order[0])
+      {
+          case ringorder_dp:
+          case ringorder_wp:
+          case ringorder_ds:
+          case ringorder_ws:
+          case ringorder_ls:
+          case ringorder_unspec:
+            if (r->order[1] == ringorder_C ||  r->order[0] == ringorder_unspec)
+              return rOrderType_ExpComp;
+            return rOrderType_Exp;
+       
+          default:
+            assume(r->order[1] == ringorder_lp ||
+                   r->order[1] == ringorder_Dp ||
+                   r->order[1] == ringorder_Wp ||
+                   r->order[1] == ringorder_Ds ||
+                   r->order[1] == ringorder_Ws);
+            
+            if (r->order[1] == ringorder_c) return rOrderType_ExpComp;
+            return rOrderType_Exp;
+      }
     }
     else
Index: Singular/ring.h
===================================================================
--- Singular/ring.h	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/ring.h	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -7,5 +7,5 @@
 * ABSTRACT - the interpreter related ring operations
 */
-/* $Id: ring.h,v 1.9 1998-03-16 14:56:41 obachman Exp $ */
+/* $Id: ring.h,v 1.10 1998-03-19 16:05:51 obachman Exp $ */
 
 /* includes */
@@ -72,5 +72,7 @@
   rOrderType_CompExp,     // simple ordering, component has priority 
   rOrderType_ExpComp,     // simple ordering, exponent vector has priority
-  rOrderType_Exp,         // simple ordering, no components involved
+                          // component not compatible with exp-vector order
+  rOrderType_Exp,         // simple ordering, exponent vector has priority
+                          // component is compatible with exp-vector order
   rOrderType_Syz,         // syzygy ordering
   rOrderType_Schreyer     // Schreyer ordering
Index: Singular/spSpolyLoop.cc
===================================================================
--- Singular/spSpolyLoop.cc	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/spSpolyLoop.cc	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -31,5 +31,4 @@
  *
  ***************************************************************/
-#if 1
 void spSpolyLoop_General 
 (poly a1, poly a2, poly monom, poly spNoether)
@@ -100,12 +99,4 @@
    pFree1(b);
 } 
-#else
-extern void spGSpolyLoop(poly a1, poly a2, poly m,poly spNoether);
-void spSpolyLoop_General 
-(poly a1, poly a2, poly m,poly spNoether)
-{
-  spGSpolyLoop(a1, a2, m, spNoether);
-}
-#endif
 
 
@@ -154,15 +145,15 @@
   switch (rot)
   {   
-    rOrderType_Exp:
-    ot = otEXP;
-    break;
+      case rOrderType_Exp:
+        ot = otEXP;
+        break;
     
-    rOrderType_CompExp:
-    ot = otCOMPEXP;
-    break;
+      case rOrderType_CompExp:
+        ot = otCOMPEXP;
+        break;
     
-    rOrderType_ExpComp:
-    ot = otEXPCOMP;
-    break;
+      case rOrderType_ExpComp:
+        ot = otEXPCOMP;
+        break;
 
       default:
@@ -181,15 +172,11 @@
   if (Variables1W > 2)
   {
-    if (Variables1W & 1)
-      nw = nwODD;
-    else
-      nw = nwEVEN;
+    if (Variables1W & 1) nw = nwODD;
+    else nw = nwEVEN;
   }
   else 
   {
-    if (Variables1W == 2)
-      nw = nwTWO;
-    else
-      nw = nwONE;
+    if (Variables1W == 2) nw = nwTWO;
+    else nw = nwONE;
   }
   
Index: Singular/spSpolyLoop.h
===================================================================
--- Singular/spSpolyLoop.h	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/spSpolyLoop.h	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -20,7 +20,14 @@
 void spSpolyLoop_General (poly a1, poly a2, poly monom, poly spNoether);
 
+inline spSpolyLoopProc spGetSpolyLoop(ring r, int modrank, int syzComp, 
+                                      BOOLEAN homog)
+{
+  return spGetSpolyLoop(r, spGetOrderType(r, modrank, syzComp), homog);
+}
+
 inline spSpolyLoopProc spGetSpolyLoop(ring r, kStrategy strat)
 {
-  return spGetSpolyLoop(r, spGetOrderType(r, strat), strat->homog);
+  return spGetSpolyLoop(r, spGetOrderType(r, strat), 
+                        (strat->homog && strat->ak == 0));
 }
 
Index: Singular/spSpolyLoop.pl
===================================================================
--- Singular/spSpolyLoop.pl	(revision 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da)
+++ Singular/spSpolyLoop.pl	(revision 18255d9ac71af356d5f2f1ae0cd213ab439c90ca)
@@ -1,5 +1,5 @@
 #!/usr/local/bin/perl
 ###########################################################################
-# $Id: spSpolyLoop.pl,v 1.1 1998-03-17 10:59:57 obachman Exp $
+# $Id: spSpolyLoop.pl,v 1.2 1998-03-19 16:05:53 obachman Exp $
 
 ###########################################################################
@@ -240,5 +240,5 @@
        c;                                 // used for temporary storage
   number tm   = pGetCoeff(monom),         // coefficient of monom
-         tneg = CALL_NCOPYNEG(tm), // - (coefficient of monom)
+         tneg = CALL_NCOPYNEG(tm),        // - (coefficient of monom)
          tb;                              // used for tm*coeff(a1)
 
@@ -254,4 +254,5 @@
 
   Equal:   // b equals a2
+    assume(pComp0(b, a2) == 0);
     tb = CALL_NMULT("pGetCoeff(a1)",tm);
     if (!CALL_NEQUAL("pGetCoeff(a2)",tb))
@@ -277,4 +278,5 @@
     if (d < 0)  // b < a2: 
     {
+      assume(pComp0(b, a2) == -1);
       a = pNext(a) = a2;// append a2 to result and advance a2
       pIter(a2);
@@ -284,4 +286,5 @@
     else // now d >= 0, i.e., b > a2
     {
+      assume(pComp0(b, a2) == 1);
       pSetCoeff0(b,CALL_NMULT("pGetCoeff(a1)",tneg));
       a = pNext(a) = b;       // append b to result and advance a1
@@ -294,4 +297,5 @@
  
  Finish: // a1 or a2 is NULL: Clean-up time
+   assume(a1 == NULL || a2 == NULL);
    if (a1 == NULL) // append rest of a2 to result
      pNext(a) = a2;
