Changeset 1aa55bf in git
- Timestamp:
- Oct 16, 2000, 2:06:41 PM (24 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- dc078459b7830eda29e3e82e01acd64423bbddc0
- Parents:
- b559f83182d4517c4869319c1caa185e21439112
- Location:
- Singular
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/Makefile.in
rb559f8 r1aa55bf 116 116 pp_Mult_mm__Template.cc p_Mult_mm__Template.cc \ 117 117 p_Minus_mm_Mult_qq__Template.cc p_Add_q__Template.cc \ 118 p_Neg__Template.cc kInline.cc 118 p_Neg__Template.cc pp_Mult_Coeff_mm_DivSelect__Template.cc \ 119 kInline.cc utils.cc utils.h 119 120 120 121 … … 129 130 fglm.h kstd1.h modulop.h sing_dbm.h weight.h \ 130 131 fglmgauss.h fglmvec.h mpsr.h sing_mp.h \ 131 kstdfac.h mpsr_Get.h \132 kstdfac.h mpsr_Get.h kmatrix.h\ 132 133 kutil.h mpsr_Put.h sing_dld.h\ 133 134 ndbm.h polys-impl.h libparse.h \ -
Singular/extra.cc
rb559f8 r1aa55bf 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: extra.cc,v 1.14 6 2000-09-25 12:26:30obachman Exp $ */4 /* $Id: extra.cc,v 1.147 2000-10-16 12:06:34 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: general interface to internals of Singular ("system" command) … … 741 741 #endif 742 742 /*==================== pDivStat =============================*/ 743 #if def PDEBUG743 #if defined(PDEBUG) || defined(PDIV_DEBUG) 744 744 if(strcmp(sys_cmd,"pDivStat")==0) 745 745 { -
Singular/kspoly.cc
rb559f8 r1aa55bf 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kspoly.cc,v 1.1 1 2000-10-04 13:12:01obachman Exp $ */4 /* $Id: kspoly.cc,v 1.12 2000-10-16 12:06:34 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT - Routines for Spoly creation and reductions … … 22 22 23 23 24 #define NEW_STUFF25 26 #ifdef NEW_STUFF27 24 /*************************************************************** 28 25 * … … 99 96 p_LmDelete(lm, tailRing); 100 97 } 101 #endif102 98 103 99 /*************************************************************** … … 107 103 * 108 104 ***************************************************************/ 109 #ifdef NEW_STUFF110 105 void ksCreateSpoly(LObject* Pair,poly spNoether, 111 106 int use_buckets, ring tailRing) … … 189 184 } 190 185 } 191 #endif 192 193 ////////////////////////////////////////////////////////////////////////// 194 // Reduces PR at Current->next with PW 195 // Assumes PR != NULL, Current contained in PR 196 // Current->next != NULL, LM(PW) devides LM(Current->next) 197 // Changes: PR 198 // Const: PW 199 #ifdef NEW_STUFF 200 void ksSpolyTail(LObject* PR, TObject* PW, poly Current, poly spNoether) 201 { 202 poly Lp = PR->p; 203 number coef; 204 poly Save = PW->p; 205 ring lmRing = PR->lmRing; 206 207 assume(Lp != NULL && Current != NULL && pNext(Current) != NULL); 208 assume(PR->bucket == NULL); 209 pAssume(pIsMonomOf(Lp, Current)); 210 211 if (Lp == Save) 212 PW->p = p_Copy(Save, currRing, PR->tailRing); 213 214 215 PR->p = pNext(Current); 216 PR->lmRing = PR->tailRing; 217 ksReducePoly(PR, PW, spNoether, &coef); 218 219 if (! n_IsOne(coef, currRing)) 220 { 221 pNext(Current) = NULL; 222 p_Mult_nn(Lp, coef, currRing, PR->tailRing); 223 } 224 n_Delete(&coef, currRing); 225 pNext(Current) = PR->p; 226 PR->p = Lp; 227 PR->lmRing = lmRing; 228 if (PW->p != Save) 229 { 230 p_Delete(&(PW->p), currRing, PR->tailRing); 231 PW->p = Save; // == Lp 232 } 233 } 234 235 #endif 236 237 #ifndef NEW_STUFF 238 239 void ksReducePoly(LObject* PR, 240 TObject* PW, 241 poly spNoether, 242 number *coef) 243 { 244 poly p1 = PR->p; 245 poly p2 = PW->p; 246 247 assume(p2 != NULL && p1 != NULL && pDivisibleBy(p2, p1)); 248 assume(pGetComp(p1) == pGetComp(p2) || 249 (pMaxComp(p2) == 0)); 250 251 poly a2 = pNext(p2), lm = p1; 252 253 p1 = pNext(p1); 254 255 if (a2==NULL) 256 { 257 pDeleteLm(&lm); 258 PR->p = p1; 259 if (coef != NULL) *coef = nInit(1); 260 return; 261 } 262 263 if (! nIsOne(pGetCoeff(p2))) 264 { 265 number bn = pGetCoeff(lm); 266 number an = pGetCoeff(p2); 267 int ct = ksCheckCoeff(&an, &bn); 268 pSetCoeff(lm, bn); 269 if ((ct == 0) || (ct == 2)) 270 p1 = pMult_nn(p1, an); 271 if (coef != NULL) *coef = an; 272 else nDelete(&an); 273 } 274 else 275 { 276 if (coef != NULL) *coef = nInit(1); 277 } 278 279 280 // pMonSubFrom(lm, p2); 281 pExpVectorSub(lm, p2); 282 int dummy; 283 PR->p = currRing->p_Procs->p_Minus_mm_Mult_qq(p1, lm, a2, 284 dummy, spNoether, currRing); 285 286 pDeleteLm(&lm); 287 } 288 #endif 289 290 #ifndef NEW_STUFF 291 292 /*************************************************************** 293 * 294 * Creates S-Poly of p1 and p2 295 * 296 * 297 ***************************************************************/ 298 void ksCreateSpoly(LObject* Pair, 299 poly spNoether, 300 int use_buckets, ring tailRing) 301 { 302 assume(kTest_L(Pair)); 303 poly p1 = Pair->p1; 304 poly p2 = Pair->p2; 305 306 assume(p1 != NULL); 307 assume(p2 != NULL); 308 309 poly a1 = pNext(p1), a2 = pNext(p2); 310 number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2); 311 poly m1, m2; 312 int co=0, ct = ksCheckCoeff(&lc1, &lc2); 313 int x, l1; 314 315 if (pGetComp(p1)!=pGetComp(p2)) 316 { 317 if (pGetComp(p1)==0) 318 { 319 co=1; 320 pSetCompP(p1,pGetComp(p2)); 321 } 322 else 323 { 324 co=2; 325 pSetCompP(p2,pGetComp(p1)); 326 } 327 } 328 329 // get m1 = LCM(LM(p1), LM(p2))/LM(p1) 330 // m2 = LCM(LM(p1), LM(p2))/LM(p2) 331 m1 = pInit(); 332 m2 = pInit(); 333 for (int i = pVariables; i; i--) 334 { 335 x = pGetExpDiff(p1, p2, i); 336 if (x > 0) 337 { 338 pSetExp(m2,i,x); 339 pSetExp(m1,i,0); 340 } 341 else 342 { 343 pSetExp(m1,i,-x); 344 pSetExp(m2,i,0); 345 } 346 } 347 pSetm(m1); 348 pSetm(m2); // now we have m1 * LM(p1) == m2 * LM(p2) 349 pSetCoeff0(m1, lc2); 350 pSetCoeff0(m2, lc1); // and now, m1 * LT(p1) == m2 * LT(p2) 351 352 // get m2 * a2 353 a2 = currRing->p_Procs->pp_Mult_mm(a2, m2, spNoether, currRing); 354 355 // and, finally, the spoly 356 int dummy; 357 Pair->p = currRing->p_Procs->p_Minus_mm_Mult_qq(a2, m1, a1, 358 dummy, spNoether, 359 currRing); 360 361 // Clean-up time 362 pDeleteLm(&m1); 363 pDeleteLm(&m2); 364 365 if (co != 0) 366 { 367 if (co==1) 368 { 369 pSetCompP(p1,0); 370 } 371 else 372 { 373 pSetCompP(p2,0); 374 } 375 } 376 } 377 #endif 378 379 #ifndef NEW_STUFF 186 380 187 ////////////////////////////////////////////////////////////////////////// 381 188 // Reduces PR at Current->next with PW … … 389 196 number coef; 390 197 poly Save = PW->p; 391 198 ring lmRing = PR->lmRing; 199 200 assume(Lp != NULL && Current != NULL && pNext(Current) != NULL); 201 assume(PR->bucket == NULL); 202 pAssume(pIsMonomOf(Lp, Current)); 203 392 204 if (Lp == Save) 393 PW->p = pCopy(Save); 394 395 assume(Lp != NULL && Current != NULL && pNext(Current) != NULL); 396 assume(pIsMonomOf(Lp, Current)); 205 PW->p = p_Copy(Save, currRing, PR->tailRing); 206 397 207 398 208 PR->p = pNext(Current); 209 PR->lmRing = PR->tailRing; 399 210 ksReducePoly(PR, PW, spNoether, &coef); 400 211 401 if (! n IsOne(coef))212 if (! n_IsOne(coef, currRing)) 402 213 { 403 214 pNext(Current) = NULL; 404 p Mult_nn(Lp, coef);405 } 406 n Delete(&coef);215 p_Mult_nn(Lp, coef, currRing, PR->tailRing); 216 } 217 n_Delete(&coef, currRing); 407 218 pNext(Current) = PR->p; 408 219 PR->p = Lp; 220 PR->lmRing = lmRing; 409 221 if (PW->p != Save) 410 222 { 411 p Delete(&(PW->p));223 p_Delete(&(PW->p), currRing, PR->tailRing); 412 224 PW->p = Save; // == Lp 413 225 } 414 226 } 415 416 #endif417 227 418 228 /*************************************************************** -
Singular/kstd2.cc
rb559f8 r1aa55bf 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd2.cc,v 1. 49 2000-10-04 13:12:02obachman Exp $ */4 /* $Id: kstd2.cc,v 1.50 2000-10-16 12:06:35 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: alg. of Buchberger … … 188 188 189 189 poly pi; 190 int i,j,at,reddeg,d,pass,ei, ii ;190 int i,j,at,reddeg,d,pass,ei, ii, h_d; 191 191 unsigned long not_sev; 192 192 … … 300 300 h->sev = pGetShortExpVector(h->p); 301 301 not_sev = ~ h->sev; 302 h_d = pFDeg(h->p); 302 303 /* compute the ecart */ 303 304 if (ei <= (*h).ecart) 304 (*h).ecart = d- pFDeg((*h).p);305 (*h).ecart = d-h_d; 305 306 else 306 (*h).ecart = d- pFDeg((*h).p)+ei-(*h).ecart;307 (*h).ecart = d-h_d+ei-(*h).ecart; 307 308 /* 308 309 * try to reduce the s-polynomial h … … 312 313 */ 313 314 pass++; 314 d = pFDeg((*h).p)+(*h).ecart;315 d = h_d +(*h).ecart; 315 316 if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) 316 317 { -
Singular/kutil.cc
rb559f8 r1aa55bf 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.6 4 2000-10-04 13:12:03obachman Exp $ */4 /* $Id: kutil.cc,v 1.65 2000-10-16 12:06:35 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for kStd … … 27 27 #include "kutil.h" 28 28 29 /* Hmm ... this should be inlined or made more efficient:30 see Long/mregular.tst */31 /*232 *should return 1 if p divides q and p<q,33 * -1 if q divides p and q<p34 * 0 otherwise35 */36 static inline int pDivComp(poly p, poly q)37 {38 if (pGetComp(p) == pGetComp(q))39 {40 int i=pVariables;41 long d;42 BOOLEAN a=FALSE, b=FALSE;43 for (; i>0; i--)44 {45 d = pGetExpDiff(p, q, i);46 if (d)47 {48 if (d < 0)49 {50 if (b) return 0;51 a =TRUE;52 }53 else54 {55 if (a) return 0;56 b = TRUE;57 }58 }59 }60 if (a) return 1;61 else if (b) return -1;62 }63 return 0;64 }65 29 66 30 static poly redMora (poly h,int maxIndex,kStrategy strat); 67 31 static poly redBba (poly h,int maxIndex,kStrategy strat); 32 33 static inline int pDivComp(poly p, poly q) 34 { 35 if (pGetComp(p) == pGetComp(q)) 36 { 37 BOOLEAN a=FALSE, b=FALSE; 38 int i; 39 unsigned long la, lb; 40 unsigned long divmask = currRing->divmask; 41 for (i=0; i<currRing->VarL_Size; i++) 42 { 43 la = p->exp[currRing->VarL_Offset[i]]; 44 lb = q->exp[currRing->VarL_Offset[i]]; 45 if (la != lb) 46 { 47 if (la < lb) 48 { 49 if (b) return 0; 50 if (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)) 51 return 0; 52 a = TRUE; 53 } 54 else 55 { 56 if (a) return 0; 57 if (((la & divmask) ^ (lb & divmask)) != ((la - lb) & divmask)) 58 return 0; 59 b = TRUE; 60 } 61 } 62 } 63 if (a) return 1; 64 if (b) return -1; 65 } 66 return 0; 67 } 68 68 69 69 70 BITSET test=(BITSET)0; -
Singular/kutil.h
rb559f8 r1aa55bf 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: kutil.h,v 1.3 2 2000-10-04 13:12:03obachman Exp $ */6 /* $Id: kutil.h,v 1.33 2000-10-16 12:06:36 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT: kernel: utils for kStd … … 34 34 { 35 35 memset((void*) this, 0, sizeof(sTObject)); 36 } 37 sTObject(poly _p) 38 { 39 memset((void*) this, 0, sizeof(sTObject)); 40 p = _p; 36 41 } 37 42 }; … … 52 57 memset((void*) this, 0, sizeof(sLObject)); 53 58 lmRing = tailRing = currRing; 59 } 60 sLObject(poly _p) 61 { 62 memset((void*) this, 0, sizeof(sLObject)); 63 lmRing = tailRing = currRing; 64 p = _p; 54 65 } 55 66 // spoly related things -
Singular/pDebug.cc
rb559f8 r1aa55bf 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pDebug.cc,v 1. 5 2000-09-25 12:26:35obachman Exp $9 * Version: $Id: pDebug.cc,v 1.6 2000-10-16 12:06:36 obachman Exp $ 10 10 *******************************************************************/ 11 11 … … 100 100 * 101 101 ***************************************************************/ 102 static int pDivisibleBy_number = 1; 103 static int pDivisibleBy_FALSE = 1; 104 static int pDivisibleBy_ShortFalse = 1; 105 BOOLEAN pDebugLmShortDivisibleBy(poly p1, unsigned long sev_1, ring r_1, 106 poly p2, unsigned long not_sev_2, ring r_2) 107 { 108 _pPolyAssume(p_GetShortExpVector(p1, r_1) == sev_1, p1, r_1); 109 _pPolyAssume(p_GetShortExpVector(p2, r_2) == ~ not_sev_2, p2, r_2); 110 111 pDivisibleBy_number++; 112 BOOLEAN ret = p_LmDivisibleBy(p1, r_1, p2, r_2); 113 if (! ret) pDivisibleBy_FALSE++; 114 if (sev_1 & not_sev_2) 115 { 116 pDivisibleBy_ShortFalse++; 117 if (ret) 118 dReportError("p1 divides p2, but sev's are wrong"); 119 } 120 return ret; 121 } 122 123 void pPrintDivisbleByStat() 124 { 125 Print("#Tests: %d; #FALSE %d(%d); #SHORT %d(%d)\n", 126 pDivisibleBy_number, 127 pDivisibleBy_FALSE, pDivisibleBy_FALSE*100/pDivisibleBy_number, 128 pDivisibleBy_ShortFalse, pDivisibleBy_ShortFalse*100/pDivisibleBy_FALSE); 129 } 102 BOOLEAN p_DebugLmDivisibleByNoComp(poly a, poly b, ring r) 103 { 104 int i=r->N; 105 106 do 107 { 108 if (p_GetExp(a,i,r) > p_GetExp(b,i,r)) 109 return FALSE; 110 i--; 111 } 112 while (i); 113 return TRUE; 114 } 115 130 116 131 117 /*************************************************************** … … 297 283 298 284 #endif // PDEBUG 285 286 #include "pInline1.h" 287 288 #if defined(PDEBUG) || defined(PDIV_DEBUG) 289 static unsigned long pDivisibleBy_number = 1; 290 static unsigned long pDivisibleBy_FALSE = 1; 291 static unsigned long pDivisibleBy_ShortFalse = 1; 292 BOOLEAN pDebugLmShortDivisibleBy(poly p1, unsigned long sev_1, ring r_1, 293 poly p2, unsigned long not_sev_2, ring r_2) 294 { 295 _pPolyAssume(p_GetShortExpVector(p1, r_1) == sev_1, p1, r_1); 296 _pPolyAssume(p_GetShortExpVector(p2, r_2) == ~ not_sev_2, p2, r_2); 297 298 pDivisibleBy_number++; 299 BOOLEAN ret; 300 if (r_1 == r_2) 301 ret = p_LmDivisibleBy(p1, p2, r_1); 302 else 303 ret = p_LmDivisibleBy(p1, r_1, p2, r_2); 304 305 if (! ret) pDivisibleBy_FALSE++; 306 if (sev_1 & not_sev_2) 307 { 308 pDivisibleBy_ShortFalse++; 309 if (ret) 310 dReportError("p1 divides p2, but sev's are wrong"); 311 } 312 return ret; 313 } 314 315 void pPrintDivisbleByStat() 316 { 317 Print("#Tests: %d; #FALSE %d(%d); #SHORT %d(%d)\n", 318 pDivisibleBy_number, 319 pDivisibleBy_FALSE, (unsigned long) ((double)pDivisibleBy_FALSE*((double) 100)/(double)pDivisibleBy_number), 320 pDivisibleBy_ShortFalse, (unsigned long) ((double)pDivisibleBy_ShortFalse*((double)100)/(double)pDivisibleBy_FALSE)); 321 } 322 #endif 323 299 324 #endif // PDEBUG_CC 300 325 -
Singular/pInline1.h
rb559f8 r1aa55bf 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline1.h,v 1. 5 2000-10-04 13:12:04obachman Exp $9 * Version: $Id: pInline1.h,v 1.6 2000-10-16 12:06:36 obachman Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE1_H … … 44 44 #ifdef PDIV_DEBUG 45 45 BOOLEAN pDebugLmShortDivisibleBy(poly p1, unsigned long sev_1, ring r_1, 46 poly p2, unsigned long not_sev_2, ring r_2); 46 poly p2, unsigned long not_sev_2, ring r_2); 47 BOOLEAN p_DebugLmDivisibleByNoComp(poly a, poly b, ring r); 48 #define pDivAssume pAssume 49 #else 50 #define pDivAssume(x) ((void)0) 47 51 #endif 48 52 … … 149 153 p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpLSize); 150 154 } 155 // ExpVector(p1) += ExpVector(p2) - ExpVector(p3) 156 PINLINE1 void p_ExpVectorAddSub(poly p1, poly p2, poly p3, ring r) 157 { 158 p_CheckPolyRing1(p1, r); 159 p_CheckPolyRing1(p2, r); 160 p_CheckPolyRing1(p3, r); 161 #if PDEBUG >= 1 162 for (int i=1; i<=r->N; i++) 163 pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r)); 164 pAssume1(p_GetComp(p1, r) == 0 || 165 (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) || 166 (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r))); 167 #endif 168 169 p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpLSize); 170 } 151 171 // ExpVector(pr) = ExpVector(p1) + ExpVector(p2) 152 172 PINLINE1 void p_ExpVectorSum(poly pr, poly p1, poly p2, ring r) … … 249 269 * 250 270 ***************************************************************/ 271 // return: FALSE, if there exists i, such that a->exp[i] > b->exp[i] 272 // TRUE, otherwise 273 // (1) Consider long vars, instead of single exponents 274 // (2) Clearly, if la > lb, then FALSE 275 // (3) Suppose la <= lb, and consider first bits of single exponents in l: 276 // if TRUE, then value of these bits is la ^ lb 277 // if FALSE, then la-lb causes an "overflow" into one of those bits, i.e., 278 // la ^ lb != la - lb 251 279 static inline BOOLEAN _p_LmDivisibleByNoComp(poly a, poly b, ring r) 252 280 { 253 int i=r->N; 254 255 do 256 { 257 if (p_GetExp(a,i,r) > p_GetExp(b,i,r)) 258 return FALSE; 259 i--; 260 } 261 while (i); 281 int i=r->VarL_Size - 1; 282 unsigned long divmask = r->divmask; 283 unsigned long la, lb; 284 285 if (r->VarL_LowIndex >= 0) 286 { 287 i += r->VarL_LowIndex; 288 do 289 { 290 la = a->exp[i]; 291 lb = b->exp[i]; 292 if ((la > lb) || 293 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask))) 294 { 295 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == FALSE); 296 return FALSE; 297 } 298 i--; 299 } 300 while (i>=r->VarL_LowIndex); 301 } 302 else 303 { 304 do 305 { 306 la = a->exp[r->VarL_Offset[i]]; 307 lb = b->exp[r->VarL_Offset[i]]; 308 if ((la > lb) || 309 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask))) 310 { 311 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == FALSE); 312 return FALSE; 313 } 314 i--; 315 } 316 while (i>=0); 317 } 318 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == TRUE); 262 319 return TRUE; 263 320 } 321 264 322 static inline BOOLEAN _p_LmDivisibleByNoComp(poly a, ring r_a, poly b, ring r_b) 265 323 { -
Singular/pInline2.h
rb559f8 r1aa55bf 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline2.h,v 1. 7 2000-10-04 13:12:04obachman Exp $9 * Version: $Id: pInline2.h,v 1.8 2000-10-16 12:06:37 obachman Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE2_H … … 387 387 } 388 388 389 PINLINE2 poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r) 390 { 391 return r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, r); 392 } 393 389 394 // returns -p, destroys p 390 395 PINLINE2 poly p_Neg(poly p, const ring r) -
Singular/p_MemAdd.h
rb559f8 r1aa55bf 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: p_MemAdd.h,v 1. 2 2000-09-12 16:01:06obachman Exp $9 * Version: $Id: p_MemAdd.h,v 1.3 2000-10-16 12:06:37 obachman Exp $ 10 10 *******************************************************************/ 11 11 #ifndef P_MEM_ADD_H … … 366 366 while (0) 367 367 368 #define _p_MemAddSub_Declare(r, s, t) \ 369 const unsigned long* _s = ((unsigned long*) s); \ 370 const unsigned long* _t = ((unsigned long*) t); \ 371 unsigned long* _r = ((unsigned long*) r) 372 373 #define p_MemAddSub_LengthGeneral(r, s, t, length) \ 374 do \ 375 { \ 376 _p_MemAddSub_Declare(r,s, t); \ 377 const unsigned long _l = (unsigned long) length; \ 378 unsigned long _i = 0; \ 379 \ 380 do \ 381 { \ 382 _r[_i] += _s[_i] - _t[_i]; \ 383 _i++; \ 384 } \ 385 while (_i != _l); \ 386 } \ 387 while (0) 388 368 389 #endif P_MEM_ADD_H 390 -
Singular/p_Procs.cc
rb559f8 r1aa55bf 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: p_Procs.cc,v 1.1 4 2000-10-04 15:37:54obachman Exp $9 * Version: $Id: p_Procs.cc,v 1.15 2000-10-16 12:06:37 obachman Exp $ 10 10 *******************************************************************/ 11 11 #include <string.h> … … 46 46 // 5 -- all Field*_Length*_Ord* procs 47 47 #ifdef NDEBUG 48 const int HAVE_FAST_P_PROCS = 2;48 const int HAVE_FAST_P_PROCS = 3; 49 49 #else 50 50 const int HAVE_FAST_P_PROCS = 0; … … 64 64 // 3 -- special cases for length <= 4 65 65 // 4 -- special cases for length <= 8 66 const int HAVE_FAST_LENGTH = 4;66 const int HAVE_FAST_LENGTH = 3; 67 67 68 68 // Set HAVE_FAST_ORD to: … … 180 180 p_Minus_mm_Mult_qq_Proc, 181 181 p_Neg_Proc, 182 pp_Mult_Coeff_mm_DivSelect_Proc, 182 183 p_Unknown_Proc 183 184 }; … … 268 269 case p_Minus_mm_Mult_qq_Proc: return "p_Minus_mm_Mult_qq_Proc"; 269 270 case p_Neg_Proc: return "p_Neg_Proc"; 271 case pp_Mult_Coeff_mm_DivSelect_Proc: return "pp_Mult_Coeff_mm_DivSelect_Proc"; 270 272 case p_Unknown_Proc: return "p_Unknown_Proc"; 271 273 } … … 483 485 case p_Mult_mm_Proc: 484 486 case pp_Mult_nn_Proc: 487 case pp_Mult_Coeff_mm_DivSelect_Proc: 485 488 return index(field, length); 486 489 … … 636 639 (p_Procs->p_Add_q != NULL) && 637 640 (p_Procs->p_Neg != NULL) && 641 (p_Procs->pp_Mult_Coeff_mm_DivSelect != NULL) && 638 642 (p_Procs->p_Minus_mm_Mult_qq != NULL)); 639 643 } … … 901 905 SetProc(p_Minus_mm_Mult_qq, field, length, ord); 902 906 SetProc(p_Neg, field, LengthGeneral, OrdGeneral); 903 } 904 905 906 907 SetProc(pp_Mult_Coeff_mm_DivSelect, field, length, OrdGeneral); 908 } 909 910 911 -
Singular/p_Procs.h
rb559f8 r1aa55bf 8 8 * Author: obachman (Olaf Bachmann) 9 9 * Created: 8/00 10 * Version: $Id: p_Procs.h,v 1. 5 2000-09-18 09:19:27obachman Exp $10 * Version: $Id: p_Procs.h,v 1.6 2000-10-16 12:06:38 obachman Exp $ 11 11 *******************************************************************/ 12 12 #ifndef P_PROCS_H … … 28 28 const ring r); 29 29 typedef poly (*p_Neg_Proc_Ptr)(poly p, const ring r); 30 typedef poly (*pp_Mult_Coeff_mm_DivSelect_Proc_Ptr)(poly p, const poly m, const ring r); 30 31 31 32 typedef struct p_Procs_s … … 41 42 p_Minus_mm_Mult_qq_Proc_Ptr p_Minus_mm_Mult_qq; 42 43 p_Neg_Proc_Ptr p_Neg; 44 pp_Mult_Coeff_mm_DivSelect_Proc_Ptr pp_Mult_Coeff_mm_DivSelect; 43 45 } pProcs_s; 44 46 -
Singular/p_polys.h
rb559f8 r1aa55bf 8 8 * Author: obachman (Olaf Bachmann) 9 9 * Created: 9/00 10 * Version: $Id: p_polys.h,v 1. 3 2000-10-04 13:12:05obachman Exp $10 * Version: $Id: p_polys.h,v 1.4 2000-10-16 12:06:38 obachman Exp $ 11 11 *******************************************************************/ 12 12 #ifndef P_POLYS_H … … 122 122 // ExpVector(p1) -= ExpVector(p2) 123 123 PINLINE1 void p_ExpVectorSub(poly p1, poly p2, ring r); 124 // ExpVector(p1) += ExpVector(p2) - ExpVector(p3) 125 PINLINE1 void p_ExpVectorAddSub(poly p1, poly p2, poly p3, ring r); 124 126 // ExpVector(pr) = ExpVector(p1) + ExpVector(p2) 125 127 PINLINE1 void p_ExpVectorSum(poly pr, poly p1, poly p2, ring r); … … 232 234 PINLINE2 poly pp_Mult_qq(poly p, poly q, const ring r); 233 235 236 // returns p*Coeff(m) for such monomials pm of p, for which m is divisble by pm 237 PINLINE2 poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r); 238 234 239 /*************************************************************** 235 240 * -
Singular/polys.cc
rb559f8 r1aa55bf 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1.6 2 2000-09-18 09:19:29obachman Exp $ */4 /* $Id: polys.cc,v 1.63 2000-10-16 12:06:38 obachman Exp $ */ 5 5 6 6 /* … … 780 780 } 781 781 } 782 if (pFDeg!=pWTotaldegree) pFDeg=pTotaldegree; 782 if (pFDeg!=pWTotaldegree) 783 { 784 if (rOrd_is_Totaldegree_Ordering(r)) 785 { 786 pFDeg = pDeg; 787 } 788 else 789 { 790 pFDeg=pTotaldegree; 791 } 792 } 783 793 } 784 794 -
Singular/polys.h
rb559f8 r1aa55bf 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys.h,v 1. 39 2000-09-20 12:56:37obachman Exp $ */6 /* $Id: polys.h,v 1.40 2000-10-16 12:06:39 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT - all basic methods to manipulate polynomials of the … … 125 125 #define pExpVectorAdd(p1, p2) p_ExpVectorAdd(p1, p2, currRing) 126 126 #define pExpVectorSub(p1, p2) p_ExpVectorSub(p1, p2, currRing) 127 #define pExpVectorAddSub(p1, p2, p3)p_ExpVectorAddSub(p1, p2, p3, currRing) 127 128 #define pExpVectorSum(pr, p1, p2) p_ExpVectorSum(pr, p1, p2, currRing) 128 129 #define pExpVectorDiff(pr, p1, p2) p_ExpVectorDiff(pr, p1, p2, currRing) … … 206 207 #define pMult(p, q) p_Mult_q(p, q, currRing) 207 208 #define ppMult_qq(p, q) pp_Mult_qq(p, q, currRing) 209 // p*Coeff(m) for such monomials pm of p, for which m is divisble by pm 210 #define ppMult_Coeff_mm_DivSelect(p, m) pp_Mult_Coeff_mm_DivSelect(p, m, currRing) 208 211 209 212 /*************************************************************** -
Singular/pp_Mult_nn__Template.cc
rb559f8 r1aa55bf 3 3 ****************************************/ 4 4 /*************************************************************** 5 * File: pp_Mult_n __Template.cc6 * Purpose: template for pp_Mult_n 5 * File: pp_Mult_nn__Template.cc 6 * Purpose: template for pp_Mult_nn 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pp_Mult_nn__Template.cc,v 1. 3 2000-09-18 09:19:31obachman Exp $9 * Version: $Id: pp_Mult_nn__Template.cc,v 1.4 2000-10-16 12:06:39 obachman Exp $ 10 10 *******************************************************************/ 11 11 -
Singular/ring.cc
rb559f8 r1aa55bf 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.1 19 2000-09-20 12:33:29 obachman Exp $ */4 /* $Id: ring.cc,v 1.120 2000-10-16 12:06:39 obachman Exp $ */ 5 5 6 6 /* … … 63 63 // unconditionally deletes fields in r 64 64 static void rDelete(ring r); 65 // set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex 66 static void rSetVarL(ring r); 67 // get r->divmask depending on bits per exponent 68 static unsigned long rGetDivMask(int bits); 65 69 66 70 /*0 implementation*/ … … 1935 1939 } 1936 1940 1941 BOOLEAN rOrder_is_DegOrdering(rRingOrder_t order) 1942 { 1943 switch(order) 1944 { 1945 case ringorder_dp: 1946 case ringorder_Dp: 1947 case ringorder_ds: 1948 case ringorder_Ds: 1949 return TRUE; 1950 1951 default: 1952 return FALSE; 1953 } 1954 } 1955 1956 // return TRUE if p->exp[r->pOrdIndex] holds total degree of p */ 1957 BOOLEAN rOrd_is_Totaldegree_Ordering(ring r =currRing) 1958 { 1959 // Hmm.... what about Syz orderings? 1960 return (r->N > 1 && 1961 rHasSimpleOrder(r) && 1962 (rOrder_is_DegOrdering((rRingOrder_t)r->order[0]) || 1963 rOrder_is_DegOrdering(( rRingOrder_t)r->order[1]))); 1964 } 1965 1937 1966 BOOLEAN rIsPolyVar(int v) 1938 1967 { … … 2210 2239 } 2211 2240 2212 unsigned long rGetExpSize(unsigned long bitmask, int & bits)2241 static unsigned long rGetExpSize(unsigned long bitmask, int & bits) 2213 2242 { 2214 2243 if (bitmask == 0) … … 2295 2324 * optimize rGetExpSize for a block of N variables, exp <=bitmask 2296 2325 */ 2297 unsigned long rGetExpSize(unsigned long bitmask, int & bits, int N)2326 static unsigned long rGetExpSize(unsigned long bitmask, int & bits, int N) 2298 2327 { 2299 2328 #if SIZEOF_LONG == 8 … … 2449 2478 int bits; 2450 2479 r->bitmask=rGetExpSize(r->bitmask,bits); 2480 r->BitsPerExp = bits; 2481 r->divmask=rGetDivMask(bits); 2482 2451 2483 // will be used for ordsgn: 2452 2484 long *tmp_ordsgn=(long *)omAlloc0(2*(n+r->N)*sizeof(long)); … … 2784 2816 r->p_Procs = (p_Procs_s*)omAlloc(sizeof(p_Procs_s)); 2785 2817 p_SetProcs(r, r->p_Procs); 2818 2819 // ---------------------------- 2820 // set VarL_* 2821 rSetVarL(r); 2786 2822 return FALSE; 2787 2823 } … … 2812 2848 if (r->p_Procs != NULL) 2813 2849 omFreeSize(r->p_Procs, sizeof(p_Procs_s)); 2814 } 2850 omfreeSize(r->VarL_Offset, r->VarL_Size*sizeof(int)); 2851 } 2852 } 2853 2854 // set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex 2855 static void rSetVarL(ring r) 2856 { 2857 poly p = p_Init(r); 2858 int* VarL_Offset = (int*) omAlloc0(r->ExpLSize*sizeof(int)); 2859 int i,j; 2860 2861 for (i=1; i<=r->N; i++) 2862 p_SetExp(p, i, 1, r); 2863 2864 r->VarL_LowIndex = 0; 2865 for (i=0, j=0; i<r->ExpLSize; i++) 2866 { 2867 if (p->exp[i] != 0) 2868 { 2869 VarL_Offset[j] = i; 2870 if (j > 0 && VarL_Offset[j-1] != VarL_Offset[j] - 1) 2871 r->VarL_LowIndex = -1; 2872 j++; 2873 } 2874 } 2875 r->VarL_Size = j; 2876 if (r->VarL_LowIndex >= 0) 2877 r->VarL_LowIndex = VarL_Offset[0]; 2878 r->VarL_Offset = (int*) omReallocSize(VarL_Offset,r->ExpLSize*sizeof(int), 2879 j*sizeof(int)); 2880 p_LmFree(p, r); 2881 } 2882 2883 // get r->divmask depending on bits per exponent 2884 static unsigned long rGetDivMask(int bits) 2885 { 2886 unsigned long divmask = 1; 2887 int i = bits; 2888 2889 while (i < BIT_SIZEOF_LONG) 2890 { 2891 divmask |= (1 << (unsigned long) i); 2892 i += bits; 2893 } 2894 return divmask; 2815 2895 } 2816 2896 … … 2828 2908 for(j=0;j<=r->N;j++) Print(" v%d at e-pos %d, bit %d\n", 2829 2909 j,r->VarOffset[j] & 0xffffff, r->VarOffset[j] >>24); 2910 Print("BitsPerExp=%d\n", r->BitsPerExp); 2830 2911 Print("bitmask=0x%x\n",r->bitmask); 2912 Print("divmask=%p\n", r->divmask); 2831 2913 PrintS("ordsgn:\n"); 2832 2914 for(j=0;j<r->pCompLSize;j++) … … 2854 2936 Print("pVarLowIndex:%d ",r->pVarLowIndex); 2855 2937 Print("pVarHighIndex:%d\n",r->pVarHighIndex); 2938 Print("VarL_Size:%d\nVarL_LowIndex:%d\n", r->VarL_Size, r->VarL_LowIndex); 2856 2939 #ifdef LONG_MONOMS 2857 2940 Print("pDivLow:%d ",r->pDivLow); -
Singular/ring.h
rb559f8 r1aa55bf 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1.5 1 2000-09-19 15:22:25 SingularExp $ */9 /* $Id: ring.h,v 1.52 2000-10-16 12:06:40 obachman Exp $ */ 10 10 11 11 /* includes */ … … 210 210 // returns TRUE, if simple lp or ls ordering 211 211 BOOLEAN rHasSimpleLexOrder(ring r); 212 // return TRUE if p->exp[r->pOrdIndex] holds total degree of p */ 213 BOOLEAN rOrd_is_Totaldegree_Ordering(ring r =currRing); 212 214 rOrderType_t rGetOrderType(ring r); 213 215 BOOLEAN rIsPolyVar(int i); /* returns TRUE if var(i) belongs to p-block */ 214 215 void rOptimizeOrder(ring r);216 216 217 217 #ifdef RDEBUG … … 222 222 #endif 223 223 224 unsigned long rGetExpSize(unsigned long bitmask, int & bits);225 unsigned long rGetExpSize(unsigned long bitmask, int & bits, int N);226 224 ring rModifyRing(ring r, BOOLEAN omit_degree, 227 225 BOOLEAN omit_comp, -
Singular/sparsmat.cc
rb559f8 r1aa55bf 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: sparsmat.cc,v 1.4 0 2000-09-25 14:07:59 pohlExp $ */4 /* $Id: sparsmat.cc,v 1.41 2000-10-16 12:06:41 obachman Exp $ */ 5 5 6 6 /* … … 35 35 }; 36 36 */ 37 38 #if OLD > 0 39 static poly smSelectCopy(poly, const poly); 40 #else 41 #define smSelectCopy ppMult_Coeff_mm_DivSelect 42 #endif 43 37 44 /* declare internal 'C' stuff */ 38 45 static void smExactPolyDiv(poly, poly); 39 46 static BOOLEAN smIsNegQuot(poly, const poly, const poly); 40 static BOOLEAN smCheckLead(const poly, const poly);41 static poly smSelectCopy(poly, const poly);42 47 static void smExpMultDiv(poly, const poly, const poly); 43 48 static void smPolyDivN(poly, const number); … … 1805 1810 if (smIsNegQuot(e, b, c)) 1806 1811 { 1807 lead = smCheckLead(a, e);1812 lead = pLmDivisibleByNoComp(e, a); 1808 1813 r = smSelectCopy(a, e); 1809 1814 smExpMultDiv(r, b, c); … … 1843 1848 r = smSelectCopy(a, e); 1844 1849 smExpMultDiv(r, b, c); 1845 if ( smCheckLead(a, e))1850 if (pLmDivisibleByNoComp(e, a)) 1846 1851 smCombineChain(&pa, r); 1847 1852 else … … 1902 1907 } 1903 1908 1909 // obachman --> Wilfried: check the following 1904 1910 static BOOLEAN smIsNegQuot(poly a, const poly b, const poly c) 1905 1911 { 1906 int i=pVariables; 1907 1908 while ((i>0) && (pGetExp(b,i) >= pGetExp(c,i))) i--; 1909 if(i!=0) 1910 { 1912 if (pLmDivisibleByNoComp(c, b)) 1913 { 1914 pExpVectorDiff(a, b, c); 1915 // Hmm: here used to be a pSetm(a): but it is unnecessary, 1916 // if b and c are correct 1917 return FALSE; 1918 } 1919 else 1920 { 1921 int i; 1911 1922 for (i=pVariables; i>0; i--) 1912 1923 { … … 1916 1927 pSetExp(a,i,0); 1917 1928 } 1929 // here we actually might need a pSetm, if a is to be used in 1930 // comparisons 1918 1931 return TRUE; 1919 1932 } 1920 else 1921 { 1922 for (i=pVariables; i>0; i--) 1923 { 1924 pSetExp(a,i, pGetExp(b,i)-pGetExp(c,i)); 1925 } 1926 pSetm(a); 1927 return FALSE; 1928 } 1929 } 1930 1931 static BOOLEAN smCheckLead(const poly t, const poly e) 1933 } 1934 1935 static void smExpMultDiv(poly t, const poly b, const poly c) 1932 1936 { 1933 1937 int i; 1934 Exponent_t w; 1935 for (i=pVariables; i; i--) 1936 { 1937 w = pGetExp(e,i); 1938 if (w&&(w>pGetExp(t,i))) 1939 return FALSE; 1940 } 1941 return TRUE; 1942 } 1943 1944 /* 1945 * e is a monomial with exponents e(i) 1946 * t is a polynom with monomials t_j and 1947 * exponents t_j(i) 1948 * make a copy of a part of t: 1949 * for the monomials t_j of t in the copy 1950 * we have 1951 * ((e(i)!=0)&&(e(i)<=t_j(i)) == TRUE 1952 */ 1953 static poly smSelectCopy(poly t, const poly e) 1954 { 1955 const number y = pGetCoeff(e); 1956 poly res, h; 1957 1958 loop 1959 { 1960 if(smCheckLead(t,e)) break; 1961 pIter(t); 1962 if(t==NULL) return NULL; 1963 } 1964 h = res = pNew(); 1965 loop 1966 { 1967 pExpVectorCopy(h,t); 1968 pSetCoeff0(h,nMult(y,pGetCoeff(t))); 1969 loop 1970 { 1971 pIter(t); 1972 if(t==NULL) 1973 { 1974 pNext(h)=NULL; 1975 return res; 1976 } 1977 if(smCheckLead(t,e)) break; 1978 } 1979 h=pNext(h)=pNew(); 1980 } 1981 } 1982 1983 static void smExpMultDiv(poly t, const poly b, const poly c) 1984 { 1985 int i; 1938 pTest(t); 1939 pLmTest(b); 1940 pLmTest(c); 1986 1941 while(t!=NULL) 1987 1942 { 1988 pExpVectorAdd(t,b); 1989 pExpVectorSub(t,c); 1943 pExpVectorAddSub(t, b, c); 1990 1944 pIter(t); 1991 1945 } -
Singular/structs.h
rb559f8 r1aa55bf 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1.3 7 2000-09-19 15:22:25 SingularExp $ */6 /* $Id: structs.h,v 1.38 2000-10-16 12:06:41 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 252 252 ideal qideal; /* extension to the ring structure: qring */ 253 253 254 unsigned long bitmask;255 254 256 255 int *VarOffset; … … 283 282 short ExpLSize; /* size of exponent vector in long */ 284 283 short OrdSize; /* size of ord vector (in sro_ord) */ 284 short BitsPerExp; /* number of bits per exponent */ 285 286 short ref; /* reference counter to the ring */ 287 288 /* number of long vars in exp vector: 289 long vars are those longs in the exponent vector which are 290 occupied by variables, only */ 291 short VarL_Size; 292 /* if >= 0, long vars in exp vector are consecutive and start there 293 if < 0, long vars in exp vector are not consecutive */ 294 short VarL_LowIndex; 295 /* array of size VarL_Size, 296 VarL_Offset[i] gets i-th long var in exp vector */ 297 int* VarL_Offset; 298 299 /* mask for getting single exponents */ 300 unsigned long bitmask; 301 /* mask used for divisiblity tests */ 302 unsigned long divmask; 285 303 286 304 p_Procs_s* p_Procs; 287 short ref; /* reference counter to the ring */288 305 }; 289 306
Note: See TracChangeset
for help on using the changeset viewer.