- Timestamp:
- Dec 2, 2016, 6:49:32 PM (7 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- 665dab88a13186ce5e6abca704e42280baad6b91
- Parents:
- 174bcf3262ce524919d5ef06586fee3331f4cd94
- Location:
- kernel/combinatorics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/combinatorics/hilb.cc
r174bcf r5d623c 37 37 #include <coeffs/numbers.h> 38 38 #include <vector> 39 #include <Singular/ipshell.h> 39 40 40 41 #endif … … 1685 1686 if(p_LmDivisibleBy(I->m[i], I->m[k], currRing)) 1686 1687 { 1687 pDelete(&(I->m[k])); //this is not req.1688 pDelete(&(I->m[k])); 1688 1689 break; 1689 1690 } … … 1856 1857 } 1857 1858 1858 1859 void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE ) 1859 void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE, bool mgrad, bool odp) 1860 1860 { 1861 1861 /* … … 1875 1875 if(IG_CASE) 1876 1876 { 1877 if(idIs0(S)) 1878 { 1879 WerrorS("wrong input:not the infinitely gen. case"); 1880 return; 1881 } 1877 1882 trInd = p_Totaldegree(S->m[IDELEMS(S)-1], currRing); 1878 1883 POS = &positionInOrbit_IG_Case; … … 1891 1896 polist.push_back( p_One(currRing)); 1892 1897 1893 std::vector< std::vector<int> > mat; 1894 std::vector<int> row; 1895 row.push_back(0); 1896 1898 std::vector< std::vector<int> > posMat; 1899 std::vector<int> posRow(lV,0); 1897 1900 std::vector<int> C; 1898 1901 1899 int ds, is, ps , sz;1902 int ds, is, ps; 1900 1903 int lpcnt = 0; 1901 1904 … … 1943 1946 Jwi = colonIdeal(S, wi, lV, Jwi); 1944 1947 ps = (*POS)(Jwi, wi, idorb, polist, trInd); 1945 1946 if(ps == 0) // f ound new colonideal1948 1949 if(ps == 0) // finds a new ideal 1947 1950 { 1951 posRow[is-1] = idorb.size(); 1948 1952 1949 1953 idorb.push_back(Jwi); 1950 1954 polist.push_back(wi); 1951 row.push_back(1);1952 1955 } 1953 else // there is a same idealin the orbit1956 else // ideal is already there in the orbit 1954 1957 { 1955 row[ps-1] = row[ps-1] + 1;1958 posRow[is-1]=ps-1; 1956 1959 idDelete(&Jwi); 1957 1960 pDelete(&wi); 1958 1961 } 1959 1962 } 1960 mat.push_back(row); 1961 sz = row.size(); 1962 row.clear(); 1963 row.resize(sz, 0); 1963 posMat.push_back(posRow); 1964 posRow.resize(lV,0); 1965 } 1966 int lO = C.size();//size of the orbit 1967 PrintLn(); 1968 Print("Maximal length of words = %ld\n", p_Totaldegree(polist[lO-1], currRing)); 1969 Print("\nOrbit length = %d\n", lO); 1970 PrintLn(); 1971 1972 if(odp) 1973 { 1974 Print("Words description of the Orbit: \n"); 1975 for(is = 0; is < lO; is++) 1976 { 1977 pWrite0(polist[is]); 1978 PrintS(" "); 1979 } 1980 PrintLn(); 1964 1981 } 1965 1982 … … 1975 1992 idorb.resize(0); 1976 1993 polist.resize(0); 1977 1978 row.resize(0);1979 1994 1995 int adjMatrix[lO][lO]; 1996 memset(adjMatrix, 0, lO*lO*sizeof(int)); 1980 1997 int rowCount, colCount; 1981 #if 0 1982 for(rowCount = 0; rowCount < mat.size(); rowCount++) 1983 { 1984 for(colCount = 0; colCount < mat[rowCount].size(); colCount++) 1985 { 1986 Print("%d,",mat[rowCount][colCount]); 1987 } 1988 PrintLn(); 1989 } 1990 printf("rhs column matrix::\n"); 1991 for(colCount = 0; colCount < C.size(); colCount++) 1992 printf("%d,",C[colCount]); 1993 //printf("\nlength of the Orbit==%ld\n", C.size()); 1994 #endif 1998 int tm = 0; 1999 if(!mgrad) 2000 { 2001 for(rowCount = 0; rowCount < lO; rowCount++) 2002 { 2003 for(colCount = 0; colCount < lV; colCount++) 2004 { 2005 tm = posMat[rowCount][colCount]; 2006 adjMatrix[rowCount][tm] = adjMatrix[rowCount][tm] + 1; 2007 } 2008 } 2009 } 2010 1995 2011 ring r = currRing; 1996 char** tt=(char**)omalloc(sizeof(char*));1997 tt[0] = omStrDup("t");2012 int npar; 2013 char** tt; 1998 2014 TransExtInfo p; 1999 p.r = rDefault(0, 1, tt); 2000 coeffs cf = nInitChar(n_transExt,&p); 2001 2015 if(!mgrad) 2016 { 2017 tt=(char**)omalloc(sizeof(char*)); 2018 tt[0] = omStrDup("t"); 2019 npar = 1; 2020 } 2021 else 2022 { 2023 tt=(char**)omalloc(lV*sizeof(char*)); 2024 for(is = 0; is < lV; is++) 2025 { 2026 tt[is] = (char*)omalloc(7*sizeof(char)); //if required enlarge it later 2027 sprintf (tt[is], "t(%d)", is+1); 2028 } 2029 npar = lV; 2030 } 2031 2032 p.r = rDefault(0, npar, tt); 2033 coeffs cf = nInitChar(n_transExt, &p); 2002 2034 char** xx = (char**)omalloc(sizeof(char*)); 2003 2035 xx[0] = omStrDup("x"); 2004 2036 ring R = rDefault(cf, 1, xx); 2005 rChangeCurrRing(R); 2037 rChangeCurrRing(R);//rWrite(R); 2006 2038 /* 2007 2039 * matrix corresponding to the orbit of the ideal 2008 2040 */ 2009 int lO = C.size();//size of the orbit2010 2041 matrix mR = mpNew(lO, lO); 2011 2042 matrix cMat = mpNew(lO,1); 2043 poly rc; 2044 2045 if(!mgrad) 2046 { 2047 for(rowCount = 0; rowCount < lO; rowCount++) 2048 { 2049 for(colCount = 0; colCount < lO; colCount++) 2050 { 2051 if(adjMatrix[rowCount][colCount] != 0) 2052 { 2053 MATELEM(mR, rowCount + 1, colCount + 1) = p_ISet(adjMatrix[rowCount][colCount], R); 2054 p_SetCoeff(MATELEM(mR, rowCount + 1, colCount + 1), n_Mult(pGetCoeff(mR->m[lO*rowCount+colCount]),n_Param(1, R->cf), R->cf), R); 2055 } 2056 } 2057 } 2058 } 2059 else 2060 { 2061 for(rowCount = 0; rowCount < lO; rowCount++) 2062 { 2063 for(colCount = 0; colCount < lV; colCount++) 2064 { 2065 rc=NULL; 2066 rc=p_One(R); 2067 p_SetCoeff(rc, n_Mult(pGetCoeff(rc), n_Param(colCount+1, R->cf),R->cf), R); 2068 MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1)=p_Add_q(rc,MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1), R); 2069 } 2070 } 2071 } 2012 2072 2013 2073 for(rowCount = 0; rowCount < lO; rowCount++) 2014 2074 { 2015 for(colCount = 0; colCount < mat[rowCount].size(); colCount++) 2016 { 2017 if(mat[rowCount][colCount] != 0) 2075 if(C[rowCount] != 0) 2076 { 2077 MATELEM(cMat, rowCount + 1, 1) = p_ISet(C[rowCount], R); 2078 } 2079 } 2080 2081 matrix u; 2082 unitMatrix(lO, u); //unit matrix 2083 matrix gMat = mp_Sub(u, mR, R); 2084 char* s; 2085 if(odp) 2086 { 2087 PrintS("\nlinear system:\n"); 2088 if(!mgrad) 2089 { 2090 for(rowCount = 0; rowCount < lO; rowCount++) 2018 2091 { 2019 MATELEM(mR, rowCount + 1, colCount + 1) = p_ISet(mat[rowCount][colCount], R); 2020 p_SetCoeff(MATELEM(mR, rowCount + 1, colCount + 1), n_Mult(pGetCoeff(mR->m[lO*rowCount+colCount]),n_Param(1, R->cf), R->cf), R); 2092 Print("H(%d) = ", rowCount+1); 2093 for(colCount = 0; colCount < lV; colCount++) 2094 { 2095 StringSetS(""); nWrite(n_Param(1, R->cf)); 2096 s = StringEndS(); PrintS(s); 2097 Print("*"); omFree(s); 2098 Print("H(%d) + ", posMat[rowCount][colCount] + 1); 2099 } 2100 Print(" %d\n", C[rowCount] ); 2021 2101 } 2022 } 2023 if(C[rowCount] != 0) 2024 { 2025 cMat->m[rowCount] = p_ISet(C[rowCount], R); 2026 } 2027 mat[rowCount].resize(0); 2028 } 2029 mat.resize(0); 2102 PrintS("where H(1) represents the series corresp. to input ideal\n"); 2103 PrintS("and i^th summand in the rhs of an eqn. is according\n"); 2104 PrintS("to the right colon map corresp. to the i^th variable\n"); 2105 } 2106 else 2107 { 2108 for(rowCount = 0; rowCount < lO; rowCount++) 2109 { 2110 Print("H(%d) = ", rowCount+1); 2111 for(colCount = 0; colCount < lV; colCount++) 2112 { 2113 StringSetS(""); nWrite(n_Param(colCount+1, R->cf)); 2114 s = StringEndS(); PrintS(s); 2115 Print("*");omFree(s); 2116 Print("H(%d) + ", posMat[rowCount][colCount] + 1); 2117 } 2118 Print(" %d\n", C[rowCount] ); 2119 } 2120 PrintS("where H(1) represents the series corresp. to input ideal\n"); 2121 } 2122 } 2123 posMat.resize(0); 2030 2124 C.resize(0); 2031 matrix u;2032 unitMatrix(lO,u); //unit matrix2033 matrix gMat=mp_Sub(u,mR,R);2034 2125 matrix pMat; 2035 2126 matrix lMat; … … 2040 2131 luSolveViaLUDecomp(pMat, lMat, uMat, cMat, H_serVec, Hnot); 2041 2132 2042 mp_Delete(&mR, R);2043 mp_Delete(&u, R);2044 mp_Delete(&pMat, R);2045 mp_Delete(&lMat, R);2046 mp_Delete(&uMat, R);2047 mp_Delete(&cMat, R);2048 mp_Delete(&gMat, R);2049 mp_Delete(&Hnot, R);2133 mp_Delete(&mR, R); 2134 mp_Delete(&u, R); 2135 mp_Delete(&pMat, R); 2136 mp_Delete(&lMat, R); 2137 mp_Delete(&uMat, R); 2138 mp_Delete(&cMat, R); 2139 mp_Delete(&gMat, R); 2140 mp_Delete(&Hnot, R); 2050 2141 //print the Hilbert series and Orbit length 2051 2142 PrintLn(); 2143 Print("Hilbert series:"); 2144 PrintLn(); 2052 2145 pWrite(H_serVec->m[0]); 2053 Print("\nOrbit size = %d\n", lO); 2054 2055 omFree(tt[0]); 2146 PrintLn(); 2147 if(!mgrad) 2148 { 2149 omFree(tt[0]); 2150 } 2151 else 2152 { 2153 for(is = lV-1; is >= 0; is--) 2154 2155 omFree( tt[is]); 2156 } 2056 2157 omFree(tt); 2057 2158 omFree(xx[0]); 2058 2159 omFree(xx); 2059 2160 rChangeCurrRing(r); 2060 rDelete(R); 2061 } 2062 2063 2161 rKill(R); 2162 } -
kernel/combinatorics/hutil.h
r174bcf r5d623c 84 84 scfmon hInit(ideal S, ideal Q, int * Nexist, ring tailRing); 85 85 void slicehilb(ideal I); 86 void HilbertSeries_OrbitData(ideal S, int lV, bool ig );86 void HilbertSeries_OrbitData(ideal S, int lV, bool ig, bool mgrad, bool odp); 87 87 #endif
Note: See TracChangeset
for help on using the changeset viewer.