Changeset 18255d in git
- Timestamp:
- Mar 19, 1998, 5:05:53 PM (25 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 737b2b4e3dd7efb3603cab701c4146ea17e9805e
- Parents:
- 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da
- Location:
- Singular
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ChangeLog
r7f1b91 r18255d 1 1 1998-03-18 Olaf Bachmann <obachman@mathematik.uni-kl.de> 2 2 3 * polys-impl.h: Cleaned up COMP_FAST and related #defines 3 * Makefile.in: added Singularb target for bprof 4 5 * polys-impl.h, polys-comp.h: Cleaned up COMP_FAST and related 6 #defines 4 7 5 8 1998-03-16 Olaf Bachmann <obachman@mathematik.uni-kl.de> -
Singular/ipid.h
r7f1b91 r18255d 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: ipid.h,v 1. 8 1998-01-16 14:29:53 kruegerExp $ */6 /* $Id: ipid.h,v 1.9 1998-03-19 16:05:43 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT: identfier handling … … 37 37 38 38 // what follows below here should be set by rComplete, _only_ 39 #ifdef COMP_FAST40 39 short VarOffset; /* controls indexing of exponents */ 41 short CompIndex; /* index of component in exponent vector */42 #endif43 40 44 41 #ifdef RDEBUG -
Singular/kstd1.cc
r7f1b91 r18255d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd1.cc,v 1.1 5 1998-03-16 14:56:31obachman Exp $ */4 /* $Id: kstd1.cc,v 1.16 1998-03-19 16:05:44 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: … … 1643 1643 initBuchMoraPos(strat); 1644 1644 initMora(F,strat); 1645 #ifdef COMP_FAST 1646 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);1647 #endif 1645 strat->spSpolyLoop = spGetSpolyLoop(currRing, 1646 MAX(strat->ak,pMaxComp(q)), 1647 strat->syzComp, FALSE); 1648 1648 strat->enterS = enterSMoraNF; 1649 1649 /*- set T -*/ … … 1738 1738 strat->enterS = enterSMoraNF; 1739 1739 /*- set T -*/ 1740 #ifdef COMP_FAST 1741 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);1742 #endif 1740 strat->spSpolyLoop = spGetSpolyLoop(currRing, 1741 MAX(strat->ak,idRankFreeModule(q)), 1742 strat->syzComp, FALSE); 1743 1743 strat->tl = -1; 1744 1744 strat->tmax = setmax; … … 1876 1876 strat->homog=h; 1877 1877 spSet(currRing); 1878 #ifdef COMP_FAST1879 1878 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat); 1880 #endif1881 1879 if (pOrdSgn==-1) 1882 1880 { … … 2077 2075 strat->homog=h; 2078 2076 spSet(currRing); 2079 #ifdef COMP_FAST2080 2077 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat); 2081 #endif2082 2078 if (pOrdSgn==-1) 2083 2079 { … … 2153 2149 strat->syzComp = syzComp; 2154 2150 spSet(currRing); 2155 #ifdef COMP_FAST2156 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);2157 #endif2158 2151 if (pOrdSgn==-1) 2159 2152 p=kNF1(F,Q,p,strat,lazyReduce); … … 2174 2167 kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy)); 2175 2168 strat->syzComp = syzComp; 2176 #ifdef COMP_FAST2177 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);2178 #endif2179 2169 if (pOrdSgn==-1) 2180 2170 res=kNF1(F,Q,p,strat,lazyReduce); … … 2217 2207 strat->tmax = setmax; 2218 2208 strat->T = initT(); 2219 #ifdef COMP_FAST2220 2209 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat); 2221 #endif2222 2210 if (pOrdSgn == -1) strat->honey = TRUE; 2223 2211 initS(F,Q,strat); -
Singular/kstd2.cc
r7f1b91 r18255d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd2.cc,v 1.1 2 1998-03-16 14:56:32obachman Exp $ */4 /* $Id: kstd2.cc,v 1.13 1998-03-19 16:05:46 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: alg. of Buchberger … … 1547 1547 /*- set S -*/ 1548 1548 strat->sl = -1; 1549 #ifdef COMP_FAST 1550 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);1551 #endif 1549 // strat->spSpolyLoop = spGetSpolyLoop(currRing, strat); 1550 strat->spSpolyLoop = spGetSpolyLoop(currRing, MAX(strat->ak, pMaxComp(q)), 1551 strat->syzComp, FALSE); 1552 1552 /*- init local data struct.---------------------------------------- -*/ 1553 1553 /*Shdl=*/initS(F,Q,strat); … … 1592 1592 /*- set S -*/ 1593 1593 strat->sl = -1; 1594 #ifdef COMP_FAST 1595 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);1596 #endif 1594 strat->spSpolyLoop = spGetSpolyLoop(currRing, 1595 MAX(strat->ak, idRankFreeModule(q)), 1596 strat->syzComp, FALSE); 1597 1597 /*- init local data struct.---------------------------------------- -*/ 1598 1598 /*Shdl=*/initS(F,Q,strat); … … 1684 1684 strat->homog=h; 1685 1685 spSet(currRing); 1686 #ifdef COMP_FAST1687 1686 strat->spSpolyLoop = spGetSpolyLoop(currRing, strat); 1688 #endif1689 1687 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/ 1690 1688 initBuchMoraPos(strat); -
Singular/kutil.cc
r7f1b91 r18255d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.1 2 1998-03-16 14:56:34obachman Exp $ */4 /* $Id: kutil.cc,v 1.13 1998-03-19 16:05:47 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for std … … 3808 3808 } 3809 3809 3810 rOrderType_t spGetOrderType(ring r, kStrategy strat)3811 { 3812 if (s trat->syzComp > 0)3810 rOrderType_t spGetOrderType(ring r, int modrank, int syzcomp) 3811 { 3812 if (syzcomp > 0) 3813 3813 return rOrderType_Syz; 3814 3814 else … … 3817 3817 3818 3818 if ((rot == rOrderType_CompExp || rot == rOrderType_ExpComp) && 3819 ( strat->ak == 0))3819 (modrank == 0)) 3820 3820 return rOrderType_Exp; 3821 3821 else -
Singular/kutil.h
r7f1b91 r18255d 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: kutil.h,v 1. 5 1998-03-16 14:56:35obachman Exp $ */6 /* $Id: kutil.h,v 1.6 1998-03-19 16:05:48 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT: kernel: utils for std … … 173 173 BOOLEAN homogTest(polyset F, int Fmax); 174 174 BOOLEAN newHEdge(polyset S, int ak,kStrategy strat); 175 rOrderType_t spGetOrderType(ring r, kStrategy strat); 175 176 rOrderType_t spGetOrderType(ring r, int modrank, int syzcomp); 177 inline rOrderType_t spGetOrderType(ring r, kStrategy strat) 178 { 179 return spGetOrderType(r, strat->ak, strat->syzComp); 180 } 181 182 inline int MAX(int a, int b) 183 { 184 if (a > b) return a; 185 else return b; 186 } 187 176 188 177 189 inline TSet initT () { return (TSet)Alloc0(setmax*sizeof(TObject)); } -
Singular/polys-impl.cc
r7f1b91 r18255d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys-impl.cc,v 1.1 0 1998-03-18 14:28:48obachman Exp $ */4 /* $Id: polys-impl.cc,v 1.11 1998-03-19 16:05:49 obachman Exp $ */ 5 5 6 6 /*************************************************************** … … 29 29 #include "ipid.h" 30 30 31 #ifdef COMP_FAST 31 32 /*************************************************************** 32 33 * 33 * definition of global variables34 * Low - level routines for which deal with var indicies 34 35 * 35 36 ***************************************************************/ 36 37 int pVariables;38 int pMonomSize;39 int pMonomSizeW;40 41 #ifdef COMP_FAST42 int pVariables1W;43 int pVariablesW;44 int pVarOffset;45 int pCompIndex;46 int pVarLowIndex;47 int pVarHighIndex;48 #endif49 int pLexSgn;50 51 /***************************************************************52 *53 * Low - level routines for which deal with var indicies54 *55 ***************************************************************/56 #ifdef COMP_FAST57 37 // gets var indicies w.r.t. the ring r 58 38 void pGetVarIndicies(ring r, int &VarOffset, … … 105 85 106 86 107 // assumes that pVarOffset != src_r->VarOffset108 87 inline void RingCopy2ExpV(poly dest, poly src, ring src_r) 109 88 { 110 #if 0111 if (_pHasReverseExp)112 {113 #ifdef WORDS_BIGENDIAN114 for (int i=0, offset = src_r->VarOffset - 1; i<pVariables; i++)115 dest->exp[i] = src->exp[offset - i];116 #else117 #endif118 }119 120 #endif121 89 for (int i=pVariables; i; i--) 122 90 pSetExp(dest, i, pRingGetExp(src_r, src, i)); … … 144 112 if (r->VarOffset == pVarOffset) 145 113 { 146 memcpy(a,p,pMonomSize);114 pCopy2(a,p); 147 115 a->coef=nCopy(p->coef); 148 116 pSetm(a); … … 157 125 a = pNext(a) = pNew(); 158 126 #endif 159 memcpy(a,p,pMonomSize);127 pCopy2(a,p); 160 128 a->coef=nCopy(p->coef); 161 129 pSetm(a); … … 594 562 pCopy2(ptemp, p1); 595 563 596 _ pMonAddFast(p1, p2);564 __pMonAddFast(p1, p2); 597 565 598 566 for (int i=1; i<=pVariables; i++) -
Singular/polys.cc
r7f1b91 r18255d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1.1 7 1998-03-18 14:28:50 obachman Exp $ */4 /* $Id: polys.cc,v 1.18 1998-03-19 16:05:50 obachman Exp $ */ 5 5 6 6 /* … … 21 21 #include "binom.h" 22 22 #include "ipid.h" 23 24 #ifdef COMP_FAST25 23 #include "polys-comp.h" 26 #endif27 24 28 25 /* ----------- global variables, set by pChangeRing --------------------- */ … … 34 31 pFDegProc pFDeg; 35 32 /* the monomial ordering of the head monomials a and b */ 33 /* returns -1 if a comes before b, 0 if a=b, 1 otherwise */ 36 34 pCompProc pComp0; 37 /* returns -1 if a comes before b, 0 if a=b, 1 otherwise */ 38 39 /* the number of variables */ 35 36 int pVariables; // number of variables 37 int pVariablesW; // number of words of pVariables exponents 38 int pVariables1W; // number of words of (pVariables+1) exponents 39 int pMonomSize; // size of monom (in bytes) 40 int pMonomSizeW; // size of monom (in words) 41 int pLexSgn; // 1, for lex monom comps; -1 otherwise (exception: ls) 42 int pVarOffset; // controls the way exponents are stored in a vector 43 int pVarLowIndex; // lowest exponent index 44 int pVarHighIndex; // highest exponent index 45 40 46 /* 1 for polynomial ring, -1 otherwise */ 41 47 int pOrdSgn; … … 47 53 /* TRUE if the monomial ordering has polynomial and power series blocks */ 48 54 BOOLEAN pMixedOrder; 49 50 #if defined(TEST_MAC_ORDER) || defined(COMP_FAST) 55 /* 1 for c ordering, -1 otherwise (i.e. for C ordering) */ 51 56 int pComponentOrder; 52 #else53 static int pComponentOrder;54 #endif55 57 56 58 #ifdef DRING … … 76 78 /*is the basic comparing procedure during a computation of syzygies*/ 77 79 static pCompProc pCompOld; 78 /*for grouping module indecees during computations*/ 79 #ifndef COMP_FAST 80 static int maxBound = 0; 81 #else 82 int maxBound = 0; 83 #endif 80 /*for grouping module indicies during computations*/ 81 int pMaxBound = 0; 84 82 85 83 /*contains the headterms for the Schreyer orderings*/ … … 126 124 { 127 125 p->Order = pExpQuerSum1(p, firstBlockEnds); 128 #ifdef COMP_DEBUG129 int i, j = pGetExp(p,1);130 131 for (i = firstBlockEnds; i > 1; i--) j += pGetExp(p,i);132 if (j != p->Order)133 {134 Print("Error in setdeg1");135 pExpQuerSum1(p, firstBlockEnds);136 }137 #endif138 126 } 139 127 … … 155 143 156 144 /*-------- IMPLEMENTATION OF MONOMIAL COMPARISONS ---------------------*/ 157 158 159 /***************************************************************160 ***************************************************************161 *162 * MONOMIAL COMPARIONS:163 * They are influenced by the following macros:164 * COMP_TRADITIONAL -- (un)set in polys-impl.h165 Keeps the traditional comparison routines166 defined -- needed as long as their might be comparisons with167 negativ components.168 All the traditional routines are prefixed by t_169 170 * COMP_FAST -- (un)set in polys-impl.h171 Implements monomial comparisons using the fast172 techniques. Undefine in case there are problems. All the fast173 routines are prefixed by f_174 175 * COMP_STATISTIC -- (un)set in polys-impl.h176 Provides several routines for accumulating statistics on monomial177 comparisons178 179 * COMP_DEBUG -- (un)set in polys-impl.h180 Turns on debugging of COMP_FAST by comparing the resutsl of fast181 comparison with traditional comparison182 183 *184 *185 ***************************************************************186 ***************************************************************/187 188 #ifdef COMP_DEBUG189 static int debug_comp(poly p1, poly p2);190 #endif // COMP_DEBUG191 192 #ifdef COMP_STATISTICS193 // Initializes, resets and outputs Comp statistics194 void InitCompStatistics(int nvars);195 void ResetCompStatistics();196 void OutputCompStatistics();197 unsigned long MonomCountTotal = 0;198 unsigned long MonomCountOrderS = 0;199 unsigned long MonomCountOrderG = 0;200 unsigned long* MonomCountExp = NULL;201 unsigned long MonomCountExpS = 0;202 unsigned long MonomCountExpG = 0;203 unsigned long MonomCountCompS = 0;204 unsigned long MonomCountCompG = 0;205 unsigned long MonomCountEqual = 0;206 #endif // COMP_STATISTICS207 145 208 146 … … 219 157 while(0) 220 158 221 /***************************************************************222 *223 * FAST COMPARISONS224 *225 ***************************************************************/226 #ifdef COMP_FAST227 static pCompProc f_pComp0 = NULL;228 static int f_comp_otEXP_nwONE(poly p1, poly p2);229 static int f_comp_otCOMPEXP_nwONE(poly p1, poly p2);230 static int f_comp_otEXPCOMP_nwONE(poly p1, poly p2);231 static int f_comp_otEXP_nwTWO(poly p1, poly p2);232 static int f_comp_otCOMPEXP_nwTWO(poly p1, poly p2);233 static int f_comp_otEXPCOMP_nwTWO(poly p1, poly p2);234 static int f_comp_otEXP_nwEVEN(poly p1, poly p2);235 static int f_comp_otCOMPEXP_nwEVEN(poly p1, poly p2);236 static int f_comp_otEXPCOMP_nwEVEN(poly p1, poly p2);237 static int f_comp_otEXP_nwODD(poly p1, poly p2);238 static int f_comp_otCOMPEXP_nwODD(poly p1, poly p2);239 static int f_comp_otEXPCOMP_nwODD(poly p1, poly p2);240 241 159 #define Mreturn(d, multiplier) \ 242 160 { \ … … 244 162 return -multiplier; \ 245 163 } 164 165 static int pComp_otEXP_nwONE(poly p1, poly p2); 166 static int pComp_otCOMPEXP_nwONE(poly p1, poly p2); 167 static int pComp_otEXPCOMP_nwONE(poly p1, poly p2); 168 static int pComp_otEXP_nwTWO(poly p1, poly p2); 169 static int pComp_otCOMPEXP_nwTWO(poly p1, poly p2); 170 static int pComp_otEXPCOMP_nwTWO(poly p1, poly p2); 171 static int pComp_otEXP_nwEVEN(poly p1, poly p2); 172 static int pComp_otCOMPEXP_nwEVEN(poly p1, poly p2); 173 static int pComp_otEXPCOMP_nwEVEN(poly p1, poly p2); 174 static int pComp_otEXP_nwODD(poly p1, poly p2); 175 static int pComp_otCOMPEXP_nwODD(poly p1, poly p2); 176 static int pComp_otEXPCOMP_nwODD(poly p1, poly p2); 177 246 178 247 // comp_nwONE is used if pVariables1W == 1 and component is compatible with ordering 248 static int f_comp_otEXP_nwONE(poly p1, poly p2) 179 // comp_nwONE is used if pVariables1W == 1 and component is compatible 180 // with ordering 181 static int pComp_otEXP_nwONE(poly p1, poly p2) 249 182 { 250 183 register long d = pGetOrder(p1) - pGetOrder(p2); … … 257 190 } 258 191 259 // comp_otEXPCOMP_nwONE is used if pVariables1W == 1, priority is given to exponents,260 // component is incompatible with ordering261 static int f_comp_otEXPCOMP_nwONE(poly p1, poly p2)192 // comp_otEXPCOMP_nwONE : pVariables1W == 1, priority is 193 // given to exponents, component is incompatible with ordering 194 static int pComp_otEXPCOMP_nwONE(poly p1, poly p2) 262 195 { 263 196 register long d = pGetOrder(p1) - pGetOrder(p2); … … 270 203 } 271 204 272 // comp_otEXPCOMP_nwONE is used ifpVariables1W == 1, priority is given to component,205 // comp_otEXPCOMP_nwONE : pVariables1W == 1, priority is given to component, 273 206 // component is incompatible with ordering 274 static int f_comp_otCOMPEXP_nwONE(poly p1, poly p2)207 static int pComp_otCOMPEXP_nwONE(poly p1, poly p2) 275 208 { 276 209 register long d = pGetComp(p2) - pGetComp(p1); … … 284 217 } 285 218 286 // comp_nwTWO is used ifpVariables1W == 2 and component is compatible with ordering287 static int f_comp_otEXP_nwTWO(poly p1, poly p2)219 // comp_nwTWO : pVariables1W == 2 and component is compatible with ordering 220 static int pComp_otEXP_nwTWO(poly p1, poly p2) 288 221 { 289 222 register long d = pGetOrder(p1) - pGetOrder(p2); … … 296 229 } 297 230 298 // comp_otEXPCOMP_nwTWO is used ifpVariables1W == 2, priority is given to exponents,231 // comp_otEXPCOMP_nwTWO : pVariables1W == 2, priority is given to exponents, 299 232 // component is incompatible with ordering 300 static int f_comp_otEXPCOMP_nwTWO(poly p1, poly p2)233 static int pComp_otEXPCOMP_nwTWO(poly p1, poly p2) 301 234 { 302 235 register long d = pGetOrder(p1) - pGetOrder(p2); … … 309 242 } 310 243 311 // comp_otEXPCOMP_nwTWO is used ifpVariables1W == 2, priority is given to component,244 // comp_otEXPCOMP_nwTWO : pVariables1W == 2, priority is given to component, 312 245 // component is incompatible with ordering 313 static int f_comp_otCOMPEXP_nwTWO(poly p1, poly p2)246 static int pComp_otCOMPEXP_nwTWO(poly p1, poly p2) 314 247 { 315 248 register long d = pGetComp(p2) - pGetComp(p1); … … 323 256 } 324 257 325 // comp_nwEVEN is used ifpVariables1W == 2*i and component is compatible258 // comp_nwEVEN : pVariables1W == 2*i and component is compatible 326 259 // with ordering 327 static int f_comp_otEXP_nwEVEN(poly p1, poly p2)260 static int pComp_otEXP_nwEVEN(poly p1, poly p2) 328 261 { 329 262 register long d = pGetOrder(p1) - pGetOrder(p2); … … 336 269 } 337 270 338 // comp_otEXPCOMP_nwEVEN is used ifpVariables1W == 2*i, priority is given to exponents,271 // comp_otEXPCOMP_nwEVEN : pVariables1W == 2*i, priority is given to exponents, 339 272 // component is incompatible with ordering 340 static int f_comp_otEXPCOMP_nwEVEN(poly p1, poly p2)273 static int pComp_otEXPCOMP_nwEVEN(poly p1, poly p2) 341 274 { 342 275 register long d = pGetOrder(p1) - pGetOrder(p2); … … 349 282 } 350 283 351 // comp_otEXPCOMP_nwEVEN is used ifpVariables1W == 2*i, priority is given to component,284 // comp_otEXPCOMP_nwEVEN : pVariables1W == 2*i, priority is given to component, 352 285 // component is incompatible with ordering 353 static int f_comp_otCOMPEXP_nwEVEN(poly p1, poly p2)286 static int pComp_otCOMPEXP_nwEVEN(poly p1, poly p2) 354 287 { 355 288 register long d = pGetComp(p2) - pGetComp(p1); … … 363 296 } 364 297 365 // comp_nwODD is used ifpVariables1W == 2*i and component is compatible298 // comp_nwODD : pVariables1W == 2*i and component is compatible 366 299 // with ordering 367 static int f_comp_otEXP_nwODD(poly p1, poly p2)300 static int pComp_otEXP_nwODD(poly p1, poly p2) 368 301 { 369 302 register long d = pGetOrder(p1) - pGetOrder(p2); … … 376 309 } 377 310 378 // comp_otEXPCOMP_nwODD is used ifpVariables1W == 2*i, priority is given to exponents,311 // comp_otEXPCOMP_nwODD : pVariables1W == 2*i, priority is given to exponents, 379 312 // component is incompatible with ordering 380 static int f_comp_otEXPCOMP_nwODD(poly p1, poly p2)313 static int pComp_otEXPCOMP_nwODD(poly p1, poly p2) 381 314 { 382 315 register long d = pGetOrder(p1) - pGetOrder(p2); … … 393 326 } 394 327 395 // comp_otCOMPEXP_nwODD is used ifpVariables1W == 2*i, priority is given to component,328 // comp_otCOMPEXP_nwODD : pVariables1W == 2*i, priority is given to component, 396 329 // component is incompatible with ordering 397 static int f_comp_otCOMPEXP_nwODD(poly p1, poly p2)330 static int pComp_otCOMPEXP_nwODD(poly p1, poly p2) 398 331 { 399 332 register long d = pGetComp(p2) - pGetComp(p1); … … 406 339 Mreturn(d, pLexSgn); 407 340 } 408 #endif // COMP_FAST409 410 /***************************************************************411 *412 * FAST COMPARISONS413 *414 ***************************************************************/415 #ifdef COMP_TRADITIONAL416 417 static int t_comp_otCOMPEXP_nwONE(poly p1, poly p2);418 static int t_comp_otEXPCOMP_nwONE(poly p1, poly p2);419 static int t_comp_lex_otCOMPEXP_i(poly p1, poly p2);420 static int t_comp_otCOMPEXP_lex_i(poly p1, poly p2);421 static int t_comp_revlex_otCOMPEXP_i(poly p1, poly p2);422 static int t_comp_otCOMPEXP_revlex_i(poly p1, poly p2);423 424 inline long LexComp(poly p1, poly p2)425 {426 long d, i;427 for (i=1; i<pVariables; i++)428 {429 d = pGetExpDiff(p1, p2, i);430 if (d) return d;431 }432 return pGetExpDiff(p1, p2, pVariables);433 }434 435 inline long RevLexComp(poly p1, poly p2)436 {437 long d, i;438 for (i=pVariables; i>1; i--)439 {440 d = pGetExpDiff(p1, p2, i);441 if (d) return d;442 }443 return pGetExpDiff(p1, p2, 1);444 }445 446 static int t_comp_otCOMPEXP_nwONE(poly p1, poly p2)447 {448 NonZeroR(pGetComp(p1) - pGetComp(p2),449 return -pComponentOrder, return pComponentOrder);450 NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);451 return 0;452 }453 454 static int t_comp_otEXPCOMP_nwONE(poly p1, poly p2)455 {456 NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);457 NonZeroR(pGetComp(p1) - pGetComp(p2),458 return -pComponentOrder, return pComponentOrder);459 return 0;460 }461 462 static int t_comp_lex_otCOMPEXP_i(poly p1, poly p2)463 {464 NonZeroR(pGetComp(p1) - pGetComp(p2),465 return -pComponentOrder, return pComponentOrder);466 NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);467 NonZeroR(LexComp(p1, p2), return pLexSgn, return -pLexSgn);468 return 0;469 }470 471 static int t_comp_otEXPCOMP_lex_i(poly p1, poly p2)472 {473 NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);474 NonZeroR(LexComp(p1, p2), return pLexSgn, return -pLexSgn);475 NonZeroR(pGetComp(p1) - pGetComp(p2),476 return -pComponentOrder, return pComponentOrder);477 return 0;478 }479 480 static int t_comp_revlex_otCOMPEXP_i(poly p1, poly p2)481 {482 NonZeroR(pGetComp(p1) - pGetComp(p2),483 return -pComponentOrder, return pComponentOrder);484 NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);485 NonZeroR(RevLexComp(p1, p2), return pLexSgn, return -pLexSgn);486 return 0;487 }488 489 static int t_comp_otEXPCOMP_revlex_i(poly p1, poly p2)490 {491 NonZeroR(pGetOrder(p1) - pGetOrder(p2), return pOrdSgn, return -pOrdSgn);492 NonZeroR(RevLexComp(p1, p2), return pLexSgn, return -pLexSgn);493 NonZeroR(pGetComp(p1) - pGetComp(p2),494 return -pComponentOrder, return pComponentOrder);495 return 0;496 }497 498 #endif // COMP_TRADITIONAL499 500 341 /*2 501 342 * compare the head monomial of p1 and p2 with weight vector … … 503 344 static int comp1a ( poly p1, poly p2, int f, int l, short * w ) 504 345 { 505 int d= p 1->Order - p2->Order;346 int d= pGetOrder(p1) - pGetOrder(p2); 506 347 if ( d > 0 /*p1->Order > p2->Order*/ ) 507 348 return 1; … … 1023 864 static int mcompSyz(poly p1,poly p2) 1024 865 { 1025 if (pGetComp(p1)<= maxBound)1026 { 1027 if (pGetComp(p2)> maxBound) return 1;1028 } 1029 else if (pGetComp(p2)<= maxBound)866 if (pGetComp(p1)<=pMaxBound) 867 { 868 if (pGetComp(p2)>pMaxBound) return 1; 869 } 870 else if (pGetComp(p2)<=pMaxBound) 1030 871 { 1031 872 return -1; … … 1038 879 if (k!=0) 1039 880 { 1040 if ( maxBound==0)881 if (pMaxBound==0) 1041 882 { 1042 883 pCompOld = pComp0; 1043 884 pComp0 = mcompSyz; 1044 885 } 1045 maxBound = k;886 pMaxBound = k; 1046 887 } 1047 888 else 1048 889 { 1049 if ( maxBound!=0)890 if (pMaxBound!=0) 1050 891 { 1051 892 pComp0 = pCompOld; 1052 maxBound = 0;893 pMaxBound = 0; 1053 894 } 1054 895 } … … 1165 1006 int ll=1; 1166 1007 1167 if ( maxBound/*syzComp*/==0)1008 if (pMaxBound/*syzComp*/==0) 1168 1009 { 1169 1010 while ((p=pNext(p))!=NULL) … … 1177 1018 while ((p=pNext(p))!=NULL) 1178 1019 { 1179 if (pGetComp(p)<= maxBound/*syzComp*/)1020 if (pGetComp(p)<=pMaxBound/*syzComp*/) 1180 1021 { 1181 1022 o=pFDeg(p); … … 1245 1086 while ((p=pNext(p))!=NULL) 1246 1087 { 1247 if (( maxBound/*syzComp*/==0) || (pGetComp(p)<=maxBound/*syzComp*/))1088 if ((pMaxBound/*syzComp*/==0) || (pGetComp(p)<=pMaxBound/*syzComp*/)) 1248 1089 { 1249 1090 if ((t=pFDeg(p))>max) max=t; … … 1260 1101 1261 1102 1262 /*2 1263 * sets the comparision routine for monomials: for the first block 1264 * of variables (o_r is the number of the ordering) 1265 */ 1266 #ifdef COMP_FAST 1103 /* 1104 * sets the comparision routine for monomials: for simple monomial orderings 1105 * Priority is given to exponent vector 1106 */ 1267 1107 static void SimpleChoose(int o_r, int comp_order, pCompProc *p) 1268 #else 1269 static void SimpleChoose(int o_r, pCompProc *p) 1270 #endif 1271 { 1272 #ifdef COMP_FAST 1108 { 1273 1109 switch(o_r) 1274 1110 { … … 1283 1119 if (comp_order == ringorder_C || o_r == ringorder_unspec) 1284 1120 { 1285 if (pVariables1W == 1) 1286 f_pComp0 = f_comp_otEXPCOMP_nwONE; 1287 else if (pVariables1W == 2) 1288 f_pComp0 = f_comp_otEXPCOMP_nwTWO; 1289 else if (pVariables1W & 1) 1290 f_pComp0 = f_comp_otEXPCOMP_nwODD; 1291 else 1292 f_pComp0 = f_comp_otEXPCOMP_nwEVEN; 1121 if (pVariables1W == 1) *p = pComp_otEXPCOMP_nwONE; 1122 else if (pVariables1W == 2) *p = pComp_otEXPCOMP_nwTWO; 1123 else if (pVariables1W & 1) *p = pComp_otEXPCOMP_nwODD; 1124 else *p = pComp_otEXPCOMP_nwEVEN; 1293 1125 } 1294 1126 else 1295 1127 { 1296 if (pVariables1W == 1) 1297 f_pComp0 = f_comp_otEXP_nwONE; 1298 else if (pVariables1W == 2) 1299 f_pComp0 = f_comp_otEXP_nwTWO; 1300 else if (pVariables1W & 1) 1301 f_pComp0 = f_comp_otEXP_nwODD; 1302 else 1303 f_pComp0 = f_comp_otEXP_nwEVEN; 1128 // component is compatible with exponent vector 1129 if (pVariables1W == 1) *p = pComp_otEXP_nwONE; 1130 else if (pVariables1W == 2) *p = pComp_otEXP_nwTWO; 1131 else if (pVariables1W & 1) *p = pComp_otEXP_nwODD; 1132 else *p = pComp_otEXP_nwEVEN; 1304 1133 } 1305 1134 break; … … 1318 1147 if (comp_order == ringorder_c) 1319 1148 { 1320 if (pVariables1W == 1) 1321 f_pComp0 = f_comp_otEXPCOMP_nwONE; 1322 else if (pVariables1W == 2) 1323 f_pComp0 = f_comp_otEXPCOMP_nwTWO; 1324 else if (pVariables1W & 1) 1325 f_pComp0 = f_comp_otEXPCOMP_nwODD; 1326 else 1327 f_pComp0 = f_comp_otEXPCOMP_nwEVEN; 1149 if (pVariables1W == 1) *p = pComp_otEXPCOMP_nwONE; 1150 else if (pVariables1W == 2) *p = pComp_otEXPCOMP_nwTWO; 1151 else if (pVariables1W & 1) *p = pComp_otEXPCOMP_nwODD; 1152 else *p = pComp_otEXPCOMP_nwEVEN; 1328 1153 } 1329 1154 else 1330 1155 { 1331 if (pVariables1W == 1) 1332 f_pComp0 = f_comp_otEXP_nwONE; 1333 else if (pVariables1W == 2) 1334 f_pComp0 = f_comp_otEXP_nwTWO; 1335 else if (pVariables1W & 1) 1336 f_pComp0 = f_comp_otEXP_nwODD; 1337 else 1338 f_pComp0 = f_comp_otEXP_nwEVEN; 1156 // component is compatible with exponent vector 1157 if (pVariables1W == 1) *p = pComp_otEXP_nwONE; 1158 else if (pVariables1W == 2) *p = pComp_otEXP_nwTWO; 1159 else if (pVariables1W & 1) *p = pComp_otEXP_nwODD; 1160 else *p = pComp_otEXP_nwEVEN; 1339 1161 } 1340 1162 #ifdef PDEBUG … … 1353 1175 pSetVarIndicies_Lex(pVariables); 1354 1176 } 1355 *p = f_pComp0; 1356 #endif // COMP_FAST 1357 1177 } 1178 1179 /* 1180 * sets the comparision routine for monomials: for simple monomial orderings 1181 * Priority is given to component 1182 */ 1183 static void SimpleChooseC(int o_r, pCompProc *p) 1184 { 1185 switch(o_r) 1186 { 1187 case ringorder_dp: 1188 case ringorder_wp: 1189 case ringorder_ds: 1190 case ringorder_ls: 1191 case ringorder_ws: 1192 pSetVarIndicies_RevLex(pVariables); 1193 pLexSgn = -1; 1194 if (pVariablesW == 1) 1195 *p = pComp_otCOMPEXP_nwONE; 1196 else if (pVariablesW == 2) 1197 *p = pComp_otCOMPEXP_nwTWO; 1198 else if (pVariablesW & 1) 1199 *p = pComp_otCOMPEXP_nwODD; 1200 else 1201 *p = pComp_otCOMPEXP_nwEVEN; 1202 break; 1203 1204 #ifdef PDEBUG 1205 case ringorder_lp: 1206 case ringorder_Dp: 1207 case ringorder_Wp: 1208 case ringorder_Ds: 1209 case ringorder_Ws: 1210 #else 1211 default: 1212 #endif 1213 pSetVarIndicies_Lex(pVariables); 1214 pLexSgn = 1; 1215 if (pVariablesW == 1) 1216 *p = pComp_otCOMPEXP_nwONE; 1217 else if (pVariablesW == 2) 1218 *p = pComp_otCOMPEXP_nwTWO; 1219 else if (pVariablesW & 1) 1220 *p = pComp_otCOMPEXP_nwODD; 1221 else 1222 *p = pComp_otCOMPEXP_nwEVEN; 1223 #ifdef PDEBUG 1224 break; 1225 default: 1226 Werror("wrong internal ordering:%d at %s, l:%d\n",o_r,__FILE__,__LINE__); 1227 #endif 1228 } 1229 if (o_r == ringorder_lp || o_r == ringorder_ls) 1230 { 1231 pLexOrder=TRUE; 1232 pFDeg = pTotaldegree; 1233 pLDeg = ldeg1c; 1234 if (o_r == ringorder_ls) 1235 pSetVarIndicies_Lex(pVariables); 1236 } 1358 1237 } 1359 1238 … … 1401 1280 } 1402 1281 1403 /*21404 * sets the comparision routine for monomials: for the first block1405 * of variables (o_r is the number of the ordering)1406 */1407 #ifdef COMP_FAST1408 static void SimpleChooseC(int o_r, int comp_order, pCompProc *p)1409 #else1410 static void SimpleChooseC(int o_r, pCompProc *p)1411 #endif1412 {1413 #ifdef COMP_FAST1414 switch(o_r)1415 {1416 case ringorder_dp:1417 case ringorder_wp:1418 case ringorder_ds:1419 case ringorder_ls:1420 case ringorder_ws:1421 pSetVarIndicies_RevLex(pVariables);1422 pLexSgn = -1;1423 if (pVariablesW == 1)1424 f_pComp0 = f_comp_otCOMPEXP_nwONE;1425 else if (pVariablesW == 2)1426 f_pComp0 = f_comp_otCOMPEXP_nwTWO;1427 else if (pVariablesW & 1)1428 f_pComp0 = f_comp_otCOMPEXP_nwODD;1429 else1430 f_pComp0 = f_comp_otCOMPEXP_nwEVEN;1431 break;1432 1433 #ifdef PDEBUG1434 case ringorder_lp:1435 case ringorder_Dp:1436 case ringorder_Wp:1437 case ringorder_Ds:1438 case ringorder_Ws:1439 #else1440 default:1441 #endif1442 pSetVarIndicies_Lex(pVariables);1443 pLexSgn = 1;1444 if (pVariablesW == 1)1445 f_pComp0 = f_comp_otCOMPEXP_nwONE;1446 else if (pVariablesW == 2)1447 f_pComp0 = f_comp_otCOMPEXP_nwTWO;1448 else if (pVariablesW & 1)1449 f_pComp0 = f_comp_otCOMPEXP_nwODD;1450 else1451 f_pComp0 = f_comp_otCOMPEXP_nwEVEN;1452 #ifdef PDEBUG1453 break;1454 default:1455 Werror("wrong internal ordering:%d at %s, l:%d\n",o_r,__FILE__,__LINE__);1456 #endif1457 }1458 if (o_r == ringorder_lp || o_r == ringorder_ls)1459 {1460 pLexOrder=TRUE;1461 pFDeg = pTotaldegree;1462 pLDeg = ldeg1c;1463 if (o_r == ringorder_ls)1464 pSetVarIndicies_Lex(pVariables);1465 }1466 *p = f_pComp0;1467 #endif // COMP_FAST1468 1469 #ifdef COMP_DEBUG1470 *p = debug_comp;1471 #endif1472 }1473 1282 1474 1283 /*2 … … 1541 1350 } 1542 1351 1543 #ifdef DIV_COUNT1544 struct div_triple1545 {1546 unsigned long greater;1547 unsigned long equal;1548 unsigned long smaller;1549 };1550 1551 static div_triple* DivTriples = NULL;1552 static int NumberOfDivTriples = 0;1553 static unsigned long DivCountTotal = 0;1554 static unsigned long DivCountDiv = 0;1555 static unsigned long LexDivCount = 0;1556 static unsigned long RevLexDivCount = 0;1557 static unsigned long LexDivCount2 = 0;1558 static unsigned long RevLexDivCount2 = 0;1559 static int pVariables2;1560 static int pVariablesEven;1561 1562 void InitDivCount(int nvars)1563 {1564 if (nvars & 1) pVariablesEven = 0;1565 else pVariablesEven = 1;1566 1567 pVariables2 = (pVariables -1) / 2;1568 1569 if (DivTriples == NULL)1570 {1571 DivTriples = (div_triple*) Alloc0(nvars*sizeof(div_triple));1572 NumberOfDivTriples = nvars;1573 }1574 else if (nvars > NumberOfDivTriples)1575 {1576 DivTriples = (div_triple*) ReAlloc(DivTriples,1577 NumberOfDivTriples*sizeof(div_triple),1578 nvars*sizeof(div_triple));1579 for (int i=NumberOfDivTriples; i<nvars; i++)1580 {1581 DivTriples[i].greater = 0;1582 DivTriples[i].smaller = 0;1583 DivTriples[i].equal = 0;1584 }1585 1586 NumberOfDivTriples = nvars;1587 }1588 }1589 1590 void ResetDivCount()1591 {1592 int i;1593 for (i=0; i<NumberOfDivTriples;i++)1594 {1595 DivTriples[i].greater = 0;1596 DivTriples[i].equal = 0;1597 DivTriples[i].smaller = 0;1598 }1599 1600 DivCountTotal = 0;1601 DivCountDiv = 0;1602 LexDivCount = 0;1603 RevLexDivCount = 0;1604 LexDivCount2 = 0;1605 RevLexDivCount2 = 0;1606 }1607 1608 void OutputDivCount()1609 {1610 printf("Total : %10u\n", DivCountTotal);1611 if (DivCountTotal == 0) DivCountTotal++;1612 printf("Div : %10u \t %.4f\n", DivCountDiv,1613 (float) DivCountDiv / (float) DivCountTotal);1614 printf("LexCount : %10u \t %.4f\n", LexDivCount,1615 (float) LexDivCount / (float) DivCountTotal);1616 printf("RevLexCount: %10u \t %.4f\n", RevLexDivCount,1617 (float) RevLexDivCount / (float) DivCountTotal);1618 printf("LexCount2 : %10u \t %.4f\n", LexDivCount2,1619 (float) LexDivCount2 / (float) DivCountTotal);1620 printf("RevLexCount2: %10u \t %.4f\n", RevLexDivCount2,1621 (float) RevLexDivCount2 / (float) DivCountTotal);1622 1623 for (int i=0; i<NumberOfDivTriples; i++)1624 {1625 unsigned long total = DivTriples[i].greater +1626 DivTriples[i].equal + DivTriples[i].smaller;1627 // avoid total==01628 if (total == 0) total=1;1629 printf(" [%d]: %10u (%.4f) %10u (%.4f) %10u (%.4f)\n", i,1630 DivTriples[i].greater,1631 (float) DivTriples[i].greater / (float) total ,1632 DivTriples[i].equal,1633 (float) DivTriples[i].equal / (float) total ,1634 DivTriples[i].smaller,1635 (float) DivTriples[i].smaller / (float) total );1636 }1637 }1638 1639 BOOLEAN pDivisibleBy(poly a, poly b)1640 {1641 if ((a!=NULL)&&(( pGetComp(a)==0) || ( pGetComp(a) == pGetComp(b))))1642 {1643 int i;1644 Exponent_t *e1=&( pGetExp(a,1));1645 Exponent_t *e2=&( pGetExp(b,1));1646 BOOLEAN res = TRUE, res2 = TRUE;1647 DivCountTotal++;1648 1649 for (i=0; i<pVariables; i++)1650 {1651 if (res == TRUE) LexDivCount++;1652 if (*e1 > *e2)1653 {1654 DivTriples[i].greater++;1655 res = FALSE;1656 }1657 else if (*e1 == *e2) DivTriples[i].equal++;1658 else DivTriples[i].smaller++;1659 e1++;1660 e2++;1661 }1662 if (res == TRUE) DivCountDiv++;1663 e1 = &(pGetExp(a,pVariables));1664 e2 = &(pGetExp(b,pVariables));1665 1666 for (i=0; i<pVariables; i++)1667 {1668 RevLexDivCount++;1669 if (*e1 > *e2)1670 {1671 res2 = FALSE;1672 break;1673 }1674 e1--;1675 e2--;1676 }1677 if (res != res2)1678 fprintf(stderr, "Error in RevLexCount\n");1679 1680 if (pVariables < 4) return res;1681 LexTop:1682 res2 = TRUE;1683 int* s1 = (int*) &( pGetExp(a,2));1684 int* s2 = (int*) &( pGetExp(b,2));1685 for (i=0; i<pVariables2; i++, s1++, s2++)1686 {1687 LexDivCount2++;1688 if (*s1 > *s2)1689 {1690 res2 = FALSE;1691 break;1692 }1693 }1694 if (res2 == TRUE)1695 {1696 LexDivCount2++;1697 if ( pGetExp(a,1) > pGetExp(b,1)) res2 = FALSE;1698 if (res2 == TRUE && pVariablesEven)1699 {1700 LexDivCount2++;1701 if (pGetExp(a,pVariables) > pGetExp(b,pVariables))1702 res2 = FALSE;1703 }1704 }1705 if (res2 == TRUE)1706 {1707 e1 = &( pGetExp(a,2));1708 e2 = &( pGetExp(b,2));1709 for (i=0; i<pVariables2; i++, e1 += 2, e2 += 2)1710 {1711 LexDivCount++;1712 #ifdef WORDS_BIG_ENDIAN1713 if (e1[1] > e2[1])1714 #else1715 if (*e1 > *e2)1716 #endif1717 {1718 res2 = FALSE;1719 break;1720 }1721 }1722 }1723 if (res != res2)1724 {1725 fprintf(stderr, "Error in LexDivCount2\n");1726 // goto LexTop;1727 }1728 1729 RevLexTop:1730 res2 = TRUE;1731 if (pVariablesEven)1732 {1733 s1 = (int*) &(pGetExp(a,pVariables-2));1734 s2 = (int*) &(pGetExp(b,pVariables-2));1735 }1736 else1737 {1738 s1 = (int*) &(pGetExp(a,pVariables-1));1739 s2 = (int*) &(pGetExp(b,pVariables-1));1740 }1741 for (i=0; i< pVariables2; i++, s1--, s2--)1742 {1743 RevLexDivCount2++;1744 if (*s1 > *s2)1745 {1746 res2 = FALSE;1747 break;1748 }1749 }1750 if (res2 == TRUE)1751 {1752 if (pVariablesEven)1753 {1754 RevLexDivCount2++;1755 if (pGetExp(a,pVariables) > pGetExp(b,pVariables))1756 res2 = FALSE;1757 }1758 if (res2 == TRUE)1759 {1760 RevLexDivCount2++;1761 if ( pGetExp(a,1) > pGetExp(b,1)) res2 = FALSE;1762 }1763 }1764 if (res2 == TRUE)1765 {1766 if (pVariablesEven)1767 {1768 e1 = &(pGetExp(a,pVariables-2));1769 e2 = &(pGetExp(b,pVariables-2));1770 }1771 else1772 {1773 e1 = &(pGetExp(a,pVariables-1));1774 e2 = &(pGetExp(b,pVariables-1));1775 }1776 for (i=0; i<pVariables2; i++, e1 -= 2, e2 -= 2)1777 {1778 #ifdef WORDS_BIG_ENDIAN1779 if (e1[1] > e2[1])1780 #else1781 if (*e1 > *e2)1782 #endif1783 {1784 res2 = FALSE;1785 break;1786 }1787 }1788 }1789 if (res != res2)1790 {1791 fprintf(stderr, "Error in RevLexDivCount2\n");1792 // goto RevLexTop;1793 }1794 return res;1795 }1796 return FALSE;1797 }1798 #endif1799 1800 1352 /* -------------------------------------------------------- */ 1801 1353 /*2 … … 1819 1371 void pSetGlobals(ring r, BOOLEAN complete) 1820 1372 { 1821 #ifdef TEST_MAC_ORDER1822 bNoAdd=FALSE;1823 #endif1824 1373 int i; 1825 1374 pComponentOrder=1; … … 1829 1378 pAltVars=r->N+1; 1830 1379 #endif 1831 #ifdef COMP_FAST1832 f_pComp0 = NULL;1833 #endif1834 1380 pVariables = r->N; 1835 1381 1836 1382 // set the various size parameters and initialize memory 1837 pMonomSize = POLYSIZE + (pVariables + 1) * sizeof(Exponent_t);1838 if ((pMonomSize % sizeof(void*)) == 0)1839 {1840 pMonomSizeW = pMonomSize/sizeof(void*);1841 }1842 else1843 {1844 pMonomSizeW = pMonomSize/sizeof(void*) + 1;1845 pMonomSize = pMonomSizeW*sizeof(void*);1846 }1847 1848 #ifdef COMP_FAST1849 1383 if ((((pVariables+1)*sizeof(Exponent_t)) % sizeof(void*)) == 0) 1850 1384 pVariables1W = (pVariables+1)*sizeof(Exponent_t) / sizeof(void*); 1851 1385 else 1852 1386 pVariables1W = ((pVariables+1)*sizeof(Exponent_t) / sizeof(void*)) + 1; 1387 1853 1388 if ((((pVariables)*sizeof(Exponent_t)) % sizeof(void*)) == 0) 1854 1389 pVariablesW = (pVariables)*sizeof(Exponent_t) / sizeof(void*); 1855 1390 else 1856 1391 pVariablesW = ((pVariables)*sizeof(Exponent_t) / sizeof(void*)) + 1; 1392 1393 pMonomSize = POLYSIZE + (pVariables + 1) * sizeof(Exponent_t); 1394 if ((pMonomSize % sizeof(void*)) == 0) 1395 { 1396 pMonomSizeW = pMonomSize/sizeof(void*); 1397 } 1398 else 1399 { 1400 pMonomSizeW = pMonomSize/sizeof(void*) + 1; 1401 pMonomSize = pMonomSizeW*sizeof(void*); 1402 } 1857 1403 1858 1404 // Set default Var Indicies 1859 1405 pSetVarIndicies(pVariables); 1860 #endif 1406 1407 // Initialize memory management 1861 1408 mmSpecializeBlock(pMonomSize); 1862 1409 … … 1886 1433 pComponentOrder=-1; 1887 1434 if (pOrdSgn == -1) pLDeg = ldeg0c; 1888 #ifdef COMP_FAST1889 1435 SimpleChoose(order[0],order[1], &pComp0); 1890 #else1891 SimpleChoose(order[0],&pComp0);1892 #endif1893 1436 SetpSetm(order[0],0); 1894 #ifdef TEST_MAC_ORDER1895 if (order[0]==ringorder_dp)1896 bBinomSet(order);1897 #endif1898 1437 } 1899 1438 /*======== ordering type is (c,_) =========================*/ … … 1905 1444 if (order[0]==ringorder_C) 1906 1445 pComponentOrder=-1; 1907 #ifdef COMP_FAST 1908 SimpleChooseC(order[1],pComponentOrder, &pComp0); 1909 #else 1910 SimpleChooseC(order[1],&pComp0); 1911 #endif 1446 SimpleChooseC(order[1], &pComp0); 1912 1447 SetpSetm(order[1],1); 1913 #ifdef TEST_MAC_ORDER1914 if (order[1]==ringorder_dp)1915 bBinomSet(order);1916 #endif1917 1448 } 1918 1449 /*------- more than one block ----------------------*/ … … 1955 1486 test &= ~Sy_bit(OPT_REDTAIL); /* noredTail */ 1956 1487 } 1957 1958 #ifdef COMP_FAST1959 if (f_pComp0 == NULL)1960 f_pComp0 = pComp0;1961 #endif1962 1963 #ifdef DIV_COUNT1964 InitDivCount(pVariables);1965 #endif1966 1488 } 1967 1489 … … 2635 2157 * pair has no common factor ? or is no polynomial 2636 2158 */ 2637 #ifdef COMP_FAST2638 2159 BOOLEAN pHasNotCF(poly p1, poly p2) 2639 2160 { … … 2645 2166 if (pGetComp(p1) > 0 || pGetComp(p2) > 0) 2646 2167 return FALSE; 2647 Exponent_t * m1 = &(p1->exp[pVarLowIndex]);2648 Exponent_t * m2 = &(p2->exp[pVarLowIndex]);2649 2168 int i = 1; 2650 2169 loop 2651 2170 { 2652 if (((*m1) > 0) && ((*m2) > 0)) 2653 return FALSE; 2654 if (i == pVariables) 2655 return TRUE; 2656 m1++;m2++; 2171 if ((pGetExp(p1, i) > 0) && (pGetExp(p2, i) > 0)) return FALSE; 2172 if (i == pVariables) return TRUE; 2657 2173 i++; 2658 2174 } 2659 2175 } 2660 #else2661 BOOLEAN pHasNotCF(poly p1, poly p2)2662 {2663 #ifdef SRING2664 if (pSRING)2665 return FALSE;2666 #endif2667 short * m1 = p1->exp;2668 short * m2 = p2->exp;2669 2670 if (((*m1) > 0)||((*m2) > 0))2671 return FALSE;2672 int i = 1;2673 loop2674 {2675 m1++;m2++;2676 if (((*m1) > 0) && ((*m2) > 0))2677 return FALSE;2678 if (i == pVariables)2679 return TRUE;2680 i++;2681 }2682 }2683 #endif2684 /*2685 *void pSFactors(poly f, poly g, poly a, poly b)2686 *{2687 * int i,d;2688 *2689 * for (i=pVariables;i>0;i--)2690 * {2691 * d = pGetExp(f,i)- pGetExp(g,i);2692 * if (d >= 0)2693 * {2694 * pGetExp(a,i) = 0;2695 * pGetExp(b,i) = d;2696 * }2697 * else2698 * {2699 * pGetExp(a,i) = -d;2700 * pGetExp(b,i) = 0;2701 * }2702 * }2703 * pGetComp(a) = 0;2704 * pGetComp(b) = 0;2705 * pSetm(a);2706 * pSetm(b);2707 *}2708 */2709 2710 /*2711 *void pSDiv(poly f, poly g, poly b)2712 *{2713 * int i,d;2714 *2715 * for (i=pVariables;i>0;i--)2716 * {2717 * d = pGetExp(f,i)- pGetExp(g,i);2718 * pGetExp(b,i) = d;2719 * }2720 * pGetComp(b) = 0;2721 * pSetm(b);2722 *}2723 */2724 2725 /*22726 * update the initial term of a polynomial a by multipying it by2727 * the (number) coefficient2728 * and the exponent vector (of) exp (a well initialized polynomial)2729 */2730 /*2731 *void pSMultBy(poly f, poly m)2732 *{2733 * number t;2734 * int i;2735 * // short notok;2736 *2737 * t=nMult(f->coef, m->coef);2738 * nDelete(&(f->coef));2739 * f->coef = t;2740 * f->Order += m->Order;2741 * for (i=pVariables; i; i--)2742 * pGetExp(f,i) += pGetExp(m,i);2743 * // if (notok)2744 * // {2745 * if (!( pGetComp(f)))2746 * {2747 * pGetComp(f) = pGetComp(m);2748 * }2749 * // else2750 * // {2751 * // HALT;2752 * // }2753 * // }2754 *}2755 */2756 2176 2757 2177 … … 2761 2181 * 0 otherwise 2762 2182 */ 2763 #ifdef COMP_FAST2764 2183 int pDivComp(poly p, poly q) 2765 2184 { 2766 2185 if (pGetComp(p) == pGetComp(q)) 2767 2186 { 2768 Exponent_t * mp = &(p->exp[pVarLowIndex]);2769 Exponent_t * mq = &(q->exp[pVarLowIndex]);2770 2187 int i=pVariables; 2188 long d; 2771 2189 BOOLEAN a=FALSE, b=FALSE; 2772 2190 for (; i>0; i--) 2773 2191 { 2774 if (*mp<*mq) 2192 d = pGetExpDiff(p, q, i); 2193 if (d) 2775 2194 { 2776 if (b) return 0; 2777 a =TRUE; 2195 if (d < 0) 2196 { 2197 if (b) return 0; 2198 a =TRUE; 2199 } 2200 else 2201 { 2202 if (a) return 0; 2203 b = TRUE; 2204 } 2778 2205 } 2779 else if (*mp>*mq)2780 {2781 if (a) return 0;2782 b = TRUE;2783 }2784 mp++;mq++;2785 2206 } 2786 2207 if (a) return 1; … … 2789 2210 return 0; 2790 2211 } 2791 #else2792 int pDivComp(poly p, poly q)2793 {2794 short * mp = p->exp;2795 short * mq = q->exp;2796 2797 if (*mp==*mq)2798 {2799 int i=pVariables;2800 BOOLEAN a=FALSE, b=FALSE;2801 for (; i>0; i--)2802 {2803 mp++;mq++;2804 if (*mp<*mq)2805 {2806 if (b) return 0;2807 a =TRUE;2808 }2809 else if (*mp>*mq)2810 {2811 if (a) return 0;2812 b = TRUE;2813 }2814 }2815 if (a) return 1;2816 else if (b) return -1;2817 }2818 return 0;2819 }2820 #endif2821 2212 /*2 2822 2213 *divides p1 by its leading monomial … … 2951 2342 if (pGetExp(p,j)!=pGetExp(lcm,j)) 2952 2343 { 2953 for (k=pVariables; k>j; k--) 2954 { 2344 for (k=pVariables; k>j; k--) { 2955 2345 if ((pGetExp(p,k)!=pGetExp(lcm,k)) 2956 2346 && (pGetExp(p2,k)!=pGetExp(lcm,k))) … … 2999 2389 3000 2390 3001 #ifdef COMP_STATISTICS3002 static int s_comp_lp_otCOMPEXP_1(poly p1, poly p2)3003 {3004 MonomCountTotal++;3005 3006 OrderCmp(p2, p1,3007 {MonomCountOrderS++; return -1;},3008 {MonomCountOrderG++; return 1;});3009 3010 CompCmp(p2, p1,3011 {MonomCountCompS++; return -pComponentOrder},3012 {MonomCountCompG++; return pComponentOrder});3013 3014 MonomCountEqual++;3015 return 0;3016 }3017 #endif3018 3019 #ifdef COMP_STATISTICS3020 static int s_comp_lp_otCOMPEXP_i(poly p1, poly p2)3021 {3022 MonomCountTotal++;3023 3024 OrderCmp(p2, p1,3025 {MonomCountOrderS++; return -1;},3026 {MonomCountOrderG++; return 1;});3027 3028 int i = SIZEOF_ORDER / SIZEOF_EXPONENT + 1;3029 Exponent_t d;3030 3031 3032 for (;;)3033 {3034 d = pGetExp(p1, i) - pGetExp(p2, i);3035 if (d)3036 {3037 MonomCountExp[i]++;3038 if (d < 0)3039 {3040 return -1;3041 MonomCountExpS++;3042 }3043 MonomCountExpG++;3044 return 1;3045 }3046 i++;3047 if (i == pVariables) break;3048 }3049 3050 CompCmp(p2, p1,3051 {MonomCountCompS++; return -pComponentOrder},3052 {MonomCountCompG++; return pComponentOrder});3053 3054 MonomCountEqual++;3055 return 0;3056 }3057 #endif3058 3059 #ifdef MONOM_COUNT3060 static void InitMonomCount(unsigned int nvars)3061 {3062 if (gMonomCount == NULL)3063 {3064 gMonomCount = (unsigned long *) Alloc0(nvars*sizeof(int));3065 gMonomCountLength = nvars;3066 }3067 else if (gMonomCountLength < nvars)3068 {3069 int i;3070 gMonomCount = (unsigned long *) ReAlloc(gMonomCount,3071 gMonomCountLength*sizeof(int),3072 nvars*sizeof(int));3073 for (i = gMonomCountLength; i< nvars; i++)3074 gMonomCount[i] = 0;3075 gMonomCountLength = nvars;3076 }3077 }3078 3079 void OutputMonomCount()3080 {3081 unsigned int i;3082 unsigned long max = gMonomCount0;3083 float fmax;3084 unsigned long sum = 0;3085 3086 3087 // check that everything went ok3088 if (gMonomCountS !=3089 gMonomCount0 + gMonomCountOrder + gMonomCountL + gMonomCountG)3090 {3091 printf("MonomCountTotalError: %10lu %10lu\n", gMonomCountS,3092 gMonomCount0 + gMonomCountOrder + gMonomCountL + gMonomCountG);3093 }3094 for (i=0; i<gMonomCountLength; i++)3095 sum += gMonomCount[i];3096 if (sum != gMonomCountL + gMonomCountG)3097 {3098 printf("MonomCountNotEqualError: %10lu %10lu\n",3099 gMonomCountL + gMonomCountG, sum);3100 }3101 3102 printf("Total : %10lu\n", gMonomCountS);3103 if (gMonomCountS == 0) gMonomCountS = 1;3104 3105 printf("Order : %10lu \t %.4f\n",gMonomCountOrder,3106 (float) gMonomCountOrder / (float) gMonomCountS);3107 printf("Equal : %10lu \t %.4f\n",gMonomCount0,3108 (float) gMonomCount0 / (float) gMonomCountS);3109 printf("NotEqual: %10lu \t %.4f\n",gMonomCountL + gMonomCountG,3110 ((float) gMonomCountL + gMonomCountG) / (float) gMonomCountS);3111 printf("\tGreater: %10lu \t %.4f\n",gMonomCountG,3112 (float) gMonomCountG / (float) gMonomCountS);3113 printf("\tLess : %10lu \t %.4f\n",gMonomCountL,3114 (float) gMonomCountL / (float) gMonomCountS);3115 3116 for (i=0; i<gMonomCountLength; i++)3117 {3118 printf("\t\t[%d] : %10lu \t %.4f\n", i, gMonomCount[i],3119 (float) gMonomCount[i] / (float) gMonomCountS);3120 }3121 printf("E1Neg : %10lu \t %.4f\n",gMonomCountN1,3122 (float) gMonomCountN1 / (float) gMonomCountS);3123 printf("E2Neg : %10lu \t %.4f\n",gMonomCountN2,3124 (float) gMonomCountN2 / (float) gMonomCountS);3125 printf("BothNeg : %10lu \t %.4f\n",gMonomCountNN,3126 (float) gMonomCountNN / (float) gMonomCountS);3127 printf("Mcount2 : %u\n", gMcount2);3128 }3129 3130 void ResetMonomCount()3131 {3132 int i;3133 3134 for (i=0; i<gMonomCountLength; i++)3135 gMonomCount[i] = 0;3136 gMonomCountOrder = 0;3137 gMonomCount0 = 0;3138 gMonomCountS = 0;3139 gMonomCountG = 0;3140 gMonomCountL = 0;3141 gMonomCountN1 = 0;3142 gMonomCountN2 = 0;3143 gMonomCountNN = 0;3144 gMcount2 = 0;3145 }3146 3147 #endif3148 #ifdef MONOM_COUNT3149 unsigned long gMonomCount0 = 0;3150 unsigned long gMonomCountLength = 0;3151 unsigned long gMonomCountOrder = 0;3152 unsigned long gMonomCountG = 0;3153 unsigned long gMonomCountL = 0;3154 unsigned long gMonomCountS = 0;3155 unsigned long gMonomCountN1 = 0;3156 unsigned long gMonomCountN2 = 0;3157 unsigned long gMonomCountNN = 0;3158 unsigned long gMcount2 = 0;3159 unsigned long* gMonomCount = NULL;3160 #endif -
Singular/ring.cc
r7f1b91 r18255d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.1 7 1998-03-18 14:28:52obachman Exp $ */4 /* $Id: ring.cc,v 1.18 1998-03-19 16:05:51 obachman Exp $ */ 5 5 6 6 /* … … 1672 1672 r->order[0] != ringorder_M))) 1673 1673 { 1674 if ((r->order[1]==ringorder_c)||(r->order[1]==ringorder_C)) 1675 { 1676 return rOrderType_ExpComp; 1674 if ((r->order[1] == ringorder_c) || (r->order[1] == ringorder_C)) 1675 { 1676 switch(r->order[0]) 1677 { 1678 case ringorder_dp: 1679 case ringorder_wp: 1680 case ringorder_ds: 1681 case ringorder_ws: 1682 case ringorder_ls: 1683 case ringorder_unspec: 1684 if (r->order[1] == ringorder_C || r->order[0] == ringorder_unspec) 1685 return rOrderType_ExpComp; 1686 return rOrderType_Exp; 1687 1688 default: 1689 assume(r->order[1] == ringorder_lp || 1690 r->order[1] == ringorder_Dp || 1691 r->order[1] == ringorder_Wp || 1692 r->order[1] == ringorder_Ds || 1693 r->order[1] == ringorder_Ws); 1694 1695 if (r->order[1] == ringorder_c) return rOrderType_ExpComp; 1696 return rOrderType_Exp; 1697 } 1677 1698 } 1678 1699 else -
Singular/ring.h
r7f1b91 r18255d 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1. 9 1998-03-16 14:56:41 obachman Exp $ */9 /* $Id: ring.h,v 1.10 1998-03-19 16:05:51 obachman Exp $ */ 10 10 11 11 /* includes */ … … 72 72 rOrderType_CompExp, // simple ordering, component has priority 73 73 rOrderType_ExpComp, // simple ordering, exponent vector has priority 74 rOrderType_Exp, // simple ordering, no components involved 74 // component not compatible with exp-vector order 75 rOrderType_Exp, // simple ordering, exponent vector has priority 76 // component is compatible with exp-vector order 75 77 rOrderType_Syz, // syzygy ordering 76 78 rOrderType_Schreyer // Schreyer ordering -
Singular/spSpolyLoop.cc
r7f1b91 r18255d 31 31 * 32 32 ***************************************************************/ 33 #if 134 33 void spSpolyLoop_General 35 34 (poly a1, poly a2, poly monom, poly spNoether) … … 100 99 pFree1(b); 101 100 } 102 #else103 extern void spGSpolyLoop(poly a1, poly a2, poly m,poly spNoether);104 void spSpolyLoop_General105 (poly a1, poly a2, poly m,poly spNoether)106 {107 spGSpolyLoop(a1, a2, m, spNoether);108 }109 #endif110 101 111 102 … … 154 145 switch (rot) 155 146 { 156 rOrderType_Exp:157 ot = otEXP;158 break;147 case rOrderType_Exp: 148 ot = otEXP; 149 break; 159 150 160 rOrderType_CompExp:161 ot = otCOMPEXP;162 break;151 case rOrderType_CompExp: 152 ot = otCOMPEXP; 153 break; 163 154 164 rOrderType_ExpComp:165 ot = otEXPCOMP;166 break;155 case rOrderType_ExpComp: 156 ot = otEXPCOMP; 157 break; 167 158 168 159 default: … … 181 172 if (Variables1W > 2) 182 173 { 183 if (Variables1W & 1) 184 nw = nwODD; 185 else 186 nw = nwEVEN; 174 if (Variables1W & 1) nw = nwODD; 175 else nw = nwEVEN; 187 176 } 188 177 else 189 178 { 190 if (Variables1W == 2) 191 nw = nwTWO; 192 else 193 nw = nwONE; 179 if (Variables1W == 2) nw = nwTWO; 180 else nw = nwONE; 194 181 } 195 182 -
Singular/spSpolyLoop.h
r7f1b91 r18255d 20 20 void spSpolyLoop_General (poly a1, poly a2, poly monom, poly spNoether); 21 21 22 inline spSpolyLoopProc spGetSpolyLoop(ring r, int modrank, int syzComp, 23 BOOLEAN homog) 24 { 25 return spGetSpolyLoop(r, spGetOrderType(r, modrank, syzComp), homog); 26 } 27 22 28 inline spSpolyLoopProc spGetSpolyLoop(ring r, kStrategy strat) 23 29 { 24 return spGetSpolyLoop(r, spGetOrderType(r, strat), strat->homog); 30 return spGetSpolyLoop(r, spGetOrderType(r, strat), 31 (strat->homog && strat->ak == 0)); 25 32 } 26 33 -
Singular/spSpolyLoop.pl
r7f1b91 r18255d 1 1 #!/usr/local/bin/perl 2 2 ########################################################################### 3 # $Id: spSpolyLoop.pl,v 1. 1 1998-03-17 10:59:57obachman Exp $3 # $Id: spSpolyLoop.pl,v 1.2 1998-03-19 16:05:53 obachman Exp $ 4 4 5 5 ########################################################################### … … 240 240 c; // used for temporary storage 241 241 number tm = pGetCoeff(monom), // coefficient of monom 242 tneg = CALL_NCOPYNEG(tm), // - (coefficient of monom)242 tneg = CALL_NCOPYNEG(tm), // - (coefficient of monom) 243 243 tb; // used for tm*coeff(a1) 244 244 … … 254 254 255 255 Equal: // b equals a2 256 assume(pComp0(b, a2) == 0); 256 257 tb = CALL_NMULT("pGetCoeff(a1)",tm); 257 258 if (!CALL_NEQUAL("pGetCoeff(a2)",tb)) … … 277 278 if (d < 0) // b < a2: 278 279 { 280 assume(pComp0(b, a2) == -1); 279 281 a = pNext(a) = a2;// append a2 to result and advance a2 280 282 pIter(a2); … … 284 286 else // now d >= 0, i.e., b > a2 285 287 { 288 assume(pComp0(b, a2) == 1); 286 289 pSetCoeff0(b,CALL_NMULT("pGetCoeff(a1)",tneg)); 287 290 a = pNext(a) = b; // append b to result and advance a1 … … 294 297 295 298 Finish: // a1 or a2 is NULL: Clean-up time 299 assume(a1 == NULL || a2 == NULL); 296 300 if (a1 == NULL) // append rest of a2 to result 297 301 pNext(a) = a2;
Note: See TracChangeset
for help on using the changeset viewer.