Changeset 206e158 in git
- Timestamp:
- May 11, 2007, 12:48:05 PM (16 years ago)
- Branches:
- (u'spielwiese', 'f6c3dc58b0df4bd712574325fe76d0626174ad97')
- Children:
- d15996cd44ce997d3360fac629f4062adb1c4836
- Parents:
- 3fd4df896525da08d34f33e88e6239994fa4d0e6
- Location:
- kernel
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/kbuckets.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kbuckets.cc,v 1.3 2 2007-05-10 08:12:40wienand Exp $ */4 /* $Id: kbuckets.cc,v 1.33 2007-05-11 10:48:03 wienand Exp $ */ 5 5 6 6 #include "mod2.h" … … 585 585 if (i<coef_start) 586 586 bucket->buckets[i] = p_Mult_nn(bucket->buckets[i], n, r); 587 #ifdef HAVE_RING 2TOM588 if (r ->cring == 1) {587 #ifdef HAVE_RINGS 588 if (rField_is_Ring(r) && !(rField_is_Domain(r))) { 589 589 bucket->buckets_length[i] = pLength(bucket->buckets[i]); 590 590 kBucketAdjust(bucket, i); … … 610 610 bucket->buckets[i] = p_Mult_nn(bucket->buckets[i], n, r); 611 611 #ifdef HAVE_RINGS 612 if (rField_is_Ring(currRing) ) {612 if (rField_is_Ring(currRing) && !(rField_is_Domain(currRing))) { 613 613 bucket->buckets_length[i] = pLength(bucket->buckets[i]); 614 614 kBucketAdjust(bucket, i); … … 740 740 bucket->buckets_length[i] = 0; 741 741 #ifdef HAVE_RINGS 742 if (rField_is_Ring(currRing) )742 if (rField_is_Ring(currRing) && !(rField_is_Domain(currRing))) 743 743 { 744 744 l1 = pLength(p1); … … 760 760 p1 = r->p_Procs->pp_Mult_mm(p1, m, r, last); 761 761 #ifdef HAVE_RINGS 762 if (rField_is_Ring(currRing) )762 if (rField_is_Ring(currRing) && !(rField_is_Domain(currRing))) 763 763 { 764 764 l1 = pLength(p1); -
kernel/kspoly.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kspoly.cc,v 1.1 0 2007-05-10 08:12:40wienand Exp $ */4 /* $Id: kspoly.cc,v 1.11 2007-05-11 10:48:03 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT - Routines for Spoly creation and reductions … … 14 14 #include "p_Procs.h" 15 15 #include "gring.h" 16 #ifdef HAVE_RING 2TOM16 #ifdef HAVE_RINGS 17 17 #include "polys.h" 18 18 #endif … … 214 214 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing,last); 215 215 #ifdef HAVE_RINGS 216 if (rField_is_Ring(currRing) ) l2 = pLength(a2);216 if (rField_is_Ring(currRing) && !(rField_is_Domain(currRing))) l2 = pLength(a2); 217 217 #endif 218 218 -
kernel/kstd1.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd1.cc,v 1. 19 2007-05-10 08:12:41wienand Exp $ */4 /* $Id: kstd1.cc,v 1.20 2007-05-11 10:48:03 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: … … 1008 1008 strat->red = redHomog; 1009 1009 } 1010 #ifdef HAVE_RING 2TOM1011 if (rField_is_Ring _2toM(currRing)) {1010 #ifdef HAVE_RINGS //TODO Oliver 1011 if (rField_is_Ring(currRing)) { 1012 1012 strat->red = redRing2toM; 1013 1013 } -
kernel/kstd2.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd2.cc,v 1.4 3 2007-05-10 08:12:41wienand Exp $ */4 /* $Id: kstd2.cc,v 1.44 2007-05-11 10:48:03 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: alg. of Buchberger … … 310 310 return kFindZeroPoly(h->GetLmCurrRing(), currRing, h->tailRing); 311 311 } 312 313 #ifdef HAVE_RING2TOM 312 #endif 313 314 315 #ifdef HAVE_RINGS 314 316 /*2 315 317 * reduction procedure for the ring Z/2^m … … 338 340 { 339 341 #ifdef HAVE_VANGB 342 #ifdef HAVE_RING2TOM 340 343 zeroPoly = kFindDivisibleByZeroPoly(h); 341 344 if (zeroPoly != NULL) … … 362 365 else 363 366 #endif 367 #endif 364 368 { 365 369 j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h); … … 383 387 ksReducePoly(h, &(strat->T[j]), NULL, NULL, strat); 384 388 #ifdef HAVE_VANGB 389 #ifdef HAVE_RING2TOM 385 390 if (zeroPoly != NULL) 386 391 { … … 388 393 strat->tl--; 389 394 } 395 #endif 390 396 #endif 391 397 … … 437 443 } 438 444 } 439 #endif440 445 #endif 441 446 … … 1088 1093 #ifdef KDEBUG 1089 1094 loop_count++; 1090 #ifdef HAVE_RING 2TOM1095 #ifdef HAVE_RINGS 1091 1096 if (TEST_OPT_DEBUG) PrintS("--- next step ---\n"); 1092 1097 #endif … … 1214 1219 //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) 1215 1220 enterT(strat->P, strat); 1216 #ifdef HAVE_RING 2TOM1221 #ifdef HAVE_RINGS 1217 1222 #ifdef HAVE_VANGB 1218 1223 int at_R = strat->tl; 1219 1224 #endif 1220 if (rField_is_Ring _2toM(currRing))1225 if (rField_is_Ring(currRing)) 1221 1226 superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl); 1222 1227 else -
kernel/kutil.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.5 2 2007-05-10 08:12:41wienand Exp $ */4 /* $Id: kutil.cc,v 1.53 2007-05-11 10:48:04 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for kStd … … 104 104 static poly redBba (poly h,int maxIndex,kStrategy strat); 105 105 106 #ifdef HAVE_RING 2TOM106 #ifdef HAVE_RINGS 107 107 #define pDivComp_EQUAL 2 108 108 #define pDivComp_LESS 1 … … 130 130 if (la < lb) 131 131 { 132 if (b) return 0;132 if (b) return pDivComp_INCOMP; 133 133 if (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)) 134 return 0;134 return pDivComp_INCOMP; 135 135 a = TRUE; 136 136 } 137 137 else 138 138 { 139 if (a) return 0;139 if (a) return pDivComp_INCOMP; 140 140 if (((la & divmask) ^ (lb & divmask)) != ((la - lb) & divmask)) 141 return 0;141 return pDivComp_INCOMP; 142 142 b = TRUE; 143 143 } 144 144 } 145 145 } 146 if (a) return 1;147 if (b) return -1;146 if (a) return pDivComp_LESS; 147 if (b) return pDivComp_GREATER; 148 148 if (!a & !b) return pDivComp_EQUAL; 149 149 } … … 492 492 } 493 493 494 #ifdef HAVE_RING2TOM495 //void initLMtest(kStrategy strat)496 //{497 // strat->lmtest = (unsigned int *)omAlloc0((strat->sl*strat->sl/2+2)*sizeof(BOOLEAN));498 //}499 #endif500 501 494 /*2 502 495 *test whether (p1,p2) or (p2,p1) is in L up position length … … 1022 1015 } 1023 1016 1024 #ifdef HAVE_RING2TOM 1025 /* TODO move to numbers.cc 1026 */ 1027 inline int nComp(NATNUMBER a, NATNUMBER b) 1028 { 1029 assume(a != 0 && b != 0); 1030 while (a % 2 == 0 && b % 2 == 0) 1031 { 1032 a = a / 2; 1033 b = b / 2; 1034 } 1035 if (a % 2 == 0) 1036 { 1037 return -1; 1038 } 1039 else 1040 { 1041 if (b % 2 == 1) 1042 { 1043 return 0; 1044 } 1045 else 1046 { 1047 return 1; 1048 } 1049 } 1050 } 1051 1017 #ifdef HAVE_RINGS 1052 1018 /*2 1053 1019 * put the pair (s[i],p) into the set B, ecart=ecart(p) (ring case) … … 1088 1054 { 1089 1055 compare=pDivCompRing(strat->B[j].lcm,Lp.lcm); 1090 compareCoeff = nComp( (long) pGetCoeff(strat->B[j].lcm), (long)pGetCoeff(Lp.lcm));1056 compareCoeff = nComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(Lp.lcm)); 1091 1057 if (compareCoeff == 0 || compare == compareCoeff) 1092 1058 { … … 1111 1077 { 1112 1078 // Add hint for same LM and direction of LC (later) (TODO Oliver) 1113 if (compareCoeff == 1)1079 if (compareCoeff == pDivComp_LESS) 1114 1080 { 1115 1081 strat->c3++; … … 1122 1088 } 1123 1089 else 1124 if (compareCoeff == -1)1090 if (compareCoeff == pDivComp_GREATER) 1125 1091 { 1126 1092 deleteInL(strat->B,&strat->Bl,j,strat); … … 1808 1774 } 1809 1775 1810 #ifdef HAVE_RING 2TOM1776 #ifdef HAVE_RINGS 1811 1777 /*2 1812 1778 *the pairset B of pairs of type (s[i],p) is complete now. It will be updated … … 1936 1902 } 1937 1903 } 1938 1904 #endif 1905 1906 #ifdef HAVE_RING2TOM 1939 1907 long twoPow(long arg) 1940 1908 { … … 1996 1964 { 1997 1965 compare=pDivCompRing(strat->B[j].lcm,Lp.lcm); 1998 compareCoeff = nComp( (long) pGetCoeff(strat->B[j].lcm), (long)pGetCoeff(Lp.lcm));1966 compareCoeff = nComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(Lp.lcm)); 1999 1967 if (compareCoeff == 0 || compare == compareCoeff) 2000 1968 { … … 2343 2311 idSkipZeroes(G0); 2344 2312 return G0; 2345 } 2346 2313 } 2314 #endif 2315 2316 #ifdef HAVE_RINGS 2347 2317 /*2 2348 2318 *(s[0],h),...,(s[k],h) will be put to the pairset L … … 2413 2383 void enterExtendedSpoly(poly h,kStrategy strat) 2414 2384 { 2415 if (((long) ((h)->coef)) % 2 == 0) 2416 { 2417 long a = ((long) ((h)->coef)) / 2; 2385 number gcd = nGcd((number) 0, pGetCoeff(h), strat->tailRing); 2386 if ((NATNUMBER) gcd > 1) 2387 { 2388 poly p = p_Copy(h->next, strat->tailRing); 2389 /* long a = ((long) ((h)->coef)) / 2; 2418 2390 long b = currRing->ch - 1; 2419 poly p = p_Copy(h->next, strat->tailRing);2420 2391 while (a % 2 == 0) 2421 2392 { … … 2423 2394 b--; 2424 2395 } 2425 p = p_Mult_nn(p, (number) twoPow(b), strat->tailRing); 2396 p = p_Mult_nn(p, (number) twoPow(b), strat->tailRing); */ 2397 p = p_Mult_nn(p, nIntDiv(0, gcd), strat->tailRing); 2426 2398 2427 2399 if (p != NULL) … … 2665 2637 else 2666 2638 { 2667 #ifdef HAVE_RING 2TOM2668 if (rField_is_Ring _2toM(currRing))2639 #ifdef HAVE_RINGS 2640 if (rField_is_Ring(currRing)) 2669 2641 { 2670 2642 if (pLmCmp(set[length],p)== -cmp_int) … … 5166 5138 else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18)) 5167 5139 strat->posInT = posInT1; 5168 #ifdef HAVE_RING 2TOM5140 #ifdef HAVE_RINGS 5169 5141 if (rField_is_Ring(currRing)) 5170 5142 { … … 5496 5468 // might be too strong 5497 5469 #ifdef HAVE_RINGS 5498 (strat->homog && pFDeg == pDeg && rField_is_Ring(currRing)), // TODO Oliver5470 (strat->homog && pFDeg == pDeg && !(rField_is_Ring(currRing))), // TODO Oliver 5499 5471 #else 5500 5472 (strat->homog && pFDeg == pDeg), -
kernel/kutil.h
r3fd4df r206e158 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: kutil.h,v 1.2 2 2007-03-29 11:34:52 SingularExp $ */6 /* $Id: kutil.h,v 1.23 2007-05-11 10:48:04 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT: kernel: utils for kStd … … 397 397 poly redNFTail (poly h,const int sl,kStrategy strat); 398 398 int redHoney (LObject* h, kStrategy strat); 399 #ifdef HAVE_RINGS 400 int redRing2toM (LObject* h,kStrategy strat); 401 void enterExtendedSpoly(poly h,kStrategy strat); 402 void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1); 403 poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing); 404 #endif 399 405 #ifdef HAVE_RING2TOM 400 int redRing2toM (LObject* h,kStrategy strat);401 406 long ind2(long arg); 402 407 long ind_fact_2(long arg); 403 408 long twoPow(long arg); 404 void enterExtendedSpoly(poly h,kStrategy strat);405 void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);406 poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing);407 409 ideal createG0(); 408 410 #endif … … 548 550 kStrategy strat = NULL); 549 551 550 #ifdef HAVE_RING2TOM 552 #ifdef HAVE_RING2TOM_OLD 551 553 // same for rings 552 554 int ksRingReducePoly(LObject* PR, -
kernel/numbers.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: numbers.cc,v 1. 8 2007-05-10 08:12:42wienand Exp $ */4 /* $Id: numbers.cc,v 1.9 2007-05-11 10:48:04 wienand Exp $ */ 5 5 6 6 /* … … 48 48 #ifdef HAVE_RINGS 49 49 BOOLEAN (*nDivBy)(number a,number b); 50 int (*nComp)(number a,number b); 50 51 #endif 51 52 BOOLEAN (*nGreater)(number a,number b); … … 105 106 #ifdef HAVE_RINGS 106 107 BOOLEAN ndDivBy(number a, number b) { return TRUE; } 108 int ndComp(number a, number b) { return 0; } 107 109 #endif 108 110 … … 181 183 nCopy = r->cf->nCopy; 182 184 #ifdef HAVE_RINGS 185 nComp = r->cf->nComp; 183 186 nDivBy = r->cf->nDivBy; 184 187 #endif … … 262 265 n->nLcm = ndGcd; /* tricky, isn't it ?*/ 263 266 #ifdef HAVE_RINGS 267 n->nComp = ndComp; 264 268 n->nDivBy = ndDivBy; 265 269 #endif … … 320 324 n->nInvers= nr2mInvers; 321 325 n->nDivBy = nr2mDivBy; 326 n->nComp = nr2mComp; 322 327 n->nGreater = nr2mGreater; 323 328 n->nEqual = nr2mEqual; … … 357 362 n->nInvers= nrnInvers; 358 363 n->nDivBy = nrnDivBy; 364 n->nComp = nrnComp; 359 365 n->nGreater = nrnGreater; 360 366 n->nEqual = nrnEqual; -
kernel/numbers.h
r3fd4df r206e158 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: numbers.h,v 1. 7 2007-05-10 08:12:42wienand Exp $ */6 /* $Id: numbers.h,v 1.8 2007-05-11 10:48:04 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT: interface to coefficient aritmetics … … 47 47 extern int (*nSize)(number n); 48 48 extern int (*nInt)(number &n); 49 #ifdef HAVE_RINGS 50 extern int (*nComp)(number a,number b); 51 #endif 49 52 // always use in the form n=nNeg(n) ! 50 53 extern number (*nNeg)(number a); -
kernel/polys.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1.1 6 2007-05-10 08:12:42wienand Exp $ */4 /* $Id: polys.cc,v 1.17 2007-05-11 10:48:04 wienand Exp $ */ 5 5 6 6 /* … … 110 110 } 111 111 112 #ifdef HAVE_RING 2TOM112 #ifdef HAVE_RINGS //TODO Oliver 113 113 #define pDiv_nn(p, n) p_Div_nn(p, n, currRing) 114 114 -
kernel/polys.h
r3fd4df r206e158 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys.h,v 1. 9 2006-03-28 12:56:06 SingularExp $ */6 /* $Id: polys.h,v 1.10 2007-05-11 10:48:05 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT - all basic methods to manipulate polynomials of the … … 251 251 #define pIsVector(p) (pGetComp(p)>0) 252 252 253 #ifdef HAVE_RING 2TOM253 #ifdef HAVE_RINGS 254 254 /* 255 255 * Test stuff for dev OLIVER -
kernel/ring.h
r3fd4df r206e158 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1. 19 2007-05-10 08:12:43wienand Exp $ */9 /* $Id: ring.h,v 1.20 2007-05-11 10:48:05 wienand Exp $ */ 10 10 11 11 /* includes */ … … 101 101 #ifdef HAVE_RINGS 102 102 inline BOOLEAN rField_is_Ring(ring r=currRing) 103 { return (r->ringtype > 0); } 103 { return (r->ringtype != 0); } 104 105 inline BOOLEAN rField_is_Domain(ring r=currRing) 106 { return (r->ringtype < 0); } 104 107 #endif 105 108 -
kernel/ringgb.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ringgb.cc,v 1.1 2 2006-06-12 00:35:13wienand Exp $ */4 /* $Id: ringgb.cc,v 1.13 2007-05-11 10:48:05 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: ringgb interface … … 49 49 } 50 50 51 /*52 * Find an index i from G, such that53 * LT(rside) = x * LT(G[i]) has a solution54 * or -1 if rside is not in the55 * ideal of the leading coefficients56 * of the suitable g from G.57 */58 int findRing2toMsolver(poly rside, ideal G, ring r) {59 if (rside == NULL) return -1;60 int i;61 int iO2rside = indexOf2(pGetCoeff(rside));62 for (i = 0; i < IDELEMS(G); i++) {63 if (indexOf2(pGetCoeff(G->m[i])) <= iO2rside && p_LmDivisibleBy(G->m[i], rside, r)) {64 return i;65 }66 }67 return -1;68 }69 70 51 /*************************************************************** 71 52 * … … 119 100 PrintS(end); 120 101 } 121 122 poly plain_spoly(poly f, poly g) {123 number cf = pGetCoeff(f), cg = pGetCoeff(g);124 int ct = ksCheckCoeff(&cf, &cg); // gcd and zero divisors125 poly fm, gm;126 k_GetLeadTerms(f, g, currRing, fm, gm, currRing);127 pSetCoeff0(fm, cg);128 pSetCoeff0(gm, cf); // and now, m1 * LT(p1) == m2 * LT(p2)129 poly sp = pSub(pMult_mm(f, fm), pMult_mm(g, gm));130 pDelete(&fm);131 pDelete(&gm);132 return(sp);133 }134 135 102 136 103 poly spolyRing2toM(poly f, poly g, ring r) { … … 145 112 pDelete(&m2); 146 113 return(sp); 147 }148 149 poly ringNF(poly f, ideal G, ring r) {150 // If f = 0, then normal form is also 0151 if (f == NULL) { return NULL; }152 poly h = pCopy(f);153 int i = findRing2toMsolver(h, G, r);154 int c = 1;155 while (h != NULL && i >= 0) {156 // Print("%d-step NF - h:", c);157 // wrp(h);158 // PrintS(" ");159 // PrintS("G->m[i]:");160 // wrp(G->m[i]);161 // PrintLn();162 h = spolyRing2toM(h, G->m[i], r);163 // PrintS("=> h=");164 // wrp(h);165 // PrintLn();166 i = findRing2toMsolver(h, G, r);167 c++;168 }169 return h;170 114 } 171 115 … … 187 131 pLmDelete(&g); 188 132 } 133 c++; 134 } 135 return h; 136 } 137 138 #endif 139 140 #ifdef HAVE_RINGS 141 142 /* 143 * Find an index i from G, such that 144 * LT(rside) = x * LT(G[i]) has a solution 145 * or -1 if rside is not in the 146 * ideal of the leading coefficients 147 * of the suitable g from G. 148 */ 149 int findRingSolver(poly rside, ideal G, ring r) { 150 if (rside == NULL) return -1; 151 int i; 152 // int iO2rside = indexOf2(pGetCoeff(rside)); 153 for (i = 0; i < IDELEMS(G); i++) { 154 if // (indexOf2(pGetCoeff(G->m[i])) <= iO2rside && / should not be necessary any more 155 (p_LmDivisibleBy(G->m[i], rside, r)) { 156 return i; 157 } 158 } 159 return -1; 160 } 161 162 poly plain_spoly(poly f, poly g) { 163 number cf = pGetCoeff(f), cg = pGetCoeff(g); 164 int ct = ksCheckCoeff(&cf, &cg); // gcd and zero divisors 165 poly fm, gm; 166 k_GetLeadTerms(f, g, currRing, fm, gm, currRing); 167 pSetCoeff0(fm, cg); 168 pSetCoeff0(gm, cf); // and now, m1 * LT(p1) == m2 * LT(p2) 169 poly sp = pSub(pMult_mm(f, fm), pMult_mm(g, gm)); 170 pDelete(&fm); 171 pDelete(&gm); 172 return(sp); 173 } 174 175 poly ringNF(poly f, ideal G, ring r) { 176 // If f = 0, then normal form is also 0 177 if (f == NULL) { return NULL; } 178 poly h = pCopy(f); 179 int i = findRingSolver(h, G, r); 180 int c = 1; 181 while (h != NULL && i >= 0) { 182 Print("%d-step NF - h:", c); 183 wrp(h); 184 PrintS(" "); 185 PrintS("G->m[i]:"); 186 wrp(G->m[i]); 187 PrintLn(); 188 h = plain_spoly(h, G->m[i]); 189 PrintS("=> h="); 190 wrp(h); 191 PrintLn(); 192 i = findRingSolver(h, G, r); 189 193 c++; 190 194 } -
kernel/ringgb.h
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ringgb.h,v 1. 5 2006-06-12 13:04:26 SingularExp $ */4 /* $Id: ringgb.h,v 1.6 2007-05-11 10:48:05 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: ringgb interface … … 9 9 #define RINGGB_HEADER 10 10 #include "mod2.h" 11 #ifdef HAVE_RING2TOM 11 12 #ifdef HAVE_RINGS 12 13 #include "polys.h" 13 14 14 poly reduce_poly_fct(poly p, ring r);15 poly ringRedNF(poly f, ideal G, ring r);16 15 poly ringNF(poly f, ideal G, ring r); 17 16 poly plain_spoly(poly f, poly g); 18 17 int testGB(ideal I, ideal GI); 19 18 19 #ifdef HAVE_RING2TOM 20 poly reduce_poly_fct(poly p, ring r); 21 poly ringRedNF(poly f, ideal G, ring r); 22 #endif 23 20 24 #endif 21 25 #endif -
kernel/rmodulo2m.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: rmodulo2m.cc,v 1. 8 2007-05-10 08:12:43wienand Exp $ */4 /* $Id: rmodulo2m.cc,v 1.9 2007-05-11 10:48:05 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: numbers modulo 2^m … … 70 70 res++; 71 71 } 72 if ((NATNUMBER) b % 2 == 0)73 {74 return (number) ((1L << res));// * (NATNUMBER) a); // (2**res)*a a ist Einheit75 }76 else77 {72 // if ((NATNUMBER) b % 2 == 0) 73 // { 74 // return (number) ((1L << res));// * (NATNUMBER) a); // (2**res)*a a ist Einheit 75 // } 76 // else 77 // { 78 78 return (number) ((1L << res));// * (NATNUMBER) b); // (2**res)*b b ist Einheit 79 }79 // } 80 80 } 81 81 … … 163 163 } 164 164 return ((NATNUMBER) b % 2 == 1); 165 } 166 167 int nr2mComp(number as, number bs) 168 { 169 NATNUMBER a = (NATNUMBER) as; 170 NATNUMBER b = (NATNUMBER) bs; 171 assume(a != 0 && b != 0); 172 while (a % 2 == 0 && b % 2 == 0) 173 { 174 a = a / 2; 175 b = b / 2; 176 } 177 if (a % 2 == 0) 178 { 179 return -1; 180 } 181 else 182 { 183 if (b % 2 == 1) 184 { 185 return 0; 186 } 187 else 188 { 189 return 1; 190 } 191 } 165 192 } 166 193 … … 271 298 if ((NATNUMBER)a==0) 272 299 { 273 return (number) 0; 274 } 275 else 276 { 300 if ((NATNUMBER)b==0) 301 return (number) 1; 302 return (number) (nr2mModul / (NATNUMBER) b); 303 } 304 else 305 { 306 if ((NATNUMBER)b==0) 307 return (number) 0; 277 308 return (number) ((NATNUMBER) a / (NATNUMBER) b); 278 309 } -
kernel/rmodulo2m.h
r3fd4df r206e158 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: rmodulo2m.h,v 1. 5 2007-05-10 08:12:43wienand Exp $ */6 /* $Id: rmodulo2m.h,v 1.6 2007-05-11 10:48:05 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT: numbers modulo 2^m … … 25 25 BOOLEAN nr2mIsMOne (number a); 26 26 number nr2mDiv (number a, number b); 27 number 27 number nr2mIntDiv (number a,number b); 28 28 number nr2mNeg (number c); 29 29 number nr2mInvers (number c); 30 30 BOOLEAN nr2mGreater (number a, number b); 31 31 BOOLEAN nr2mDivBy (number a, number b); 32 int nr2mComp (number a, number b); 32 33 BOOLEAN nr2mEqual (number a, number b); 33 number 34 number 35 nMapFunc nr2mSetMap (ring src, ring dst);34 number nr2mLcm (number a,number b, ring r); 35 number nr2mGcd (number a,number b,ring r); 36 nMapFunc nr2mSetMap (ring src, ring dst); 36 37 void nr2mWrite (number &a); 37 38 char * nr2mRead (char *s, number *a); -
kernel/rmodulon.cc
r3fd4df r206e158 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: rmodulon.cc,v 1. 2 2007-05-10 08:12:43wienand Exp $ */4 /* $Id: rmodulon.cc,v 1.3 2007-05-11 10:48:05 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: numbers modulo n … … 162 162 } 163 163 164 int nrnComp(number a, number b) 165 { 166 NATNUMBER bs = XSGCD2((NATNUMBER) b, nrnModul); 167 NATNUMBER as = XSGCD2((NATNUMBER) a, nrnModul); 168 if (bs == as) return 0; 169 if (as % bs == 0) return 1; 170 return -1; 171 } 172 164 173 BOOLEAN nrnDivBy (number a,number b) 165 174 { … … 267 276 if ((NATNUMBER)a==0) 268 277 { 269 return (number) 0; 270 } 271 else 272 { 278 if ((NATNUMBER)b==0) 279 return (number) 1; 280 return (number) ( nrnModul / (NATNUMBER) b); 281 } 282 else 283 { 284 if ((NATNUMBER)b==0) 285 return (number) 0; 273 286 return (number) ((NATNUMBER) a / (NATNUMBER) b); 274 287 } -
kernel/rmodulon.h
r3fd4df r206e158 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: rmodulon.h,v 1. 2 2007-05-10 08:12:44wienand Exp $ */6 /* $Id: rmodulon.h,v 1.3 2007-05-11 10:48:05 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT: numbers modulo n … … 29 29 BOOLEAN nrnIsMOne (number a); 30 30 number nrnDiv (number a, number b); 31 number 31 number nrnIntDiv (number a,number b); 32 32 number nrnNeg (number c); 33 33 number nrnInvers (number c); 34 34 BOOLEAN nrnGreater (number a, number b); 35 35 BOOLEAN nrnDivBy (number a, number b); 36 int nrnComp (number a, number b); 36 37 BOOLEAN nrnEqual (number a, number b); 37 number 38 number 39 nMapFunc nrnSetMap (ring src, ring dst);38 number nrnLcm (number a,number b, ring r); 39 number nrnGcd (number a,number b,ring r); 40 nMapFunc nrnSetMap (ring src, ring dst); 40 41 void nrnWrite (number &a); 41 42 char * nrnRead (char *s, number *a); -
kernel/structs.h
r3fd4df r206e158 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1.3 7 2007-05-10 08:12:44wienand Exp $ */6 /* $Id: structs.h,v 1.38 2007-05-11 10:48:05 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 271 271 int (*nSize)(number n); 272 272 int (*nInt)(number &n); 273 #ifdef HAVE_RINGS 274 int (*nComp)(number a,number b); 275 #endif 273 276 number (*nNeg)(number a); 274 277 number (*nInvers)(number a);
Note: See TracChangeset
for help on using the changeset viewer.