Changeset 14e93b in git
- Timestamp:
- Jun 14, 2012, 10:18:24 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- ff7993e279b46dbac09bfb1762c976061c50eb24
- Parents:
- 2c16b81352589f222e0e327ed8ce64db62736728
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-06-14 22:18:24+02:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:45+02:00
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/schreyer.lib
r2c16b8 r14e93b 1578 1578 } 1579 1579 1580 def a; bigint c; int r, k; poly aa; 1581 1582 int @LEAD2SYZ = 0; 1583 if( typeof( attrib(basering, "LEAD2SYZ") ) == "int" ) 1584 { 1585 @LEAD2SYZ = attrib(basering, "LEAD2SYZ"); 1586 } 1587 1588 int @TAILREDSYZ = 1; 1589 if( typeof( attrib(basering, "TAILREDSYZ") ) == "int" ) 1590 { 1591 @TAILREDSYZ = attrib(basering, "TAILREDSYZ"); 1592 } 1593 1594 int @HYBRIDNF = 0; 1595 if( typeof( attrib(basering, "HYBRIDNF") ) == "int" ) 1596 { 1597 @HYBRIDNF = attrib(basering, "HYBRIDNF"); 1598 } 1599 1600 module LL; 1601 def a2; int r2; poly aa2; 1602 1603 /// Get the critical leading syzygy terms 1604 if( @LEAD2SYZ ) // & 2nd syz. term 1605 { 1606 module LL2; 1607 (LL, LL2) = SSCompute2LeadingSyzygyTerms(L); // ++ 1608 } else 1609 { 1610 LL = SSComputeLeadingSyzygyTerms(L); 1611 } 1612 1613 module TT, SYZ; def spoly; 1614 1615 if( size(LL) > 0 ) 1616 { 1617 list LS; 1618 1619 if( @TAILREDSYZ) 1620 { 1621 LS = list(LL); 1622 } 1623 1624 vector @tail; 1625 1626 for(k = ncols(LL); k > 0; k-- ) 1627 { 1628 // leading syz. term: 1629 a = LL[k]; c = leadcomp(a); r = int(c); aa = leadmonomial(a); 1630 // "A: ", a, " --->>>> ", aa, " **** [", r, "]: "; 1631 1632 // NF reduction: 1633 if( !@HYBRIDNF ) 1580 list @res = ComputeSyzygy(L, T); 1581 1582 module @LL = @res[1]; module @TT = @res[2]; 1583 1584 if( @KERCHECK ) 1585 { 1586 if( typeof( attrib(basering, "SYZCHECK") ) == "int" ) 1587 { 1588 int @SYZCHECK = attrib(basering, "SYZCHECK"); 1589 } else 1590 { 1591 int @SYZCHECK = @DEBUG; 1592 } 1593 1594 int @LEAD2SYZ = 1; 1595 if( typeof( attrib(basering, "LEAD2SYZ") ) == "int" ) 1596 { 1597 @LEAD2SYZ = attrib(basering, "LEAD2SYZ"); 1598 } 1599 1600 int @TAILREDSYZ = 1; 1601 if( typeof( attrib(basering, "TAILREDSYZ") ) == "int" ) 1602 { 1603 @TAILREDSYZ = attrib(basering, "TAILREDSYZ"); 1604 } 1605 1606 int @HYBRIDNF = 0; 1607 if( typeof( attrib(basering, "HYBRIDNF") ) == "int" ) 1608 { 1609 @HYBRIDNF = attrib(basering, "HYBRIDNF"); 1610 } 1611 1612 module LL; 1613 1614 /// Get the critical leading syzygy terms 1615 if( @LEAD2SYZ ) // & 2nd syz. term 1616 { 1617 module LL2; 1618 (LL, LL2) = SSCompute2LeadingSyzygyTerms(L); 1619 } else 1620 { 1621 LL = SSComputeLeadingSyzygyTerms(L); 1622 } 1623 1624 module TT, SYZ; 1625 1626 vector a, a2; bigint c; int r; poly aa; 1627 1628 if( size(LL) > 0 ) 1629 { 1630 list LS; 1631 1632 if( @TAILREDSYZ) 1634 1633 { 1635 /// TODO: save shortcut (aa) * T[r] -> ? 1636 @tail = SSTraverseTail(aa, T[r], L, T, LS); 1637 // // @tail = SSTraverseTail(a, L, T, LS); 1638 1639 // get the 2nd syzygy term... 1640 1641 if( @LEAD2SYZ ) // with the 2nd syz. term: 1642 { 1643 a2 = LL2[k]; c = leadcomp(a2); r2 = int(c); aa2 = leadmonomial(a2); 1644 1645 @tail = @tail + a2 + 1646 /// TODO: save shortcut (aa2) * T[r2] -> ? 1647 SSTraverseTail(aa2, T[r2], L, T, LS); 1648 // // SSTraverseTail(a2, L, T, LS); 1649 } else 1634 LS = list(LL); 1635 } 1636 1637 vector @tail; 1638 1639 for(int k = ncols(LL); k > 0; k-- ) 1640 { 1641 // leading syz. term: 1642 a = LL[k]; c = leadcomp(a); r = int(c); aa = leadmonomial(a); 1643 1644 // NF reduction: 1645 if( !@HYBRIDNF ) // Traverse approach: 1646 { 1647 @tail = SSTraverseTail(aa, T[r], L, T, LS); 1648 1649 // get the 2nd syzygy term... 1650 if( @LEAD2SYZ ) // with the 2nd syz. term: 1651 { 1652 a2 = LL2[k]; c = leadcomp(a2); r = int(c); aa = leadmonomial(a2); 1653 1654 @tail = a2 + @tail + SSTraverseTail(aa, T[r], L, T, LS); 1655 } else 1656 { 1657 @tail = @tail + SSReduceTerm(aa, L[r], a, L, T, LS); 1658 } 1659 1660 } else // Hybrid approach: 1650 1661 { 1651 @tail = @tail + 1652 SSReduceTerm(aa, L[r], a, L, T, LS); 1653 // // SSReduceTerm(a, L, T, LS); 1662 1663 // get the 2nd syzygy term... 1664 if( @LEAD2SYZ ) 1665 { 1666 a2 = LL2[k]; 1667 } else 1668 { 1669 a2 = SSFindReducer( aa * L[r], a, L, LS); 1670 } 1671 1672 if ( (@SYZCHECK || @DEBUG) ) 1673 { 1674 if( size(a2) == 0 ) // if syzterm == 0!!!! 1675 { 1676 "ERROR in SSComputeSyzygy: could not find the 2nd syzygy term during the hybrid NF!!!"; 1677 $ 1678 } 1679 } 1680 1681 @tail = SSSchreyerSyzygyNF(a, a2, L, T, LS); 1654 1682 } 1655 } else 1656 { 1657 if( @LEAD2SYZ ) 1658 { 1659 a2 = LL2[k]; 1660 } else 1661 { 1662 a2 = SSFindReducer( aa * L[r], a, L, LS); 1663 } 1664 1665 if ( (@SYZCHECK || @DEBUG) ) 1666 { 1667 if( size(a2) == 0 ) // if syzterm == 0!!!! 1668 { 1669 "ERROR: could not find the 2nd syzygy term during the hybrid NF!!!"; 1670 $ 1671 } 1672 } 1673 1674 @tail = SSSchreyerSyzygyNF(a, a2, L, T, LS); 1683 1684 TT[k] = @tail; 1685 SYZ[k] = a + @tail; 1675 1686 } 1676 1677 TT[k] = @tail; 1678 SYZ[k] = a + @tail; 1679 } 1680 } 1681 1687 } 1688 1689 if( ncols(LL) != ncols(@LL) ) 1690 { 1691 "ERROR in SSComputeSyzygy: wrong leading syzygies!?"; 1692 ""; 1693 L; T; 1694 ""; 1695 type(LL); 1696 type(@LL); 1697 $ 1698 } 1699 1700 if( ncols(TT) != ncols(@TT) ) 1701 { 1702 "ERROR in SSComputeSyzygy: wrong tail syzygies!?"; 1703 ""; 1704 L; T; 1705 ""; 1706 type(LL); 1707 type(@LL); 1708 ""; 1709 type(TT); 1710 type(@TT); 1711 $ 1712 } 1713 1714 if( size( module( matrix(LL) - matrix(@LL) ) ) != 0 ) 1715 { 1716 "ERROR in SSComputeSyzygy: wrong leading syzygies!?"; 1717 ""; 1718 L; T; 1719 ""; 1720 type(LL); 1721 type(@LL); 1722 $ 1723 } 1724 1725 1726 if( size( module( matrix(TT) - matrix(@TT) ) ) != 0 ) 1727 { 1728 "ERROR in SSComputeSyzygy: wrong tail syzygies!?"; 1729 TT; @TT; 1730 L; T; 1731 $ 1732 } 1733 1734 } 1735 1736 module @SYZ; 1737 1738 for(int @k = ncols(@LL); @k > 0; @k-- ) 1739 { 1740 @SYZ[@k] = @LL[@k] + @TT[@k]; 1741 } 1742 1682 1743 if( @DEBUG ) 1683 1744 { 1684 1745 "SSComputeSyzygy::Output"; 1685 1746 1686 "SYZ: ";SYZ;1687 "LL: "; LL;1688 "TT: "; TT;1689 } 1690 1691 return ( SYZ, LL,TT);1747 // "SYZ: "; @SYZ; 1748 "LL: "; @LL; 1749 "TT: "; @TT; 1750 } 1751 1752 return (@SYZ, @LL, @TT); 1692 1753 } 1693 1754 … … 2050 2111 2051 2112 exportto(Schreyer, Syzextra::SchreyerSyzygyNF); 2113 exportto(Schreyer, Syzextra::ComputeSyzygy); 2052 2114 } 2053 2115 /* … … 2101 2163 2102 2164 exportto(Schreyer, Syzextra_g::SchreyerSyzygyNF); 2165 exportto(Schreyer, Syzextra_g::ComputeSyzygy); 2103 2166 } 2104 2167 */ -
dyn_modules/syzextra/mod_main.cc
r2c16b8 r14e93b 1771 1771 return FALSE; 1772 1772 } 1773 1774 1775 1776 static void ComputeSyzygy(const ideal L, const ideal T, ideal& LL, ideal& TT, const ring R) 1777 { 1778 assume( R == currRing ); // For attributes :-/ 1779 1780 assume( IDELEMS(L) == IDELEMS(T) ); 1781 1782 #ifndef NDEBUG 1783 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE))); 1784 #else 1785 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE))); 1786 #endif 1787 1788 const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)1))); 1789 const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)1))); 1790 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)__DEBUG__))); 1791 1792 const BOOLEAN __HYBRIDNF__ = (BOOLEAN)((long)(atGet(currRingHdl,"HYBRIDNF",INT_CMD, (void*)0))); 1793 1794 1795 if( __LEAD2SYZ__ ) 1796 LL = Compute2LeadingSyzygyTerms(L, R); // 2 terms! 1797 else 1798 LL = ComputeLeadingSyzygyTerms(L, R); // 1 term! 1799 1800 const int size = IDELEMS(LL); 1801 1802 TT = idInit(size, 0); 1803 1804 if( size == 1 && LL->m[0] == NULL ) 1805 return; 1806 1807 1808 ideal LS = NULL; 1809 1810 if( __TAILREDSYZ__ ) 1811 LS = LL; 1812 1813 for( int k = size - 1; k >= 0; k-- ) 1814 { 1815 const poly a = LL->m[k]; assume( a != NULL ); 1816 1817 const int r = p_GetComp(a, R) - 1; 1818 1819 assume( r >= 0 && r < IDELEMS(T) ); 1820 assume( r >= 0 && r < IDELEMS(L) ); 1821 1822 poly aa = leadmonom(a, R); assume( aa != NULL); // :( 1823 1824 poly a2 = pNext(a); 1825 1826 if( a2 != NULL ) 1827 { 1828 TT->m[k] = a2; pNext(a) = NULL; 1829 } 1830 1831 if( ! __HYBRIDNF__ ) 1832 { 1833 poly t = TraverseTail(aa, T->m[r], L, T, LS, R); 1834 1835 if( a2 != NULL ) 1836 { 1837 assume( __LEAD2SYZ__ ); 1838 1839 const int r2 = p_GetComp(a2, R) - 1; poly aa2 = leadmonom(a2, R); // :( 1840 1841 assume( r2 >= 0 && r2 < IDELEMS(T) ); 1842 1843 TT->m[k] = p_Add_q(a2, p_Add_q(t, TraverseTail(aa2, T->m[r2], L, T, LS, R), R), R); 1844 1845 p_Delete(&aa2, R); 1846 } else 1847 TT->m[k] = p_Add_q(t, ReduceTerm(aa, L->m[r], a, L, T, LS, R), R); 1848 1849 } else 1850 { 1851 if( a2 == NULL ) 1852 { 1853 aa = p_Mult_mm(aa, L->m[r], R); 1854 a2 = FindReducer(aa, a, L, LS, R); 1855 } 1856 assume( a2 != NULL ); 1857 1858 TT->m[k] = SchreyerSyzygyNF(a, a2, L, T, LS, R); // will copy a2 :( 1859 1860 p_Delete(&a2, R); 1861 } 1862 p_Delete(&aa, R); 1863 } 1864 1865 TT->rank = id_RankFreeModule(TT, R); 1866 } 1867 1868 1869 1870 // module (N, LL, TT) = SSComputeSyzygy(L, T); 1871 // Compute Syz(L ++ T) = N = LL ++ TT 1872 // proc SSComputeSyzygy(def L, def T) 1873 static BOOLEAN ComputeSyzygy(leftv res, leftv h) 1874 { 1875 const char* usage = "`ComputeSyzygy(<ideal/module>, <ideal/module>])` expected"; 1876 const ring r = currRing; 1877 1878 NoReturn(res); 1879 1880 #ifndef NDEBUG 1881 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE))); 1882 #else 1883 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE))); 1884 #endif 1885 1886 if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL)) 1887 { 1888 WerrorS(usage); 1889 return TRUE; 1890 } 1891 1892 const ideal L = (ideal) h->Data(); 1893 1894 assume( IDELEMS(L) > 0 ); 1895 1896 h = h->Next(); 1897 if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL)) 1898 { 1899 WerrorS(usage); 1900 return TRUE; 1901 } 1902 1903 const ideal T = (ideal) h->Data(); 1904 assume( IDELEMS(L) == IDELEMS(T) ); 1905 1906 1907 h = h->Next(); assume( h == NULL ); 1908 1909 if( __DEBUG__ ) 1910 { 1911 PrintS("ComputeSyzygy(L, T)::Input: \n"); 1912 1913 PrintS("L: "); dPrint(L, r, r, 0); 1914 PrintS("T: "); dPrint(T, r, r, 0); 1915 } 1916 1917 ideal LL, TT; 1918 1919 ComputeSyzygy(L, T, LL, TT, r); 1920 1921 lists l = (lists)omAllocBin(slists_bin); l->Init(2); 1922 1923 l->m[0].rtyp = MODUL_CMD; l->m[0].data = reinterpret_cast<void *>(LL); 1924 1925 l->m[1].rtyp = MODUL_CMD; l->m[1].data = reinterpret_cast<void *>(TT); 1926 1927 res->data = l; res->rtyp = LIST_CMD; 1928 1929 if( __DEBUG__ ) 1930 { 1931 PrintS("ComputeSyzygy::Output: "); 1932 dPrint(LL, r, r, 0); 1933 dPrint(TT, r, r, 0); 1934 } 1935 1936 return FALSE; 1937 1938 } 1939 1773 1940 1774 1941 … … 2419 2586 2420 2587 ADD(psModulFunctions, currPack->libname, "SchreyerSyzygyNF", FALSE, SchreyerSyzygyNF); 2588 ADD(psModulFunctions, currPack->libname, "ComputeSyzygy", FALSE, ComputeSyzygy); 2421 2589 2422 2590 // ADD(psModulFunctions, currPack->libname, "GetAMData", FALSE, GetAMData);
Note: See TracChangeset
for help on using the changeset viewer.