Changeset d491e3 in git
- Timestamp:
- Jul 20, 2005, 1:12:43 PM (18 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 634dab087e9b393fec1655c78c584e20750b3db3
- Parents:
- cf2307dc9864719fabb9577ce88d785d229b1eea
- Location:
- kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/tgb.cc
rcf2307d rd491e3 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* $Id: tgb.cc,v 1.3 4 2005-06-02 12:38:51bricken Exp $ */7 /* $Id: tgb.cc,v 1.35 2005-07-20 11:12:43 bricken Exp $ */ 8 8 /* 9 9 * ABSTRACT: slimgb and F4 implementation … … 14 14 #include "tgbgauss.h" 15 15 #include "F4.h" 16 #include "gring.h" 17 //#include "gr_kstd2.h" 16 18 #include "longrat.h" 17 19 static const int bundle_size=100; … … 220 222 // return pLength(p); 221 223 // } 224 225 226 227 228 229 230 231 222 232 static inline int pQuality(poly p, slimgb_alg* c, int l=-1){ 223 233 224 234 if(l<0) 225 235 l=pLength(p); 226 if(c->is_char0) return pSLength(p,l); 236 if(c->is_char0) { 237 if((pLexOrder) &&(!c->is_homog)){ 238 int cs; 239 number coef=pGetCoeff(p); 240 if (rField_is_Q(currRing)){ 241 cs=QlogSize(coef); 242 } 243 else 244 cs=nSize(coef); 245 return cs*pELength(p,c,l); 246 } 247 return pSLength(p,l); 248 } 227 249 if((pLexOrder) &&(!c->is_homog)) return pELength(p,c,l); 228 250 return l; 229 251 } 252 230 253 static inline int pTotaldegree_full(poly p){ 231 254 int r=0; … … 242 265 //case, you have to look on coefs 243 266 int s=0; 244 if (c->is_char0) 267 if (c->is_char0){ 245 268 //s=kSBucketLength(bucket,this->p); 269 if((pLexOrder) &&(!c->is_homog)){ 270 int cs; 271 number coef; 272 273 coef=pGetCoeff(kBucketGetLm(bucket)); 274 //c=nSize(pGetCoeff(kBucketGetLm(b))); 275 276 //c=nSize(pGetCoeff(lm)); 277 if (rField_is_Q(currRing)){ 278 cs=QlogSize(coef); 279 } 280 else 281 cs=nSize(coef); 282 if (bucket->coef[0]!=NULL){ 283 if (rField_is_Q(currRing)){ 284 int modifier=QlogSize(pGetCoeff(bucket->coef[0])); 285 cs+=modifier; 286 } 287 else{ 288 int modifier=nSize(pGetCoeff(bucket->coef[0])); 289 cs*=modifier;} 290 } 291 return cs*kEBucketLength(this->bucket,this->p,c); 292 } 246 293 s=kSBucketLength(bucket,NULL); 294 } 247 295 else 248 296 { … … 255 303 return s; 256 304 } 305 257 306 // static int guess_quality(const red_object & p, slimgb_alg* c){ 258 307 // //looks only on bucket … … 583 632 static void length_one_crit(slimgb_alg* c, int pos, int len) 584 633 { 634 if (c->nc) 635 return; 585 636 if (len==1) 586 637 { … … 595 646 c->states[i][pos]=HASTREP; 596 647 } 597 shorten_tails(c,c->S->m[pos]); 648 if (!c->nc) 649 shorten_tails(c,c->S->m[pos]); 598 650 } 599 651 } … … 1036 1088 continue; 1037 1089 } else 1038 if (( c->lengths[i]==1) && (c->lengths[j]==1))1090 if ((!c->nc) && (c->lengths[i]==1) && (c->lengths[j]==1)) 1039 1091 c->states[i][j]=HASTREP; 1040 else if ( pHasNotCF(c->S->m[i],c->S->m[j]))1092 else if ((!(c->nc)) && (pHasNotCF(c->S->m[i],c->S->m[j]))) 1041 1093 { 1042 1094 c->easy_product_crit++; … … 1165 1217 add_to_reductors(c, h, c->lengths[c->n-1]); 1166 1218 //i=posInS(c->strat,c->strat->sl,h,0 ecart); 1167 1168 if (c->lengths[c->n-1]==1) 1169 shorten_tails(c,c->S->m[c->n-1]); 1219 if (!(c->nc)){ 1220 if (c->lengths[c->n-1]==1) 1221 shorten_tails(c,c->S->m[c->n-1]); 1222 } 1170 1223 //you should really update c->lengths, c->strat->lenS, and the oder of polys in strat if you sort after lengths 1171 1224 … … 1196 1249 1197 1250 1198 1199 1200 1201 1202 1203 1251 static poly redNF2 (poly h,slimgb_alg* c , int &len, number& m,int n) 1204 1252 { … … 1219 1267 // BOOLEAN corr=lenS_correct(strat); 1220 1268 kBucketInit(P.bucket,P.p,len /*pLength(P.p)*/); 1269 intset lenSw=strat->lenS; 1270 if (strat->lenSw!=NULL) 1271 lenSw=strat->lenSw; 1221 1272 //int max_pos=simple_posInS(strat,P.p); 1222 1273 loop … … 1224 1275 1225 1276 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 1226 if ((j>=0) && ((!n)||( strat->lenS[j]<=n)))1277 if ((j>=0) && ((!n)||(lenSw[j]<=n))) 1227 1278 { 1228 1279 … … 1277 1328 1278 1329 1330 1279 1331 static poly redTailShort(poly h, kStrategy strat){ 1280 1332 … … 1312 1364 static void c_S_element_changed_hook(int pos, slimgb_alg* c){ 1313 1365 length_one_crit(c,pos, c->lengths[pos]); 1314 line_of_extended_prod(pos,c); 1366 if (!c->nc) 1367 line_of_extended_prod(pos,c); 1315 1368 } 1316 1369 class poly_tree_node { … … 1527 1580 quick_pop_pair(c); 1528 1581 if(s->i>=0){ 1582 //be careful replace_pair use createShortSpoly which is not noncommutative 1529 1583 //replace_pair(s->i,s->j,c); 1530 1584 if(s->i==s->j) { … … 1534 1588 } 1535 1589 poly h; 1536 if(s->i>=0) 1537 h=ksOldCreateSpoly(c->S->m[s->i], c->S->m[s->j], NULL, c->r); 1590 if(s->i>=0){ 1591 if (!c->nc) 1592 h=ksOldCreateSpoly(c->S->m[s->i], c->S->m[s->j], NULL, c->r); 1593 else 1594 h= nc_CreateSpoly(c->S->m[s->i], c->S->m[s->j], NULL, c->r); 1595 } 1538 1596 else 1539 1597 h=s->lcm_of_lm; … … 1542 1600 number coef; 1543 1601 int mlen=pLength(h); 1544 h=redNF2(h,c,mlen,coef,2); 1545 redTailShort(h,c->strat); 1546 nDelete(&coef); 1547 1602 if (!c->nc){ 1603 h=redNF2(h,c,mlen,coef,2); 1604 redTailShort(h,c->strat); 1605 nDelete(&coef); 1606 } 1548 1607 free_sorted_pair_node(s,c->r); 1549 1608 if(!h) continue; … … 1648 1707 // delete buf[j]; 1649 1708 //remember to free res here 1650 p=redTailShort(p, c->strat); 1709 if (!c->nc) 1710 p=redTailShort(p, c->strat); 1651 1711 sbuf[j]=add_to_basis_ideal_quotient(p,-1,-1,c,ibuf+j); 1652 1712 //sbuf[j]=add_to_basis(p,-1,-1,c,ibuf+j); … … 1683 1743 } 1684 1744 1685 static poly redNF (poly h,kStrategy strat, int &len) 1686 { 1687 len=0; 1688 if (h==NULL) return NULL; 1689 int j; 1690 1691 len=pLength(h); 1692 if (0 > strat->sl) 1693 { 1694 return h; 1695 } 1696 LObject P(h); 1697 P.SetShortExpVector(); 1698 P.bucket = kBucketCreate(currRing); 1699 kBucketInit(P.bucket,P.p,len /*pLength(P.p)*/); 1700 //int max_pos=simple_posInS(strat,P.p); 1701 loop 1702 { 1703 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 1704 if (j>=0) 1705 { 1706 nNormalize(pGetCoeff(P.p)); 1707 #ifdef KDEBUG 1708 if (TEST_OPT_DEBUG) 1709 { 1710 PrintS("red:"); 1711 wrp(h); 1712 PrintS(" with "); 1713 wrp(strat->S[j]); 1714 } 1715 #endif 1716 number coef=kBucketPolyRed(P.bucket,strat->S[j], 1717 strat->lenS[j]/*pLength(strat->S[j])*/, 1718 strat->kNoether); 1719 nDelete(&coef); 1720 h = kBucketGetLm(P.bucket); 1721 if (h==NULL) return NULL; 1722 P.p=h; 1723 P.t_p=NULL; 1724 P.SetShortExpVector(); 1725 #ifdef KDEBUG 1726 if (TEST_OPT_DEBUG) 1727 { 1728 PrintS("\nto:"); 1729 wrp(h); 1730 PrintLn(); 1731 } 1732 #endif 1733 } 1734 else 1735 { 1736 kBucketClear(P.bucket,&(P.p),&len); 1737 kBucketDestroy(&P.bucket); 1738 pNormalize(P.p); 1739 return P.p; 1740 } 1741 } 1742 } 1745 1743 1746 1744 1747 #ifdef REDTAIL_S … … 1901 1904 1902 1905 r=currRing; 1906 nc=rIsPluralRing(r); 1907 Print("nc %i",nc); 1903 1908 is_homog=TRUE; 1904 1909 { … … 1934 1939 //(rChar()==0); 1935 1940 F4_mode=F4; 1941 1936 1942 if ((!F4_mode)&&(!is_homog) &&(pLexOrder)){ 1937 1943 this->doubleSugar=TRUE; … … 2516 2522 //for impl reasons may return false if the the normal product criterion matches 2517 2523 static inline BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, slimgb_alg* c){ 2524 if (c->nc) 2525 return FALSE; 2518 2526 if(gcd1==NULL) return FALSE; 2519 2527 if(gcd2==NULL) return FALSE; … … 3071 3079 void reduction_step::reduce(red_object* r, int l, int u){} 3072 3080 void simple_reducer::target_is_no_sum_reduce(red_object & ro){ 3073 kBucketPolyRed(ro.bucket,p, 3074 p_len, 3075 c->strat->kNoether); 3081 number coef; 3082 if (!c->nc) 3083 coef=kBucketPolyRed(ro.bucket,p, 3084 p_len, 3085 c->strat->kNoether); 3086 else 3087 nc_kBucketPolyRed_Z(ro.bucket, p, &coef); 3088 nDelete(&coef); 3076 3089 } 3077 3090 … … 3146 3159 pSetExp(m,i,(pGetExp(r[erg.to_reduce_l].p, i)-pGetExp(red,i))); 3147 3160 pSetm(m); 3148 poly red_cp=ppMult_mm(red,m); 3149 3161 poly red_cp; 3162 if (!c->nc) 3163 red_cp=ppMult_mm(red,m); 3164 else 3165 red_cp=nc_mm_Mult_p(m, pCopy(red), c->r); 3150 3166 if(!erg.fromS){ 3151 3167 kBucketInit(r[rn].bucket,red,red_len); … … 3153 3169 //now reduce the copy 3154 3170 //static poly redNF2 (poly h,slimgb_alg* c , int &len, number& m,int n) 3155 redTailShort(red_cp,c->strat); 3171 if (!c->nc) 3172 redTailShort(red_cp,c->strat); 3156 3173 //number mul; 3157 3174 // red_len--; -
kernel/tgb_internal.h
rcf2307d rd491e3 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* $Id: tgb_internal.h,v 1.1 5 2005-06-01 09:06:04bricken Exp $ */7 /* $Id: tgb_internal.h,v 1.16 2005-07-20 11:12:43 bricken Exp $ */ 8 8 /* 9 9 * ABSTRACT: tgb internal .h file … … 130 130 BOOLEAN doubleSugar; 131 131 BOOLEAN F4_mode; 132 BOOLEAN nc; 132 133 }; 133 134 class red_object{ -
kernel/tgb_obsolete.cc
rcf2307d rd491e3 1 1 #include "tgb_internal.h" 2 static poly redNF (poly h,kStrategy strat, int &len) 3 { 4 len=0; 5 if (h==NULL) return NULL; 6 int j; 7 8 len=pLength(h); 9 if (0 > strat->sl) 10 { 11 return h; 12 } 13 LObject P(h); 14 P.SetShortExpVector(); 15 P.bucket = kBucketCreate(currRing); 16 kBucketInit(P.bucket,P.p,len /*pLength(P.p)*/); 17 //int max_pos=simple_posInS(strat,P.p); 18 loop 19 { 20 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 21 if (j>=0) 22 { 23 nNormalize(pGetCoeff(P.p)); 24 #ifdef KDEBUG 25 if (TEST_OPT_DEBUG) 26 { 27 PrintS("red:"); 28 wrp(h); 29 PrintS(" with "); 30 wrp(strat->S[j]); 31 } 32 #endif 33 number coef=kBucketPolyRed(P.bucket,strat->S[j], 34 strat->lenS[j]/*pLength(strat->S[j])*/, 35 strat->kNoether); 36 nDelete(&coef); 37 h = kBucketGetLm(P.bucket); 38 if (h==NULL) return NULL; 39 P.p=h; 40 P.t_p=NULL; 41 P.SetShortExpVector(); 42 #ifdef KDEBUG 43 if (TEST_OPT_DEBUG) 44 { 45 PrintS("\nto:"); 46 wrp(h); 47 PrintLn(); 48 } 49 #endif 50 } 51 else 52 { 53 kBucketClear(P.bucket,&(P.p),&len); 54 kBucketDestroy(&P.bucket); 55 pNormalize(P.p); 56 return P.p; 57 } 58 } 59 } 2 60 int find_best(red_object* r,int l, int u, int &w, calc_dat* c){ 3 61
Note: See TracChangeset
for help on using the changeset viewer.