- Timestamp:
- Oct 5, 2016, 7:44:03 PM (8 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 7e48fd30f913149068233c11121d6395b3cf6fa6
- Parents:
- 637aa3957f20a1c1863a9ca0de302c346df62fd7
- git-author:
- Sharwan Tiwari <stiwari@gmail.com>2016-10-05 19:44:03+02:00
- git-committer:
- Sharwan Tiwari <stiwari@gmail.com>2016-10-11 17:40:28+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/combinatorics/hilb.cc
r637aa3 r340ab8 1401 1401 1402 1402 1403 static void idInsertMon Pos_nchilb(ideal I, poly p, int pos)1404 { 1403 static void idInsertMonomials(ideal I, poly p) 1404 { 1405 1405 /* 1406 * poly p != null, and there is no null poly in I 1407 * adds p at the position 'pos' in I 1408 * without making copy of it 1409 */ 1410 1411 pEnlargeSet(&(I->m), IDELEMS(I), IDELEMS(I)+1); 1412 IDELEMS(I) += 1; 1413 for(int i = IDELEMS(I) - 1; i > pos; i--) 1414 { 1415 I->m[i] = I->m[i-1]; 1416 } 1417 I->m[pos] = p; 1418 } 1419 1420 static void idInsertMonAtEnd_nchilb(ideal I, poly p) 1421 { 1422 /* 1423 * poly p !=null, and there is no null poly in I 1406 * adds monomial in I and if required, 1407 * enlarges the size of poly-set by 16 1408 * does not make copy of p 1424 1409 */ 1425 1410 1426 pEnlargeSet(&(I->m), IDELEMS(I), IDELEMS(I)+1); 1427 IDELEMS(I) += 1; 1428 I->m[IDELEMS(I)-1] = p; 1429 } 1430 1431 static void idInsertMonomials(ideal h1, poly h2) 1432 { 1433 /* 1434 * adds monomial in h1 and if required, 1435 * enlarges the size of poly-set by 16 1436 * does not make copy of h2 1437 */ 1438 1439 if(h2 == NULL) 1411 if(I == NULL) 1440 1412 { 1441 1413 return; 1442 1414 } 1443 1415 1444 int j = IDELEMS( h1) - 1;1445 while ((j >= 0) && ( h1->m[j] == NULL))1416 int j = IDELEMS(I) - 1; 1417 while ((j >= 0) && (I->m[j] == NULL)) 1446 1418 { 1447 1419 j--; 1448 1420 } 1449 1421 j++; 1450 if (j == IDELEMS( h1))1451 { 1452 pEnlargeSet(&( h1->m), IDELEMS(h1), 16);1453 IDELEMS( h1) +=16;1454 } 1455 h1->m[j] = h2;1422 if (j == IDELEMS(I)) 1423 { 1424 pEnlargeSet(&(I->m), IDELEMS(I), 16); 1425 IDELEMS(I) +=16; 1426 } 1427 I->m[j] = p; 1456 1428 } 1457 1429 … … 1470 1442 */ 1471 1443 1472 static ideal PlacePolyInSortedMonoIdeal_TotalDegOrder(ideal I, poly p)1473 {1474 /*1475 * order of the currRing should be a total degree1476 * poly p != null1477 * inserts poly p in the I, s.t.1478 * the polys of I are in ascending order1479 * does not make copy of p21480 */1481 int i;1482 if((I == NULL) || (idIs0(I)))1483 {1484 ideal res = idInit(1,1);1485 res->m[0] = p;1486 return(res);1487 }1488 idSkipZeroes(I);1489 1490 for(i = 0; (i<IDELEMS(I)) && (p_Totaldegree(I->m[i], currRing) <= p_Totaldegree(p, currRing)); i++)1491 {1492 if(p_DivisibleBy(I->m[i], p, currRing))1493 {1494 pDelete(&p);//this poly is not required anymore1495 return(I);1496 }1497 }1498 for(i = IDELEMS(I)-1; (i>=0) && (p_Totaldegree(I->m[i],currRing) >= p_Totaldegree(p,currRing)); i--)1499 {1500 if(p_DivisibleBy(p, I->m[i], currRing))1501 {1502 I->m[i] = NULL;1503 }1504 }1505 if(idIs0(I))1506 {1507 I->m[0] = p;1508 return(I);1509 }1510 1511 idSkipZeroes(I);1512 //when all polynomials of I have same degree1513 if(p_Totaldegree(I->m[0], currRing) == p_Totaldegree(I->m[IDELEMS(I)-1], currRing))1514 {1515 if(p_Totaldegree(p, currRing) < p_Totaldegree(I->m[0], currRing))1516 {1517 idInsertMonPos_nchilb(I, p, 0);1518 return(I);1519 }1520 if(p_Totaldegree(p, currRing) >= p_Totaldegree(I->m[IDELEMS(I)-1], currRing))1521 {1522 1523 for(i = IDELEMS(I)-1; i>=0; i--)1524 {1525 if(p_LmCmp(I->m[i], p, currRing) == 1)1526 {1527 if(i==0)1528 {1529 idInsertMonPos_nchilb(I, p, 0);1530 return(I);1531 }1532 }1533 else1534 {1535 if(i == (IDELEMS(I)-1))1536 {1537 idInsertMonAtEnd_nchilb(I, p);1538 return(I);1539 }1540 idInsertMonPos_nchilb(I, p, i+1);1541 return(I);1542 }1543 }1544 }1545 }1546 if(p_Totaldegree(p, currRing) <= p_Totaldegree(I->m[0], currRing))1547 {1548 1549 for(i = 0; i < IDELEMS(I); i++)1550 {1551 if(p_LmCmp(I->m[i], p, currRing) == 1)1552 {1553 idInsertMonPos_nchilb(I, p, i);1554 return(I);1555 }1556 }1557 idInsertMonAtEnd_nchilb(I, p);1558 return(I);1559 }1560 if(p_Totaldegree(p, currRing) >= p_Totaldegree(I->m[IDELEMS(I)-1], currRing))1561 {1562 for(i = IDELEMS(I)-1; i >= 0; i--)1563 {1564 if(p_LmCmp(I->m[i], p, currRing) != 1)1565 {1566 if(i == IDELEMS(I)-1)1567 {1568 idInsertMonAtEnd_nchilb(I, p);1569 return(I);1570 }1571 else1572 {1573 idInsertMonPos_nchilb(I, p, i+1);1574 return(I);1575 }1576 1577 }1578 }1579 1580 }1581 1582 for(i = IDELEMS(I)-2; ;)1583 {1584 if(p_Totaldegree(p, currRing) == p_Totaldegree(I->m[i], currRing))1585 {1586 for(int j = i; j >= 0; j--)1587 {1588 if(p_LmCmp(I->m[j], p, currRing) != 1)1589 {1590 idInsertMonPos_nchilb(I, p, j+1);1591 return(I);1592 }1593 }1594 }1595 if(p_Totaldegree(p, currRing) > p_Totaldegree(I->m[i], currRing))1596 {1597 idInsertMonPos_nchilb(I, p, i+1);1598 return(I);1599 }1600 i--;1601 }1602 }1603 1604 static ideal SortMonoId_TotalDegOrder(ideal I)1605 {1606 /*1607 * sorts the ideal in ascending order1608 * order must be a total degree1609 */1610 if(idIs0(I))1611 {1612 return(I);1613 }1614 int i;1615 ideal result;1616 idSkipZeroes(I);1617 result = idInit(1, 1);1618 for(i = 0; i <= IDELEMS(I)-1; i++)1619 {1620 result = PlacePolyInSortedMonoIdeal_TotalDegOrder(result, I->m[i]);1621 }1622 idSkipZeroes(result);1623 return(result);1624 }1625 1626 1444 static int isMonoIdBasesSame(ideal J, ideal Ob) 1627 1445 { … … 1632 1450 */ 1633 1451 int i, j, s, cnt; 1634 s =1;1452 s = 1; 1635 1453 int JCount = IDELEMS(J); 1636 1454 int ObCount = IDELEMS(Ob); … … 1669 1487 } 1670 1488 1671 int count =0;1489 int count = 0; 1672 1490 for(int i = 0; i < IDELEMS(I); i++) 1673 1491 { … … 1676 1494 return (count); 1677 1495 } 1678 count =count+1;1496 count = count + 1; 1679 1497 } 1680 1498 … … 1826 1644 } 1827 1645 1828 static ideal MinimalMonomialBasis(ideal I) 1646 static int monCompare(const void *m, const void *n) 1647 { 1648 /* compares monomials */ 1649 1650 return (p_Compare(*(poly*)m, *(poly*)n, currRing)); 1651 } 1652 1653 static void sortMonoIdeal_totalDegOrder(ideal I) 1654 { 1655 /* 1656 * sorts the monomial ideal in ascending order 1657 * order must be a total degree 1658 */ 1659 1660 qsort(I->m, IDELEMS(I), sizeof(poly), monCompare); 1661 1662 } 1663 1664 1665 1666 static ideal minimalMonomialsGenSet(ideal I) 1829 1667 { 1830 1668 /* … … 1832 1670 * can be generated by others in I 1833 1671 */ 1834 I = SortMonoId_TotalDegOrder(I); 1672 //first sort monomials of the ideal 1673 1674 idSkipZeroes(I); 1675 1676 sortMonoIdeal_totalDegOrder(I); 1677 1835 1678 ideal J = idInit(1, 1); 1836 1679 int i, k; 1837 1680 int count = 0; 1838 1681 int ICount = IDELEMS(I); 1839 1840 std::vector<BOOLEAN> checks(ICount, TRUE); 1841 for(k = 0; k < ICount; k++) 1842 { 1843 if(checks[k]) 1844 { 1845 idInsertMonomials(J, I->m[k]); 1846 count++; 1847 for(i = count; i < ICount; i++) 1848 { 1849 if(checks[i]) 1850 { 1851 if( pLmDivisibleByNoComp(J->m[count-1], I->m[i])) 1852 { 1853 checks[i]=FALSE; 1854 pDelete(&(I->m[i])); 1855 } 1856 } 1682 1683 for(k = ICount - 1; k >=1; k--) 1684 { 1685 for(i = 0; i < k; i++) 1686 { 1687 1688 if(p_LmDivisibleBy(I->m[i], I->m[k], currRing)) 1689 { 1690 pDelete(&(I->m[k]));//this is not req. 1691 break; 1857 1692 } 1858 1693 } 1859 1694 } 1860 idSkipZeroes(J); 1861 return(J); 1695 1696 idSkipZeroes(I); 1697 return(I); 1862 1698 } 1863 1699 … … 1884 1720 } 1885 1721 } 1886 p_SetExpV(smon, s, r); 1722 1723 p_SetExpV(smon, s, currRing); 1887 1724 omFree(e); 1888 1725 omFree(s); 1889 p_SetComp(smon, p_GetComp(p, r), r); 1726 1727 p_SetComp(smon, p_GetComp(p, currRing), currRing); 1728 p_Setm(smon, currRing); 1729 1890 1730 return(smon); 1891 1731 } … … 1914 1754 s[j] = e[j]; 1915 1755 } 1916 p_SetExpV(dw, s, r);//new exponents 1756 1757 p_SetExpV(dw, s, currRing);//new exponents 1917 1758 omFree(e); 1918 1759 omFree(s); 1919 p_SetComp(dw, p_GetComp(w, r), r); 1760 1761 p_SetComp(dw, p_GetComp(w, currRing), currRing); 1762 p_Setm(dw, currRing); 1763 1920 1764 return(dw); 1921 1765 } … … 1933 1777 */ 1934 1778 int i; 1935 //ring r=currRing;1936 1779 poly smon, dw; 1937 1780 poly qmonp = NULL; 1938 1781 bool del; 1782 1939 1783 for(i = 0;i <= d - 1; i++) 1940 1784 { … … 1942 1786 smon = shiftInMon(p, i, lV, currRing); 1943 1787 del = TRUE; 1944 if(pLmDivisibleByNoComp(smon, w)) 1788 1789 if(pLmDivisibleBy(smon, w)) 1945 1790 { 1946 1791 flag = TRUE; … … 1950 1795 pDelete(&smon); 1951 1796 1952 //make Jwi =1; 1797 //delete all monomials of Jwi 1798 //and make Jwi =1 1799 1953 1800 for(int j = 0;j < IDELEMS(Jwi); j++) 1954 1801 { 1955 1802 pDelete(&Jwi->m[j]); 1956 1803 } 1957 1958 pEnlargeSet(&(Jwi->m), IDELEMS(Jwi), -IDELEMS(Jwi)+1); 1959 IDELEMS(Jwi)=1; 1960 Jwi->m[0]=p_One(currRing); 1804 1805 idInsertMonomials(Jwi, p_One(currRing)); 1961 1806 break; 1962 1807 } 1963 1808 1964 if(pLmDivisibleBy NoComp(dw, smon))1809 if(pLmDivisibleBy(dw, smon)) 1965 1810 { 1966 1811 del = FALSE; 1967 1812 qmonp = p_Divide(smon, dw, currRing); 1968 1969 pEnlargeSet(&(Jwi->m), IDELEMS(Jwi), 1); 1970 IDELEMS(Jwi) += 1; 1971 Jwi->m[IDELEMS(Jwi)-1] = shiftInMon(qmonp, -d, lV, currRing); 1813 idInsertMonomials(Jwi, shiftInMon(qmonp, -d, lV, currRing)); 1972 1814 1973 pDelete(&qmonp);//shiftInMon(qmonp, -d, lV, currRing):returns a new poly, 1974 // qmonp remains unchanged 1815 //shiftInMon(qmonp, -d, lV, currRing):returns a new poly, 1816 //qmonp remains unchanged, delete it 1817 pDelete(&qmonp); 1975 1818 pDelete(&dw); 1976 1819 pDelete(&smon); 1977 1820 } 1978 //in case both if were false, delete dw and smon1821 //in case both if are false, delete dw and smon 1979 1822 if(del) 1980 1823 { … … 2012 1855 } 2013 1856 } 2014 Jwi = MinimalMonomialBasis(Jwi); 1857 1858 Jwi = minimalMonomialsGenSet(Jwi); 2015 1859 return(Jwi); 2016 1860 } 1861 2017 1862 2018 1863 void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE ) … … 2029 1874 2030 1875 int trInd; 2031 S = SortMonoId_TotalDegOrder(S); 2032 2033 1876 S = minimalMonomialsGenSet(S); 1877 2034 1878 int (*POS)(ideal, poly, std::vector<ideal>, std::vector<poly>, int); 2035 1879 if(IG_CASE) … … 2056 1900 2057 1901 std::vector<int> C; 2058 2059 ring r = currRing;2060 1902 2061 1903 int ds, is, ps, sz; … … 2094 1936 2095 1937 wi = pCopy(w); 2096 p_SetExp(wi, (ds*lV)+is, 1, r);2097 p_Setm(wi, r);1938 p_SetExp(wi, (ds*lV)+is, 1, currRing); 1939 p_Setm(wi, currRing); 2098 1940 2099 1941 Jwi = NULL; … … 2155 1997 //printf("\nlength of the Orbit==%ld\n", C.size()); 2156 1998 #endif 2157 1999 ring r = currRing; 2158 2000 char** tt=(char**)omalloc(sizeof(char*)); 2159 2001 tt[0] = omStrDup("t"); … … 2179 2021 if(mat[rowCount][colCount] != 0) 2180 2022 { 2181 mR->m[lO*rowCount + colCount]= p_ISet(mat[rowCount][colCount], R);2182 p_SetCoeff( mR->m[lO*rowCount+colCount], n_Mult(pGetCoeff(mR->m[lO*rowCount+colCount]),n_Param(1, R->cf), R->cf), R);2023 MATELEM(mR, rowCount + 1, colCount + 1) = p_ISet(mat[rowCount][colCount], R); 2024 p_SetCoeff(MATELEM(mR, rowCount + 1, colCount + 1), n_Mult(pGetCoeff(mR->m[lO*rowCount+colCount]),n_Param(1, R->cf), R->cf), R); 2183 2025 } 2184 2026 } … … 2219 2061 omFree(xx[0]); 2220 2062 omFree(xx); 2063 rKill(R); 2221 2064 rChangeCurrRing(r); 2222 2065 }
Note: See TracChangeset
for help on using the changeset viewer.