Changeset f3b78d in git
- Timestamp:
- Feb 5, 2003, 6:01:48 PM (21 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 07100c2bf0e9614230a892fda7b9192889d6f8e4
- Parents:
- d713d78830adcab82fa3ce5686817d1dbdbe140a
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/tgb.cc
rd713d7 rf3b78d 5 5 6 6 #include "tgb.h" 7 8 9 #define LEN_VAR3 7 #define OM_KEEP 0 8 #define LEN_VAR1 10 9 11 10 #ifdef LEN_VAR1 … … 911 910 poly hp; 912 911 int i,j; 912 c->easy_product_crit=0; 913 c->extended_product_crit=0; 913 914 c->is_char0=(rChar()==0); 914 915 c->reduction_steps=0; … … 954 955 c->lengths=(int*) h; 955 956 h=omalloc(n*sizeof(int)); 957 c->gcd_of_terms=(poly*) omalloc(n*sizeof(poly)); 956 958 c->rep=(int*) h; 957 959 c->short_Exps=(long*) omalloc(n*sizeof(long)); … … 1001 1003 } 1002 1004 } 1005 //very important: ILM 1003 1006 1004 1007 //len should be weighted length in char 0 … … 1085 1088 c->lengths[i]=pLength(h); 1086 1089 hp=omrealloc(c->states, c->n * sizeof(char*)); 1087 if (hp!=NULL){1090 1088 1091 c->states=(char**) hp; 1089 } else { 1090 exit(1); 1091 } 1092 c->gcd_of_terms=(poly*) omrealloc(c->gcd_of_terms, c->n *sizeof(poly)); 1093 c->gcd_of_terms[i]=gcd_of_terms(h,c->r); 1092 1094 c->deg=(int**) omrealloc(c->deg, c->n * sizeof(int*)); 1093 1095 c->rep[i]=i; … … 1142 1144 if ((c->lengths[i]==1) && (c->lengths[j]==1)) 1143 1145 c->states[i][j]=HASTREP; 1144 else if (pHasNotCF(c->S->m[i],c->S->m[j])) 1146 else if (pHasNotCF(c->S->m[i],c->S->m[j])){ 1147 c->easy_product_crit++; 1145 1148 c->states[i][j]=HASTREP; 1149 } 1150 else if(extended_product_criterion(c->S->m[i],c->gcd_of_terms[i],c->S->m[j],c->gcd_of_terms[j],c)){ 1151 c->states[i][j]=HASTREP; 1152 c->extended_product_crit++; 1153 //PrintS("E"); 1154 } 1146 1155 if (c->states[i][j]==UNCALCULATED){ 1147 1156 // sort_pair_in(i,j,c); 1157 1148 1158 poly short_s=ksCreateShortSpoly(c->S->m[i],c->S->m[j],c->r); 1149 1159 if (short_s) … … 1348 1358 { 1349 1359 PrintS("e"); 1350 1360 int dummy_len; 1351 1361 kBucketClear(P.bucket,&sec_copy,&dummy_len); 1352 1362 kBucketInit(P.bucket,pCopy(sec_copy),dummy_len 1353 1363 /*pLength(sec_copy)*/); 1354 1364 must_expand=TRUE; 1355 1365 } … … 1384 1394 len_upper_bound=new_length +strat->lenS[j]-2;//old entries length 1385 1395 int new_pos; 1386 1387 1388 1389 1390 1391 1392 1396 if(c->is_char0) 1397 new_pos=simple_posInS(c->strat,sec_copy, 1398 pSLength(sec_copy,new_length), 1399 c->is_char0);//hac 1400 else 1401 new_pos=simple_posInS(c->strat,sec_copy,new_length,c->is_char0);//hack 1402 assume(new_pos<=j); 1393 1403 // p=NULL; 1394 1404 for (z=c->n;z;z--) … … 1430 1440 1431 1441 c->strat->lenS[old_pos]=new_length; 1432 1433 1442 if(c->strat->lenSw) 1443 c->strat->lenS[old_pos]=pSLength(sec_copy,new_length); 1434 1444 int i=0; 1435 1445 for(i=new_pos;i<old_pos;i++){ … … 1502 1512 } 1503 1513 1504 1514 static void line_of_extended_prod(int fixpos,calc_dat* c){ 1515 if (c->gcd_of_terms[fixpos]==NULL) 1516 { 1517 c->gcd_of_terms[fixpos]=gcd_of_terms(c->S->m[fixpos],c->r); 1518 if (c->gcd_of_terms[fixpos]) 1519 { 1520 int i; 1521 for(i=0;i<fixpos;i++) 1522 if((c->states[fixpos][i]!=HASTREP)&& (extended_product_criterion(c->S->m[fixpos],c->gcd_of_terms[fixpos], c->S->m[i],c->gcd_of_terms[i],c))) 1523 { 1524 c->states[fixpos][i]=HASTREP; 1525 c->extended_product_crit++; 1526 } 1527 for(i=fixpos+1;i<c->n;i++) 1528 if((c->states[i][fixpos]!=HASTREP)&& (extended_product_criterion(c->S->m[fixpos],c->gcd_of_terms[fixpos], c->S->m[i],c->gcd_of_terms[i],c))) 1529 { c->states[i][fixpos]=HASTREP; 1530 c->extended_product_crit++; 1531 } 1532 } 1533 } 1534 } 1535 static void c_S_element_changed_hook(int pos, calc_dat* c){ 1536 length_one_crit(c,pos, c->lengths[pos]); 1537 line_of_extended_prod(pos,c); 1538 } 1505 1539 1506 1540 static BOOLEAN redNF2_n_steps (redNF_inf* obj,calc_dat* c, int n) … … 1515 1549 int j; 1516 1550 kStrategy strat=c->strat; 1517 assume(strat->sl<50000); 1551 1518 1552 if (0 > strat->sl) 1519 1553 { … … 1545 1579 { 1546 1580 poly sec_copy=NULL; 1547 1581 if (c->is_char0) wlen_upper=kSBucketLength(obj->P->bucket); 1548 1582 BOOLEAN must_expand=FALSE; 1549 1583 BOOLEAN must_replace_in_basis; 1550 1551 1552 1553 1584 if(c->is_char0) 1585 must_replace_in_basis=(wlen_upper<strat->lenSw[j]);//first test 1586 else 1587 must_replace_in_basis=(obj->len_upper_bound<strat->lenS[j]);//first test 1554 1588 if (must_replace_in_basis) 1555 1589 { … … 1557 1591 if (pLmEqual(obj->P->p,strat->S[j])) 1558 1592 { 1559 1593 int dummy_len; 1560 1594 PrintS("b"); 1561 1595 kBucketClear(obj->P->bucket,&sec_copy,&dummy_len); 1562 1596 kBucketInit(obj->P->bucket,pCopy(sec_copy),dummy_len 1563 1597 /*pLength(sec_copy)*/); 1564 1598 } 1565 1599 else … … 1569 1603 ||(obj->len_upper_bound==2) 1570 1604 ||(obj->len_upper_bound<strat->lenS[j]/2) 1571 1572 1605 || 1606 (c->is_char0 && (wlen_upper<strat->lenSw[j]/100)) 1573 1607 ) 1574 1608 { 1575 1609 int dummy_len; 1576 1610 PrintS("e"); 1577 1611 kBucketClear(obj->P->bucket,&sec_copy,&dummy_len); 1578 1612 kBucketInit(obj->P->bucket,pCopy(sec_copy),dummy_len 1579 1613 /*pLength(sec_copy)*/); 1580 1614 must_expand=TRUE; 1581 1615 } … … 1593 1627 } 1594 1628 #endif 1629 if ((!must_replace_in_basis) && (pLmEqual(obj->P->p,c->strat->S[j]))){ 1630 obj->need_std_rep=TRUE; 1631 int is; 1632 for(is=0;is<c->n;is++) 1633 if(c->S->m[is]==c->strat->S[j]) 1634 break; 1635 if (is!=c->n){ 1636 if (c->gcd_of_terms[is]==NULL) { 1637 poly m=kBucketGcd(obj->P->bucket,c->r); 1638 if (m!=NULL){ 1639 pDelete(&m); 1640 kBucketCanonicalize(obj->P->bucket); 1641 m=kBucketGcd(obj->P->bucket,c->r); 1642 c->gcd_of_terms[is]=m; 1643 line_of_extended_prod(is,c); 1644 PrintS("C"); 1645 } 1646 1647 } 1648 } 1649 } 1650 1595 1651 obj->len_upper_bound=obj->len_upper_bound+strat->lenS[j]-2; 1596 1652 number coef=kBucketPolyRed(obj->P->bucket,strat->S[j], … … 1599 1655 nDelete(&coef); 1600 1656 h = kBucketGetLm(obj->P->bucket); 1601 1657 1658 1602 1659 if (must_replace_in_basis){ 1603 1660 obj->need_std_rep=TRUE; … … 1610 1667 obj->len_upper_bound=new_length +strat->lenS[j]-2;//old entries length 1611 1668 1612 1613 1614 1615 1616 1617 1618 1669 int new_pos; 1670 if(c->is_char0) 1671 new_pos=simple_posInS(c->strat,sec_copy, 1672 pSLength(sec_copy,new_length), 1673 c->is_char0);//hac 1674 else 1675 new_pos=simple_posInS(c->strat,sec_copy,new_length,c->is_char0);//hack 1619 1676 // p=NULL; 1620 1677 assume(new_pos<=j); 1621 1678 for (z=c->n;z;z--) 1622 1679 { … … 1632 1689 deleteInS(j,c->strat); 1633 1690 add_to_reductors(c,sec_copy,pLength(sec_copy)); 1634 1691 pDelete(&p); 1635 1692 } 1636 1693 else { … … 1647 1704 assume(new_pos<=old_pos); 1648 1705 c->strat->lenS[old_pos]=new_length; 1649 1650 1706 if(c->strat->lenSw) 1707 c->strat->lenS[old_pos]=pSLength(sec_copy,new_length); 1651 1708 int i=0; 1652 1709 for(i=new_pos;i<old_pos;i++){ … … 1656 1713 break; 1657 1714 } 1658 1715 assume(new_pos<=old_pos); 1659 1716 if (new_pos<old_pos) 1660 1717 move_forward_in_S(old_pos,new_pos,c->strat,c->is_char0); 1661 1662 1718 assume(0<=pos_in_c); 1719 assume(c->n>pos_in_c); 1663 1720 c->S->m[pos_in_c]=sec_copy; 1664 1721 1665 1722 c->lengths[pos_in_c]=new_length; 1666 length_one_crit(c,pos_in_c, new_length); 1723 c_S_element_changed_hook(pos_in_c,c); 1724 1667 1725 1668 1726 } … … 2007 2065 { 2008 2066 c->misses_series=0; 2009 2010 2067 if(c->is_char0) 2068 pContent(hr); 2011 2069 #ifdef HEAD_BIN 2012 2070 hr=p_MoveHead(hr,c->HeadBin); 2013 2071 #endif 2014 2072 2015 2073 add_to_basis(hr, c->work_on[i].i,c->work_on[i].j,c); 2016 2074 … … 2117 2175 omfree(c->lengths); 2118 2176 printf("calculated %d NFs\n",c->normal_forms); 2177 printf("applied %i product crit, %i extended_product crit \n", c->easy_product_crit, c->extended_product_crit); 2119 2178 I=c->S; 2120 2179 IDELEMS(I)=c->n; … … 2220 2279 int new_pos; 2221 2280 if (c->is_char0) 2222 2223 else 2224 2281 simple_posInS(c->strat,c->S->m[i],pSLength(c->S->m[i],c->lengths[i]),c->is_char0); 2282 else 2283 simple_posInS(c->strat,c->S->m[i],c->lengths[i],c->is_char0); 2225 2284 int old_pos=-1; 2226 2285 //assume new_pos<old_pos … … 2247 2306 c->strat->lenS[old_pos]=c->lengths[i]; 2248 2307 if (c->strat->lenSw) 2249 2308 c->strat->lenSw[old_pos]=pSLength(c->S->m[i],c->lengths[i]); 2250 2309 2251 2310 if (new_pos<old_pos) … … 2363 2422 } 2364 2423 } 2424 poly gcd_of_terms(poly p, ring r){ 2425 int max_g_0=0; 2426 assume(p!=NULL); 2427 int i; 2428 poly m=pOne(); 2429 poly t; 2430 for (i=pVariables; i; i--) 2431 { 2432 pSetExp(m,i, pGetExp(p,i)); 2433 if (max_g_0==0) 2434 if (pGetExp(m,i)>0) 2435 max_g_0=i; 2436 } 2437 2438 t=p->next; 2439 while (t!=NULL){ 2440 2441 if (max_g_0==0) break; 2442 for (i=pVariables; i; i--) 2443 { 2444 pSetExp(m,i, min(pGetExp(t,i),pGetExp(m,i))); 2445 if (max_g_0==i) 2446 if (pGetExp(m,i)==0) 2447 max_g_0=0; 2448 if ((max_g_0==0) && (pGetExp(m,i)>0)){ 2449 max_g_0=i; 2450 } 2451 } 2452 t=t->next; 2453 } 2454 for (i=pVariables;i;i--) 2455 { 2456 if(pGetExp(m,i)>0) 2457 return m; 2458 } 2459 pDelete(&m); 2460 return NULL; 2461 } 2462 BOOLEAN pHasNotCFExtended(poly p1, poly p2, poly m) 2463 { 2464 2465 if (pGetComp(p1) > 0 || pGetComp(p2) > 0) 2466 return FALSE; 2467 int i = 1; 2468 loop 2469 { 2470 if ((pGetExp(p1, i)-pGetExp(m,i) >0) && (pGetExp(p2, i) -pGetExp(m,i)> 0)) return FALSE; 2471 if (i == pVariables) return TRUE; 2472 i++; 2473 } 2474 } 2475 2476 2477 //for impl reasons may return false if the the normal product criterion matches 2478 BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, calc_dat* c){ 2479 if(gcd1==NULL) return FALSE; 2480 if(gcd2==NULL) return FALSE; 2481 gcd1->next=gcd2; //may ordered incorrect 2482 poly m=gcd_of_terms(gcd1,c->r); 2483 gcd1->next=NULL; 2484 if (m==NULL) return FALSE; 2485 2486 BOOLEAN erg=pHasNotCFExtended(p1,p2,m); 2487 pDelete(&m); 2488 return erg; 2489 } 2490 static poly kBucketGcd(kBucket* b, ring r) 2491 { 2492 int s=0; 2493 int i; 2494 poly m, n; 2495 BOOLEAN initialized=FALSE; 2496 for (i=MAX_BUCKET-1;i>=0;i--) 2497 { 2498 if (b->buckets[i]!=NULL){ 2499 if (!initialized){ 2500 m=gcd_of_terms(b->buckets[i],r); 2501 initialized=TRUE; 2502 if (m==NULL) return NULL; 2503 } 2504 else 2505 { 2506 n=gcd_of_terms(b->buckets[i],r); 2507 if (n==NULL) { 2508 pDelete(&m); 2509 return NULL; 2510 } 2511 n->next=m; 2512 poly t=gcd_of_terms(n,r); 2513 n->next=NULL; 2514 pDelete(&m); 2515 pDelete(&n); 2516 m=t; 2517 if (m==NULL) return NULL; 2518 2519 } 2520 } 2521 } 2522 return m; 2523 } -
Singular/tgb.h
rd713d7 rf3b78d 76 76 int* T_deg; 77 77 int* misses; 78 poly* gcd_of_terms; 78 79 int_pair_node* soon_free; 79 80 sorted_pair_node* pairs; … … 100 101 int max_pairs; 101 102 int pair_top; 103 int easy_product_crit; 104 int extended_product_crit; 102 105 BOOLEAN is_char0; 103 106 }; … … 128 131 static int pair_better_gen(const void* ap,const void* bp); 129 132 static poly redTailShort(poly h, kStrategy strat); 133 poly gcd_of_terms(poly p, ring r); 134 BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, calc_dat* c); 135 static poly kBucketGcd(kBucket* b, ring r); 130 136 #endif
Note: See TracChangeset
for help on using the changeset viewer.