Changeset 585bbcb in git
- Timestamp:
- Nov 27, 2005, 4:28:46 PM (18 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 6a972af1108afd9ad6a0a74a519e0b3107421d16
- Parents:
- f498f1081627c853c4d77077fcaa2ea32d82a711
- Location:
- kernel
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/Makefile.in
rf498f10 r585bbcb 100 100 longalg.cc longrat.cc longrat0.cc \ 101 101 maps.cc matpol.cc misc.cc gnumpfl.cc gnumpc.cc \ 102 modulop.cc mpr_complex.cc sparsmat.cc fast_maps.cc \102 rmodulo2m.cc modulop.cc mpr_complex.cc sparsmat.cc fast_maps.cc \ 103 103 fglmzero.cc fglmvec.cc fglmgauss.cc fglmhom.cc fglmcomb.cc \ 104 104 numbers.cc polys.cc p_polys.cc polys0.cc polys1.cc polys-impl.cc \ … … 156 156 gring.h walkProc.h walkMain.h walkSupport.h\ 157 157 ffields.h khstd.h sparsmat.h gnumpfl.h gnumpc.h \ 158 fglm.h kstd1.h modulop.h sing_dbm.h weight.h \158 fglm.h kstd1.h rmodulo2m.h modulop.h sing_dbm.h weight.h \ 159 159 fglmgauss.h fglmvec.h \ 160 160 kstdfac.h kmatrix.h\ -
kernel/kspoly.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kspoly.cc,v 1. 1.1.1 2003-10-06 12:15:56 SingularExp $ */4 /* $Id: kspoly.cc,v 1.2 2005-11-27 15:28:44 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT - Routines for Spoly creation and reductions … … 116 116 number bn = pGetCoeff(lm); 117 117 number an = pGetCoeff(p2); 118 #ifdef HAVE_RING2TOM 119 if (currRing->cring == 1) { 120 while (((long) an)%2 == 0 && ((long) bn)%2 == 0) { 121 an = (number) (((long) an) / 2); 122 bn = (number) (((long) bn) / 2); 123 } 124 } 125 #endif 118 126 int ct = ksCheckCoeff(&an, &bn); 119 127 p_SetCoeff(lm, bn,tailRing); … … 140 148 return ret; 141 149 } 150 151 #ifdef HAVE_RING2TOM 152 /*************************************************************** 153 * 154 * Reduces PR with PW 155 * Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR) 156 * as above, just for rings 157 * 158 ***************************************************************/ 159 int ksRingReducePoly(LObject* PR, 160 TObject* PW, 161 poly spNoether, 162 number *coef, 163 kStrategy strat) 164 { 165 #ifdef KDEBUG 166 red_count++; 167 #ifdef TEST_OPT_DEBUG_RED 168 if (TEST_OPT_DEBUG) 169 { 170 Print("Red %d:", red_count); PR->wrp(); Print(" with:"); 171 PW->wrp(); 172 } 173 #endif 174 #endif 175 int ret = 0; 176 ring tailRing = PR->tailRing; 177 kTest_L(PR); 178 kTest_T(PW); 179 180 poly p1 = PR->GetLmTailRing(); 181 poly p2 = PW->GetLmTailRing(); 182 poly t2 = pNext(p2), lm = p1; 183 assume(p1 != NULL && p2 != NULL); 184 p_CheckPolyRing(p1, tailRing); 185 p_CheckPolyRing(p2, tailRing); 186 187 pAssume1(p2 != NULL && p1 != NULL && 188 p_RingDivisibleBy(p2, p1, tailRing)); 189 190 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) || 191 (p_GetComp(p2, tailRing) == 0 && 192 p_MaxComp(pNext(p2),tailRing) == 0)); 193 194 if (t2==NULL) 195 { 196 PR->LmDeleteAndIter(); 197 if (coef != NULL) *coef = n_Init(1, tailRing); 198 return 0; 199 } 200 201 p_ExpVectorSub(lm, p2, tailRing); 202 203 if (tailRing != currRing) 204 { 205 // check that reduction does not violate exp bound 206 while (PW->max != NULL && !p_LmExpVectorAddIsOk(lm, PW->max, tailRing)) 207 { 208 // undo changes of lm 209 p_ExpVectorAdd(lm, p2, tailRing); 210 if (strat == NULL) return 2; 211 if (! kStratChangeTailRing(strat, PR, PW)) return -1; 212 tailRing = strat->tailRing; 213 p1 = PR->GetLmTailRing(); 214 p2 = PW->GetLmTailRing(); 215 t2 = pNext(p2); 216 lm = p1; 217 p_ExpVectorSub(lm, p2, tailRing); 218 ret = 1; 219 } 220 } 221 222 // take care of coef buisness 223 if (! n_IsOne(pGetCoeff(p2), tailRing)) 224 { 225 number bn = pGetCoeff(lm); 226 number an = pGetCoeff(p2); 227 while (((long) an)%2 == 0 && ((long) bn)%2 == 0) { 228 an = (number) (((long) an) / 2); 229 bn = (number) (((long) bn) / 2); 230 } 231 int ct = ksCheckCoeff(&an, &bn); 232 p_SetCoeff(lm, bn,tailRing); 233 if ((ct == 0) || (ct == 2)) 234 PR->Tail_Mult_nn(an); 235 if (coef != NULL) *coef = an; 236 else n_Delete(&an, tailRing); 237 } 238 else 239 { 240 if (coef != NULL) *coef = n_Init(1, tailRing); 241 } 242 243 244 // and finally, 245 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether); 246 PR->LmDeleteAndIter(); 247 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) 248 if (TEST_OPT_DEBUG) 249 { 250 Print(" to: "); PR->wrp(); Print("\n"); 251 } 252 #endif 253 return ret; 254 } 255 #endif 142 256 143 257 /*************************************************************** … … 166 280 poly a1 = pNext(p1), a2 = pNext(p2); 167 281 number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2); 282 #ifdef HAVE_RING2TOM 283 if (currRing->cring == 1) { 284 while (((long) lc1)%2 == 0 && ((long) lc2)%2 == 0) { 285 lc1 = (number) (((long) lc1) / 2); 286 lc2 = (number) (((long) lc2) / 2); 287 } 288 } 289 #endif 168 290 int co=0, ct = ksCheckCoeff(&lc1, &lc2); 169 291 -
kernel/kstd1.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd1.cc,v 1. 8 2005-04-26 08:58:52 SingularExp $ */4 /* $Id: kstd1.cc,v 1.9 2005-11-27 15:28:44 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: … … 999 999 else 1000 1000 strat->red = redHomog; 1001 #ifdef HAVE_RING2TOM 1002 if (currRing->cring == 1) { 1003 strat->red = redRing2toM; 1004 } 1005 #endif 1001 1006 if (pLexOrder && strat->honey) 1002 1007 strat->initEcart = initEcartNormal; -
kernel/kstd2.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd2.cc,v 1. 3 2005-10-17 13:42:48 SingularExp $ */4 /* $Id: kstd2.cc,v 1.4 2005-11-27 15:28:44 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: alg. of Buchberger … … 103 103 } 104 104 } 105 106 #ifdef HAVE_RING2TOM 107 // return -1 if no divisor is found 108 // number of first divisor, otherwise 109 int kRingFindDivisibleByInT(const TSet &T, const unsigned long* sevT, 110 const int tl, const LObject* L, const int start) 111 { 112 unsigned long not_sev = ~L->sev; 113 int j = start; 114 poly p; 115 ring r; 116 L->GetLm(p, r); 117 118 pAssume(~not_sev == p_GetShortExpVector(p, r)); 119 120 { 121 loop 122 { 123 if (j > tl) return -1; 124 #if defined(PDEBUG) || defined(PDIV_DEBUG) 125 if (p_LmRingShortDivisibleBy(T[j].p, sevT[j], 126 p, not_sev, r)) 127 return j; 128 #else 129 if ( !(sevT[j] & not_sev) && 130 p_LmRingDivisibleBy(T[j].p, p, r) ) 131 return j; 132 #endif 133 j++; 134 } 135 } 136 return -1; 137 } 138 139 // same as above, only with set S 140 int kRingFindDivisibleByInS(const polyset &S, const unsigned long* sev, const int sl, LObject* L) 141 { 142 unsigned long not_sev = ~L->sev; 143 poly p = L->GetLmCurrRing(); 144 int j = 0; 145 //PrintS("FindDiv: p="); wrp(p); PrintLn(); 146 pAssume(~not_sev == p_GetShortExpVector(p, currRing)); 147 loop 148 { 149 //PrintS("FindDiv: S[j]="); wrp(S[j]); PrintLn(); 150 if (j > sl) return -1; 151 #if defined(PDEBUG) || defined(PDIV_DEBUG) 152 if (p_LmRingShortDivisibleBy(S[j], sev[j], 153 p, not_sev, currRing)) 154 return j; 155 #else 156 if ( !(sev[j] & not_sev) && 157 p_LmRingDivisibleBy(S[j], p, currRing) ) 158 return j; 159 #endif 160 j++; 161 } 162 } 163 164 /*2 165 * reduction procedure for the ring Z/2^m 166 */ 167 int redRing2toM (LObject* h,kStrategy strat) 168 { 169 // PrintS("redRing2toM"); 170 // PrintLn(); 171 if (strat->tl<0) return 1; 172 int at,d,i; 173 int j = 0; 174 int pass = 0; 175 assume(h->pFDeg() == h->FDeg); 176 long reddeg = h->GetpFDeg(); 177 178 h->SetShortExpVector(); 179 loop 180 { 181 j = kRingFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h); 182 if (j < 0) return 1; 183 184 #ifdef KDEBUG 185 if (TEST_OPT_DEBUG) 186 { 187 PrintS("red:"); 188 h->wrp(); 189 PrintS(" with "); 190 strat->T[j].wrp(); 191 } 192 #endif 193 194 ksRingReducePoly(h, &(strat->T[j]), NULL, NULL, strat); 195 196 #ifdef KDEBUG 197 if (TEST_OPT_DEBUG) 198 { 199 PrintS("\nto "); 200 h->wrp(); 201 PrintLn(); 202 } 203 #endif 204 205 if (h->GetLmTailRing() == NULL) 206 { 207 if (h->lcm!=NULL) pLmFree(h->lcm); 208 #ifdef KDEBUG 209 h->lcm=NULL; 210 #endif 211 return 0; 212 } 213 h->SetShortExpVector(); 214 d = h->SetpFDeg(); 215 /*- try to reduce the s-polynomial -*/ 216 pass++; 217 if (!K_TEST_OPT_REDTHROUGH && 218 (strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) 219 { 220 h->SetLmCurrRing(); 221 at = strat->posInL(strat->L,strat->Ll,h,strat); 222 if (at <= strat->Ll) 223 { 224 #if 0 225 if (kRingFindDivisibleByInS(strat->S, strat->sevS, strat->sl, h) < 0) 226 return 1; 227 #endif 228 #ifdef KDEBUG 229 if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at); 230 #endif 231 enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); 232 h->Clear(); 233 return -1; 234 } 235 } 236 else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d != reddeg)) 237 { 238 Print(".%d",d);mflush(); 239 reddeg = d; 240 } 241 } 242 } 243 #endif 105 244 106 245 /*2 … … 417 556 loop 418 557 { 419 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 558 #ifdef HAVE_RING2TOM 559 if (currRing->cring == 1) { 560 j=kRingFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 561 } 562 else 563 #endif 564 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 420 565 if (j>=0) 421 566 { … … 520 665 #ifdef KDEBUG 521 666 loop_count++; 667 #ifdef HAVE_RING2TOM 668 if (TEST_OPT_DEBUG) PrintS("--- next step ---\n"); 669 #endif 522 670 if (TEST_OPT_DEBUG) messageSets(strat); 523 671 #endif -
kernel/kutil.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.1 1 2005-11-02 08:44:46 SingularExp $ */4 /* $Id: kutil.cc,v 1.12 2005-11-27 15:28:45 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for kStd … … 2757 2757 } 2758 2758 2759 #ifdef HAVE_RING2TOM 2760 TObject* 2761 kRingFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T, 2762 long ecart) 2763 { 2764 int j = 0; 2765 const unsigned long not_sev = ~L->sev; 2766 const unsigned long* sev = strat->sevS; 2767 poly p; 2768 ring r; 2769 L->GetLm(p, r); 2770 2771 assume(~not_sev == p_GetShortExpVector(p, r)); 2772 2773 if (r == currRing) 2774 { 2775 loop 2776 { 2777 if (j > pos) return NULL; 2778 #if defined(PDEBUG) || defined(PDIV_DEBUG) 2779 if (p_LmRingShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) && 2780 (ecart== LONG_MAX || ecart>= strat->ecartS[j])) 2781 break; 2782 #else 2783 if (!(sev[j] & not_sev) && 2784 (ecart== LONG_MAX || ecart>= strat->ecartS[j]) && 2785 p_LmRingDivisibleBy(strat->S[j], p, r)) 2786 break; 2787 2788 #endif 2789 j++; 2790 } 2791 // if called from NF, T objects do not exist: 2792 if (strat->tl < 0 || strat->S_2_R[j] == -1) 2793 { 2794 T->Set(strat->S[j], r, strat->tailRing); 2795 return T; 2796 } 2797 else 2798 { 2799 assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL && 2800 strat->S_2_T(j)->p == strat->S[j]); 2801 return strat->S_2_T(j); 2802 } 2803 } 2804 else 2805 { 2806 TObject* t; 2807 loop 2808 { 2809 if (j > pos) return NULL; 2810 assume(strat->S_2_R[j] != -1); 2811 #if defined(PDEBUG) || defined(PDIV_DEBUG) 2812 t = strat->S_2_T(j); 2813 assume(t != NULL && t->t_p != NULL && t->tailRing == r); 2814 if (p_LmRingShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) && 2815 (ecart== LONG_MAX || ecart>= strat->ecartS[j])) 2816 return t; 2817 #else 2818 if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j])) 2819 { 2820 t = strat->S_2_T(j); 2821 assume(t != NULL && t->t_p != NULL && t->tailRing == r && t->p == strat->S[j]); 2822 if (p_LmRingDivisibleBy(t->t_p, p, r)) return t; 2823 } 2824 #endif 2825 j++; 2826 } 2827 } 2828 } 2829 #endif 2759 2830 2760 2831 poly redtail (LObject* L, int pos, kStrategy strat) … … 2836 2907 poly redtailBba (LObject* L, int pos, kStrategy strat, BOOLEAN withT) 2837 2908 { 2909 #ifdef HAVE_RING2TOM 2910 PrintS("Warning, redtail Bba not fully ring checked"); PrintLn(); 2911 #endif 2838 2912 strat->redTailChange=FALSE; 2839 2913 if (strat->noTailReduction) return L->GetLmCurrRing(); … … 2863 2937 if (! withT) 2864 2938 { 2865 With = kFindDivisibleByInS(strat, pos, &Ln, &With_s); 2939 #ifdef HAVE_RING2TOM 2940 if (currRing->cring == 1) { 2941 With = kRingFindDivisibleByInS(strat, pos, &Ln, &With_s); 2942 } else 2943 #endif 2944 With = kFindDivisibleByInS(strat, pos, &Ln, &With_s); 2866 2945 if (With == NULL) break; 2867 2946 } 2868 2947 else 2869 2948 { 2870 int j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, &Ln); 2949 int j; 2950 #ifdef HAVE_RING2TOM 2951 if (currRing->cring == 1) { 2952 j = kRingFindDivisibleByInT(strat->T, strat->sevT, strat->tl, &Ln); 2953 } else 2954 #endif 2955 j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, &Ln); 2871 2956 if (j < 0) break; 2872 2957 With = &(strat->T[j]); -
kernel/kutil.h
rf498f10 r585bbcb 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: kutil.h,v 1. 6 2005-11-02 08:43:57 SingularExp $ */6 /* $Id: kutil.h,v 1.7 2005-11-27 15:28:45 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT: kernel: utils for kStd … … 103 103 // allocate a new poly 104 104 KINLINE void GetLm(poly &p, ring &r) const; 105 106 #ifdef OLIVER_PRIVAT_LT 107 // routines for calc. with rings 108 KINLINE poly GetLtCurrRing(); 109 KINLINE poly GetLtTailRing(); 110 KINLINE poly GetLt(ring r); 111 KINLINE void GetLt(poly &p, ring &r) const; 112 #endif 113 105 114 KINLINE BOOLEAN IsNull() const; 106 115 … … 380 389 poly redNFTail (poly h,const int sl,kStrategy strat); 381 390 int redHoney (LObject* h, kStrategy strat); 391 #ifdef HAVE_RING2TOM 392 int redRing2toM (LObject* h,kStrategy strat); 393 #endif 382 394 int redLazy (LObject* h,kStrategy strat); 383 395 int redHomog (LObject* h,kStrategy strat); … … 426 438 long ecart = LONG_MAX); 427 439 440 #ifdef HAVE_RING2TOM 441 // same for rings 442 int kRingFindDivisibleByInT(const TSet &T, const unsigned long* sevT, 443 const int tl, const LObject* L, const int start=0); 444 int kRingFindDivisibleByInS(const polyset &S, const unsigned long* sev, 445 const int sl, LObject* L); 446 447 448 TObject* 449 kRingFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T, 450 long ecart = LONG_MAX); 451 #endif 428 452 429 453 /*************************************************************** … … 508 532 kStrategy strat = NULL); 509 533 534 #ifdef HAVE_RING2TOM 535 // same for rings 536 int ksRingReducePoly(LObject* PR, 537 TObject* PW, 538 poly spNoether = NULL, 539 number *coef = NULL, 540 kStrategy strat = NULL); 541 #endif 542 510 543 // Reduces PR at Current->next with PW 511 544 // Assumes PR != NULL, Current contained in PR -
kernel/numbers.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: numbers.cc,v 1. 1.1.1 2003-10-06 12:15:58 SingularExp $ */4 /* $Id: numbers.cc,v 1.2 2005-11-27 15:28:45 wienand Exp $ */ 5 5 6 6 /* … … 23 23 #include "ffields.h" 24 24 #include "shortfl.h" 25 #ifdef HAVE_RING2TOM 26 #include "rmodulo2m.h" 27 #endif 25 28 26 29 //static int characteristic = 0; … … 107 110 naSetChar(c,r); 108 111 } 112 #ifdef HAVE_RING2TOM 113 /*----------------------ring Z / 2^m----------------*/ 114 else if (rField_is_Ring_2toM(r)) 115 { 116 nr2mSetExp(c, r); 117 } 118 #endif 109 119 else if (rField_is_Zp(r)) 110 120 /*----------------------char. p----------------*/ … … 270 280 #endif 271 281 } 282 #ifdef HAVE_RING2TOM 283 /* -------------- Z/2^m ----------------------- */ 284 else if (rField_is_Ring_2toM(r)) 285 { 286 nr2mInitExp(c,r); 287 n->nInit = nr2mInit; 288 n->nCopy = ndCopy; 289 n->nInt = nr2mInt; 290 n->nAdd = nr2mAdd; 291 n->nSub = nr2mSub; 292 n->nMult = nr2mMult; 293 n->nDiv = nr2mDiv; 294 n->nExactDiv= nr2mDiv; 295 n->nNeg = nr2mNeg; 296 n->nInvers= nr2mInvers; 297 n->nGreater = nr2mGreater; 298 n->nEqual = nr2mEqual; 299 n->nIsZero = nr2mIsZero; 300 n->nIsOne = nr2mIsOne; 301 n->nIsMOne = nr2mIsMOne; 302 n->nGreaterZero = nr2mGreaterZero; 303 n->nWrite = nr2mWrite; 304 n->nRead = nr2mRead; 305 n->nPower = nr2mPower; 306 n->cfSetMap = nr2mSetMap; 307 n->nNormalize = nDummy2; 308 // n->nGetUnit = nr2mGetUnit; //TODO OLIVER 309 n->nName= ndName; 310 #ifdef LDEBUG 311 // n->nDBTest=nr2mDBTest; 312 #endif 313 } 314 #endif 272 315 else if (rField_is_Q(r)) 273 316 { -
kernel/pDebug.cc
rf498f10 r585bbcb 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pDebug.cc,v 1. 2 2005-04-18 13:01:40 SingularExp $9 * Version: $Id: pDebug.cc,v 1.3 2005-11-27 15:28:45 wienand Exp $ 10 10 *******************************************************************/ 11 11 … … 140 140 } 141 141 while (i); 142 return TRUE; 142 #ifdef HAVE_RING2TOM 143 if (r->cring == 1) { 144 long lside = (long) pGetCoeff(a); 145 long rside = (long) pGetCoeff(b); 146 while (lside%2 == 0 && rside%2 == 0) { 147 lside = lside / 2; 148 rside = rside / 2; 149 } 150 return (lside%2 != 0); 151 } 152 else 153 #endif 154 return TRUE; 143 155 } 144 156 -
kernel/pInline1.h
rf498f10 r585bbcb 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline1.h,v 1. 2 2004-07-29 14:56:39 SingularExp $9 * Version: $Id: pInline1.h,v 1.3 2005-11-27 15:28:45 wienand Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE1_H … … 369 369 } 370 370 371 #ifdef HAVE_RING2TOM 372 /*************************************************************** 373 * 374 * divisibility for rings (considers coefficients) 375 * 376 ***************************************************************/ 377 // return: FALSE, if there exists i, such that a->exp[i] > b->exp[i] 378 // TRUE, otherwise 379 // (1) Consider long vars, instead of single exponents 380 // (2) Clearly, if la > lb, then FALSE 381 // (3) Suppose la <= lb, and consider first bits of single exponents in l: 382 // if TRUE, then value of these bits is la ^ lb 383 // if FALSE, then la-lb causes an "overflow" into one of those bits, i.e., 384 // la ^ lb != la - lb 385 static inline BOOLEAN _p_LmRingDivisibleByNoComp(poly a, poly b, ring r) 386 { 387 int i=r->VarL_Size - 1; 388 unsigned long divmask = r->divmask; 389 unsigned long la, lb; 390 391 if (r->VarL_LowIndex >= 0) 392 { 393 i += r->VarL_LowIndex; 394 do 395 { 396 la = a->exp[i]; 397 lb = b->exp[i]; 398 if ((la > lb) || 399 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask))) 400 { 401 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == FALSE); 402 return FALSE; 403 } 404 i--; 405 } 406 while (i>=r->VarL_LowIndex); 407 } 408 else 409 { 410 do 411 { 412 la = a->exp[r->VarL_Offset[i]]; 413 lb = b->exp[r->VarL_Offset[i]]; 414 if ((la > lb) || 415 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask))) 416 { 417 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == FALSE); 418 return FALSE; 419 } 420 i--; 421 } 422 while (i>=0); 423 } 424 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == TRUE); 425 long lside = (long) p_GetCoeff(a,r); 426 long rside = (long) p_GetCoeff(b,r); 427 // Später durch bitvergleiche viel schneller TODO OLIVER 428 //Print("lside=%d", lside); PrintLn(); 429 //Print("rside=%d", rside); PrintLn(); 430 while (lside%2 == 0 && rside%2 == 0) { 431 lside = lside / 2; 432 rside = rside / 2; 433 } 434 //Print("lside=%d", lside); PrintLn(); 435 //Print("rside=%d", rside); PrintLn(); 436 return (lside%2 != 0); 437 } 438 #endif 439 371 440 static inline BOOLEAN _p_LmDivisibleByNoComp(poly a, ring r_a, poly b, ring r_b) 372 441 { … … 383 452 return TRUE; 384 453 } 454 455 #ifdef HAVE_RING2TOM 456 static inline BOOLEAN _p_LmRingDivisibleByNoComp(poly a, ring r_a, poly b, ring r_b) 457 { 458 int i=r_a->N; 459 pAssume1(r_a->N == r_b->N); 460 461 do 462 { 463 if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b)) 464 return FALSE; 465 i--; 466 } 467 while (i); 468 long lside = (long) p_GetCoeff(a, r_a); 469 long rside = (long) p_GetCoeff(b, r_b); 470 // Später durch bitvergleiche viel schneller TODO OLIVER 471 //Print("lside=%d", lside); PrintLn(); 472 //Print("rside=%d", rside); PrintLn(); 473 while (lside%2 == 0 && rside%2 == 0) { 474 lside = lside / 2; 475 rside = rside / 2; 476 } 477 //Print("lside=%d", lside); PrintLn(); 478 //Print("rside=%d", rside); PrintLn(); 479 return (lside%2 != 0); 480 } 481 #endif 482 385 483 static inline BOOLEAN _p_LmDivisibleBy(poly a, poly b, ring r) 386 484 { … … 409 507 return FALSE; 410 508 } 509 510 #ifdef HAVE_RING2TOM 511 PINLINE1 BOOLEAN p_LmRingDivisibleBy(poly a, poly b, ring r) 512 { 513 p_LmCheckPolyRing1(b, r); 514 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r)); 515 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)) 516 return _p_LmRingDivisibleByNoComp(a, b, r); 517 return FALSE; 518 } 519 #endif 520 411 521 PINLINE1 BOOLEAN p_DivisibleBy(poly a, poly b, ring r) 412 522 { … … 450 560 #endif 451 561 } 562 563 #ifdef HAVE_RING2TOM 564 PINLINE1 BOOLEAN p_LmRingShortDivisibleBy(poly a, unsigned long sev_a, 565 poly b, unsigned long not_sev_b, ring r) 566 { 567 p_LmCheckPolyRing1(a, r); 568 p_LmCheckPolyRing1(b, r); 569 #ifndef PDIV_DEBUG 570 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r); 571 _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r); 572 573 if (sev_a & not_sev_b) 574 { 575 pAssume1(_p_LmRingDivisibleByNoComp(a, b, r) == FALSE); 576 return FALSE; 577 } 578 return p_LmRingDivisibleBy(a, b, r); 579 #else 580 return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r); 581 #endif 582 } 583 #endif 452 584 453 585 PINLINE1 BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, ring r_a, -
kernel/p_Minus_mm_Mult_qq__T.cc
rf498f10 r585bbcb 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: p_Minus_mm_Mult_qq__T.cc,v 1. 1.1.1 2003-10-06 12:16:00 SingularExp $9 * Version: $Id: p_Minus_mm_Mult_qq__T.cc,v 1.2 2005-11-27 15:28:45 wienand Exp $ 10 10 *******************************************************************/ 11 11 … … 67 67 Equal: // qm equals p 68 68 tb = n_Mult(pGetCoeff(q), tm, r); 69 #ifdef HAVE_RING2TOM 70 if ((long) tb != 0) { 71 #endif 69 72 tc = pGetCoeff(p); 70 73 if (!n_Equal(tc, tb, r)) … … 83 86 p = p_LmFreeAndNext(p, r); 84 87 } 88 #ifdef HAVE_RING2TOM 89 } 90 #endif 85 91 n_Delete(&tb, r); 86 92 pIter(q); … … 91 97 92 98 Greater: 99 #ifdef HAVE_RING2TOM 100 tb = n_Mult(pGetCoeff(q), tneg, r); 101 if ((long) tb != 0) { 102 #endif 93 103 pSetCoeff0(qm, n_Mult(pGetCoeff(q), tneg, r)); 94 104 a = pNext(a) = qm; // append qm to result and advance q 105 #ifdef HAVE_RING2TOM 106 } 107 n_Delete(&tb, r); 108 #endif 95 109 pIter(q); 96 110 if (q == NULL) // are we done? -
kernel/polys.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1. 6 2005-04-21 17:15:49 SingularExp $ */4 /* $Id: polys.cc,v 1.7 2005-11-27 15:28:45 wienand Exp $ */ 5 5 6 6 /* … … 651 651 } 652 652 653 #ifdef HAVE_RING2TOM 654 number nGetUnit(number k) { 655 long test = (long) k; 656 while (test%2 == 0) { 657 test = test / 2; 658 } 659 return (number) test; 660 } 661 #endif 653 662 654 663 /*2 … … 659 668 poly h; 660 669 number k, c; 661 670 #ifdef HAVE_RING2TOM 671 if (currRing->cring != 0) 672 { 673 if (p1!=NULL) 674 { 675 k = nGetUnit(pGetCoeff(p1)); 676 if (!nIsOne(k)) 677 { 678 k = nGetUnit(pGetCoeff(p1)); 679 c = nDiv(pGetCoeff(p1), k); 680 pSetCoeff0(p1, c); 681 h = pNext(p1); 682 while (h != NULL) 683 { 684 c = nDiv(pGetCoeff(h), k); 685 pSetCoeff(h, c); 686 pIter(h); 687 } 688 nDelete(&k); 689 } 690 return; 691 } 692 } 693 #endif 662 694 if (p1!=NULL) 663 695 { … … 670 702 { 671 703 nNormalize(pGetCoeff(p1)); 672 k =pGetCoeff(p1);704 k = pGetCoeff(p1); 673 705 c = nInit(1); 674 706 pSetCoeff0(p1,c); … … 701 733 *normalize all coefficients 702 734 */ 703 void p_Normalize(poly p, ring r) 735 void p_Normalize(poly p, ring r) 704 736 { 705 737 if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */ -
kernel/polys.h
rf498f10 r585bbcb 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys.h,v 1. 6 2005-09-08 11:14:09 brickenExp $ */6 /* $Id: polys.h,v 1.7 2005-11-27 15:28:45 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT - all basic methods to manipulate polynomials of the … … 248 248 #define pIsPurePower(p) p_IsPurePower(p, currRing) 249 249 #define pIsVector(p) (pGetComp(p)>0) 250 251 #ifdef HAVE_RING2TOM 252 /* 253 * Test stuff for dev OLIVER 254 */ 255 256 number nGetUnit(number k); 257 #endif 250 258 251 259 -
kernel/polys1.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys1.cc,v 1.1 5 2005-09-08 11:14:10 brickenExp $ */4 /* $Id: polys1.cc,v 1.16 2005-11-27 15:28:46 wienand Exp $ */ 5 5 6 6 /* … … 483 483 void pContent(poly ph) 484 484 { 485 #ifdef HAVE_RING2TOM 486 if (currRing->cring!=0) return; //TODO OLIVER 487 #endif 485 488 number h,d; 486 489 poly p; … … 1012 1015 poly p; 1013 1016 1017 #ifdef HAVE_RING2TOM 1018 if (currRing->cring == 1) { 1019 pNorm(ph); 1020 return; 1021 } 1022 #endif 1014 1023 p = ph; 1015 1024 if(pNext(p)==NULL) -
kernel/pp_Mult_mm__T.cc
rf498f10 r585bbcb 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pp_Mult_mm__T.cc,v 1. 1.1.1 2003-10-06 12:16:02 SingularExp $9 * Version: $Id: pp_Mult_mm__T.cc,v 1.2 2005-11-27 15:28:46 wienand Exp $ 10 10 *******************************************************************/ 11 11 … … 33 33 pAssume(!n_IsZero(ln,ri)); 34 34 pAssume1(p_GetComp(m, ri) == 0 || p_MaxComp(p, ri) == 0); 35 35 number tmp; 36 36 37 37 do 38 38 { 39 p_AllocBin( pNext(q), bin, ri); 40 q = pNext(q); 41 pSetCoeff0(q, n_Mult(ln, pGetCoeff(p), ri)); 42 p_MemSum(q->exp, p->exp, m_e, length); 43 p_MemAddAdjust(q, ri); 39 tmp = n_Mult(ln, pGetCoeff(p), ri); 40 #ifdef HAVE_RING2TOM 41 if (ri->cring==0 || (ri->cring ==1 && (long) tmp != 0)){ 42 #endif 43 p_AllocBin( pNext(q), bin, ri); 44 q = pNext(q); 45 pSetCoeff0(q, tmp); 46 p_MemSum(q->exp, p->exp, m_e, length); 47 p_MemAddAdjust(q, ri); 48 #ifdef HAVE_RING2TOM 49 } 50 #endif 44 51 p = pNext(p); 45 52 } -
kernel/ring.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.4 3 2005-11-17 16:51:39 SingularExp $ */4 /* $Id: ring.cc,v 1.44 2005-11-27 15:28:46 wienand Exp $ */ 5 5 6 6 /* … … 2703 2703 2704 2704 // set intStrategy 2705 #ifdef HAVE_RING2TOM 2706 if (rField_is_Extension(r) || rField_is_Q(r) || rField_is_Ring_2toM(r)) 2707 #else 2705 2708 if (rField_is_Extension(r) || rField_is_Q(r)) 2709 #endif 2706 2710 r->options |= Sy_bit(OPT_INTSTRATEGY); 2707 2711 else -
kernel/ring.h
rf498f10 r585bbcb 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1.1 2 2005-09-28 15:00:37 SingularExp $ */9 /* $Id: ring.h,v 1.13 2005-11-27 15:28:46 wienand Exp $ */ 10 10 11 11 /* includes */ … … 79 79 BOOLEAN rRing_has_CompLastBlock(ring r=currRing); 80 80 81 #ifdef HAVE_RING2TOM 82 inline BOOLEAN rField_is_Ring_2toM(ring r=currRing) 83 { return (r->cring == 1); } 84 85 inline BOOLEAN rField_is_Zp(ring r=currRing) 86 { return (r->cring == 0) && (r->ch > 1) && (r->parameter==NULL); } 87 88 inline BOOLEAN rField_is_Zp(ring r, int p) 89 { return (r->cring == 0) && (r->ch > 1 && r->ch == ABS(p) && r->parameter==NULL); } 90 91 inline BOOLEAN rField_is_Q(ring r=currRing) 92 { return (r->cring == 0) && (r->ch == 0) && (r->parameter==NULL); } 93 94 inline BOOLEAN rField_is_numeric(ring r=currRing) /* R, long R, long C */ 95 { return (r->cring == 0) && (r->ch == -1); } 96 97 inline BOOLEAN rField_is_R(ring r=currRing) 98 { 99 if (rField_is_numeric(r) && (r->float_len <= (short)SHORT_REAL_LENGTH)) 100 return (r->cring == 0) && (r->parameter==NULL); 101 return FALSE; 102 } 103 104 inline BOOLEAN rField_is_GF(ring r=currRing) 105 { return (r->cring == 0) && (r->ch > 1) && (r->parameter!=NULL); } 106 107 inline BOOLEAN rField_is_GF(ring r, int q) 108 { return (r->cring == 0) && (r->ch == q); } 109 110 inline BOOLEAN rField_is_Zp_a(ring r=currRing) 111 { return (r->cring == 0) && (r->ch < -1); } 112 113 inline BOOLEAN rField_is_Zp_a(ring r, int p) 114 { return (r->cring == 0) && (r->ch < -1 ) && (-(r->ch) == ABS(p)); } 115 116 inline BOOLEAN rField_is_Q_a(ring r=currRing) 117 { return (r->cring == 0) && (r->ch == 1); } 118 119 inline BOOLEAN rField_is_long_R(ring r=currRing) 120 { 121 if (rField_is_numeric(r) && (r->float_len >(short)SHORT_REAL_LENGTH)) 122 return (r->cring == 0) && (r->parameter==NULL); 123 return FALSE; 124 } 125 126 inline BOOLEAN rField_is_long_C(ring r=currRing) 127 { 128 if (rField_is_numeric(r)) 129 return (r->cring == 0) && (r->parameter!=NULL); 130 return FALSE; 131 } 132 #else 81 133 inline BOOLEAN rField_is_Zp(ring r=currRing) 82 134 { return (r->ch > 1) && (r->parameter==NULL); } … … 126 178 return FALSE; 127 179 } 180 #endif 128 181 129 182 inline BOOLEAN rField_has_simple_inverse(ring r=currRing) 130 183 /* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/ 184 #ifdef HAVE_RING2TOM 185 { return (r->cring==1) || (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/ 186 #else 131 187 { return (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/ 188 #endif 132 189 133 190 inline BOOLEAN rField_has_simple_Alloc(ring r=currRing) 191 #ifdef HAVE_RING2TOM 192 { return (rField_is_Ring_2toM(r) || rField_is_Zp(r) || rField_is_GF(r) || rField_is_R(r)); } 193 #else 134 194 { return (rField_is_Zp(r) || rField_is_GF(r) || rField_is_R(r)); } 195 #endif 135 196 136 197 /* Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies*/ -
kernel/ringgb.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ringgb.cc,v 1. 1 2005-07-08 12:21:53 brickenExp $ */4 /* $Id: ringgb.cc,v 1.2 2005-11-27 15:28:46 wienand Exp $ */ 5 5 /* 6 * ABSTRACT: trepgb interface6 * ABSTRACT: ringgb interface 7 7 */ 8 #define HAVE_TAIL_RING 9 #define NO_BUCKETS 10 8 11 #include "mod2.h" 12 #include "kutil.h" 13 #include "structs.h" 14 #include "omalloc.h" 15 #include "polys.h" 16 #include "p_polys.h" 17 #include "ideals.h" 18 #include "febase.h" 19 #include "kstd1.h" 20 #include "khstd.h" 21 #include "kbuckets.h" 22 #include "weight.h" 23 #include "intvec.h" 24 #include "pInline1.h" 25 #ifdef HAVE_PLURAL 26 #include "gring.h" 27 #endif 28 9 29 #include "ringgb.h" 10 #include "polys.h" 11 int foo(int bar){12 return bar + 1;30 31 poly reduce_poly_fct(poly p, ring r) { 32 return NULL; 13 33 } 14 poly myadd(poly p, poly q, ring r){ 15 return p_Add_q(p_Copy(p,r),p_Copy(q,r),r); 34 35 /* 36 * Returns maximal k, such that 37 * 2^k | n 38 */ 39 int indexOf2(number n) { 40 long test = (long) n; 41 int i = 0; 42 while (test%2 == 0) { 43 i++; 44 test = test / 2; 45 } 46 return i; 16 47 } 48 49 /* 50 * Find an index i from G, such that 51 * LT(rside) = x * LT(G[i]) has a solution 52 * or -1 if rside is not in the 53 * ideal of the leading coefficients 54 * of the suitable g from G. 55 */ 56 int findRing2toMsolver(poly rside, ideal G, ring r) { 57 if (rside == NULL) return -1; 58 int i; 59 int iO2rside = indexOf2(pGetCoeff(rside)); 60 for (i = 0; i < IDELEMS(G); i++) { 61 if (indexOf2(pGetCoeff(G->m[i])) <= iO2rside && p_LmDivisibleBy(G->m[i], rside, r)) { 62 return i; 63 } 64 } 65 return -1; 66 } 67 68 /*************************************************************** 69 * 70 * Lcm business 71 * 72 ***************************************************************/ 73 // get m1 = LCM(LM(p1), LM(p2))/LM(p1) 74 // m2 = LCM(LM(p1), LM(p2))/LM(p2) 75 BOOLEAN ring2toM_GetLeadTerms(const poly p1, const poly p2, const ring p_r, 76 poly &m1, poly &m2, const ring m_r) 77 { 78 79 int i; 80 Exponent_t x; 81 m1 = p_Init(m_r); 82 m2 = p_Init(m_r); 83 84 for (i = p_r->N; i; i--) 85 { 86 x = p_GetExpDiff(p1, p2, i, p_r); 87 if (x > 0) 88 { 89 p_SetExp(m2,i,x, m_r); 90 p_SetExp(m1,i,0, m_r); 91 } 92 else 93 { 94 p_SetExp(m1,i,-x, m_r); 95 p_SetExp(m2,i,0, m_r); 96 } 97 } 98 p_Setm(m1, m_r); 99 p_Setm(m2, m_r); 100 long cp1 = (long) pGetCoeff(p1); 101 long cp2 = (long) pGetCoeff(p2); 102 if (cp1 != 0 && cp2 != 0) { 103 while (cp1%2 == 0 && cp2%2 == 0) { 104 cp1 = cp1 / 2; 105 cp2 = cp2 / 2; 106 } 107 } 108 p_SetCoeff(m1, (number) cp2, m_r); 109 p_SetCoeff(m2, (number) cp1, m_r); 110 return TRUE; 111 } 112 113 void printPolyMsg(char * start, poly f, char * end){ 114 PrintS(start); 115 wrp(f); 116 PrintS(end); 117 } 118 119 poly spolyRing2toM(poly f, poly g, ring r) { 120 poly m1 = NULL; 121 poly m2 = NULL; 122 ring2toM_GetLeadTerms(f, g, r, m1, m2, r); 123 printPolyMsg("spoly: m1=", m1, " | "); 124 printPolyMsg("m2=", m2, ""); 125 PrintLn(); 126 return pSub(pp_Mult_mm(f, m1, r), pp_Mult_mm(g, m2, r)); 127 } 128 129 poly ringNF(poly f, ideal G, ring r) { 130 // If f = 0, then normal form is also 0 131 if (f == NULL) { return NULL; } 132 poly h = pCopy(f); 133 int i = findRing2toMsolver(h, G, r); 134 int c = 1; 135 while (h != NULL && i >= 0 && c < 20) { 136 Print("%d-step NF - h:", c); 137 wrp(h); 138 PrintS(" "); 139 PrintS("G->m[i]:"); 140 wrp(G->m[i]); 141 PrintLn(); 142 h = spolyRing2toM(h, G->m[i], r); 143 PrintS("=> h="); 144 wrp(h); 145 PrintLn(); 146 i = findRing2toMsolver(h, G, r); 147 c++; 148 } 149 return h; 150 } 151 152 poly ringRedNF (poly f, ideal G, ring r) { 153 // If f = 0, then normal form is also 0 154 if (f == NULL) { return NULL; } 155 poly h = NULL; 156 poly g = pCopy(f); 157 int c = 0; 158 while (g != NULL && c < 20) { 159 Print("%d-step RedNF - g=", c); 160 wrp(g); 161 PrintS(" | h="); 162 wrp(h); 163 PrintLn(); 164 g = ringNF(g, G, r); 165 if (g != NULL) { 166 h = pAdd(h, pHead(g)); 167 pLmDelete(&g); 168 } 169 c++; 170 } 171 return h; 172 } -
kernel/ringgb.h
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ringgb.h,v 1. 1 2005-07-08 12:21:53 brickenExp $ */4 /* $Id: ringgb.h,v 1.2 2005-11-27 15:28:46 wienand Exp $ */ 5 5 /* 6 * ABSTRACT: trepgb interface6 * ABSTRACT: ringgb interface 7 7 */ 8 8 #ifndef RINGGB_HEADER … … 11 11 #include "polys.h" 12 12 13 poly reduce_poly_fct(poly p, ring r); 14 poly ringRedNF(poly f, ideal G, ring r); 15 poly ringNF(poly f, ideal G, ring r); 13 16 14 int foo(int bar);15 poly myadd(poly p, poly q, ring r);16 17 #endif -
kernel/structs.h
rf498f10 r585bbcb 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1.1 4 2005-11-08 07:28:59 brickenExp $ */6 /* $Id: structs.h,v 1.15 2005-11-27 15:28:46 wienand Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 440 440 struct omBin_s* PolyBin; /* Bin from where monoms are allocated */ 441 441 int ch; /* characteristic */ 442 #ifdef HAVE_RING2TOM 443 int cring; /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */ 444 #endif 442 445 int ref; /* reference counter to the ring */ 443 446 444 447 short float_len; /* additional char-flags */ 445 448 short float_len2; /* additional char-flags */
Note: See TracChangeset
for help on using the changeset viewer.