Changeset 86016d in git for kernel/sca.cc
- Timestamp:
- Feb 1, 2007, 12:51:25 AM (17 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- c591ad0eb4ed9f5be86c0c85d2412be2ad6be556
- Parents:
- 1cc61e18c0d6c70b177099c23a52159afb280bb4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/sca.cc
r1cc61e r86016d 7 7 * Author: motsak (Oleksandr Motsak) 8 8 * Created: 2006/12/18 9 * Version: $Id: sca.cc,v 1. 7 2007-01-25 16:36:50 SingularExp $9 * Version: $Id: sca.cc,v 1.8 2007-01-31 23:51:25 motsak Exp $ 10 10 *******************************************************************/ 11 11 … … 43 43 44 44 45 // scaFirstAltVar( r, 0 ); 46 // scaLastAltVar( r, 0 ); 45 // poly functions defined in p_Procs : 46 47 // return pPoly * pMonom; preserve pPoly and pMonom. 48 poly sca_pp_Mult_mm(const poly pPoly, const poly pMonom, const ring rRing, poly &); 49 50 // return pMonom * pPoly; preserve pPoly and pMonom. 51 poly sca_mm_Mult_pp(const poly pMonom, const poly pPoly, const ring rRing); 52 53 // return pPoly * pMonom; preserve pMonom, destroy or reuse pPoly. 54 poly sca_p_Mult_mm(poly pPoly, const poly pMonom, const ring rRing); 55 56 // return pMonom * pPoly; preserve pMonom, destroy or reuse pPoly. 57 poly sca_mm_Mult_p(const poly pMonom, poly pPoly, const ring rRing); 58 59 60 // compute the spolynomial of p1 and p2 61 poly sca_SPoly(const poly p1, const poly p2, const ring r); 62 poly sca_ReduceSpoly(const poly p1, poly p2, const ring r); 63 64 // Modified Plural's Buchberger's algorithmus. 65 ideal sca_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat); 66 67 // Modified modern Sinuglar Buchberger's algorithm. 68 ideal sca_bba(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat); 69 70 // Modified modern Sinuglar Mora's algorithm. 71 ideal sca_mora(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat); 47 72 48 73 … … 280 305 assume( scaFirstAltVar(rRing) <= i ); 281 306 282 if( p_GetExp(pMonom, i, rRing) ) //result is zero!307 if( p_GetExp(pMonom, i, rRing) != 0 ) // => result is zero! 283 308 return NULL; 284 309 … … 939 964 assume(rIsSCA(currRing)); 940 965 941 BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing); 966 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 967 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); 968 969 ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); 970 const ideal tempQ = currRing->nc->SCAQuotient(); 971 972 BOOLEAN bIdHomog = id_IsBiHomogeneous(tempF, m_iFirstAltVar, m_iLastAltVar, currRing); 973 974 assume( !bIdHomog || strat->homog ); // bIdHomog =====[implies]>>>>> strat->homog 942 975 943 976 strat->homog = strat->homog && bIdHomog; … … 952 985 { 953 986 Print("ideal F: \n"); 954 for (int i = 0; i < F->idelems(); i++)987 for (int i = 0; i < tempF->idelems(); i++) 955 988 { 956 989 Print("; F[%d] = ", i+1); 957 p_Write( F->m[i], currRing);990 p_Write(tempF->m[i], currRing); 958 991 } 959 992 Print(";\n"); … … 976 1009 initBuchMoraCrit(strat); // set Gebauer, honey, sugarCrit 977 1010 978 gr_initBba(F,strat); // set enterS, red, initEcart, initEcartPair1011 nc_gr_initBba(tempF,strat); // set enterS, red, initEcart, initEcartPair 979 1012 980 1013 initBuchMoraPos(strat); … … 983 1016 // ?? set spSpolyShort, reduce ??? 984 1017 985 initBuchMora( F, NULL, strat); // Q= squares!!!!!!!1018 initBuchMora(tempF, tempQ, strat); // currRing->nc->SCAQuotient() instead of Q == squares!!!!!!! 986 1019 987 1020 strat->posInT=posInT110; // !!! … … 989 1022 srmax = strat->sl; 990 1023 reduc = olddeg = lrmax = 0; 991 992 993 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);994 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);995 996 997 1024 998 1025 … … 1061 1088 if (strat->sl > srmax) srmax = strat->sl; 1062 1089 1063 ////////////// children !!!!!!!!!!!!!1064 1065 1090 const poly save = strat->P.p; 1066 1091 1067 // if( save != NULL )1068 {1069 1070 1092 #ifdef PDEBUG 1071 1093 p_Test(save, currRing); 1072 1094 #endif 1073 1095 assume( save != NULL ); 1096 1097 // SCA Specials: 1098 1099 { 1074 1100 const poly pNext = pNext(save); 1075 1101 1102 if( pNext != NULL ) 1076 1103 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) 1077 if( p GetExp(save, i)!=0 )1104 if( p_GetExp(save, i, currRing) != 0 ) 1078 1105 { 1106 assume(p_GetExp(save, i, currRing) == 1); 1107 1079 1108 const poly tt = sca_pp_Mult_xi_pp(i, pNext, currRing); 1080 1109 … … 1114 1143 // if(h.IsNull()) continue; 1115 1144 1116 1117 // poly save = p_Copy(h.p, currRing); 1145 // poly save = p_Copy(h.p, currRing); 1118 1146 1119 1147 int pos; … … 1158 1186 if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat); 1159 1187 1160 // if (Q!=NULL) updateResult(strat->Shdl,Q,strat); 1188 if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat); 1189 1190 id_Delete(&tempF, currRing); 1161 1191 1162 1192 … … 1166 1196 1167 1197 ideal I = strat->Shdl; 1168 ideal erg = kInterRed(I, NULL);1198 ideal erg = kInterRed(I,tempQ); 1169 1199 assume(I!=erg); 1170 1200 id_Delete(&I, currRing); … … 1174 1204 1175 1205 #if 0 1176 {1177 Print("ideal S: \n");1178 for (int i = 0; i < F->idelems(); i++)1179 {1180 Print("; S[%d] = ", 1+i);1181 p_Write(F->m[i], currRing);1182 }1183 Print(";\n");1184 PrintLn();1185 }1186 1187 1206 PrintS("</sca::bba>\n"); 1188 1207 #endif … … 1192 1211 1193 1212 1194 // is this an exterior algebra or a commuunative polynomial ring \otimes exterior algebra? 1195 // we should check whether qr->qideal is of the form: y_i^2, y_{i+1}^2, \ldots, y_j^2 (j > i) 1196 //.if yes, setup qr->nc->type, etc. 1197 bool sca_SetupSCA(ring& rGR, const ring rG) 1213 // should be used only inside nc_SetupQuotient! 1214 // Check whether this our case: 1215 // 1. rG is a commutative polynomial ring \otimes anticommutative algebra 1216 // 2. factor ideal rGR->qideal contains squares of all alternating variables. 1217 // 1218 // if yes, make rGR a super-commutative algebra! 1219 // NOTE: Factors of SuperCommutative Algebras are supported this way! 1220 bool sca_SetupQuotient(ring rGR, const ring rG) 1198 1221 { 1199 1222 // return false; // test Plural … … 1208 1231 1209 1232 const int N = rG->N; 1233 1210 1234 if(N < 2) 1211 1235 return false; 1212 1236 1213 // skew-commutative + constant skew? => no tensor products at the moment!!! Only exterior algebras are supported!1214 1215 // if( rG->nc->D != NULL )1216 // return false;1217 1218 1237 if(ncRingType(rG) != nc_skew) 1219 1238 return false; 1220 1239 1221 // if(rG->nc->IsSkewConstant != 1) 1222 // return false; 1223 // 1224 // if(!n_IsMOne(p_GetCoeff(MATELEM(rG->nc->COM,1,2),rG->nc->basering), rG->nc->basering)) // COM live in basering! 1225 // return false; 1226 1227 1228 assume(rGR->qideal != NULL); 1229 1230 // sort qr->qideal: 1231 1232 // for sanity 1233 ring rSaveRing = currRing; 1234 1235 bool bWeChangeRing = false; 1236 if(currRing != rG) 1237 { 1238 rChangeCurrRing(rG); 1239 bWeChangeRing = true; 1240 } 1241 1242 const ideal idQuotient = rGR->qideal; 1243 const int iQSize = idQuotient->idelems(); 1244 1245 intvec *iv = idSort(idQuotient, FALSE); // by lex, currRing dependent!!! :( 1246 assume(iv != NULL); 1247 1248 // check for y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2 (iAltVarEnd > iAltVarStart) 1249 bool bSCA = true; 1250 1251 int iAltVarStart = -1; 1252 int iAltVarEnd = -1; 1253 1254 for(int i = 0; i < iQSize; i++) 1255 { 1256 const poly t = idQuotient->m[(*iv)[i]-1]; 1257 1258 if( pNext(t) != NULL ) 1259 { 1260 bSCA = false; 1261 break; 1262 } 1263 1264 const int iComp = p_GetComp(t, rG); 1265 1266 if( iComp > 0 ) 1267 { 1268 bSCA = false; 1269 break; 1270 } 1271 1272 int iV = -1; 1273 1274 for (int j = N; j; j--) 1275 { 1276 const int e = p_GetExp (t, j, rGR); 1277 1278 if( e > 0 ) 1279 { 1280 if( (e != 2) || (iV != -1) ) 1281 { 1282 bSCA = false; 1283 break; 1284 } 1285 1286 iV = j; 1287 } 1288 } 1289 1290 if(!bSCA) break; 1291 1292 if(iV == -1) 1293 { 1294 bSCA = false; 1295 break; 1296 } 1297 1298 if(iAltVarStart == -1) 1299 { 1300 iAltVarStart = iV; 1301 iAltVarEnd = iV; 1302 } else 1303 { 1304 if((iAltVarStart-1) == iV) 1305 { 1306 iAltVarStart = iV; 1307 } else 1308 if((iAltVarEnd+1) == iV) 1309 { 1310 iAltVarEnd = iV; 1240 if(rGR->qideal == NULL) // there will be a factor! 1241 return false; 1242 1243 if(rG->qideal != NULL) // we cannot change from factor to factor! 1244 return false; 1245 1246 1247 int iAltVarEnd = -1; 1248 int iAltVarStart = N+1; 1249 1250 const ring rBase = rG->nc->basering; 1251 const matrix C = rG->nc->C; // live in rBase! 1252 1253 for(int i = 1; i < N; i++) 1254 { 1255 for(int j = i + 1; j <= N; j++) 1256 { 1257 assume(MATELEM(C,i,j) != NULL); // after CallPlural! 1258 number c = p_GetCoeff(MATELEM(C,i,j), rBase); 1259 1260 if( n_IsMOne(c, rBase) ) 1261 { 1262 if( i < iAltVarStart) 1263 iAltVarStart = i; 1264 1265 if( j > iAltVarEnd) 1266 iAltVarEnd = j; 1311 1267 } else 1312 1268 { 1313 bSCA = false; 1314 break; 1269 if( !n_IsOne(c, rBase) ) 1270 { 1271 #ifdef PDEBUG 1272 // Print("Wrong Coeff at: [%d, %d]\n", i, j); 1273 #endif 1274 return false; 1275 } 1315 1276 } 1316 1277 } 1317 1278 } 1318 1279 1319 // cleanup: 1320 delete iv; 1321 1322 if (bWeChangeRing) 1323 { 1324 rChangeCurrRing(rSaveRing); 1325 } 1326 1327 1328 if(!bSCA) return false; 1329 1330 assume( 1 <= iAltVarStart ); 1331 assume( iAltVarStart <= iAltVarEnd ); 1332 assume( iAltVarEnd <= N ); 1333 1334 #ifdef PDEBUG 1335 // Print("AltVars: [%d, %d]\n", iAltVarStart, iAltVarEnd); 1336 #endif 1337 1338 const ring rBase = rG->nc->basering; 1339 const matrix C = rG->nc->C; // live in rBase! 1340 1280 if( (iAltVarEnd == -1) || (iAltVarStart == (N+1)) ) 1281 return false; // either no alternating varables, or a single one => we are in commutative case! 1282 1341 1283 for(int i = 1; i < N; i++) 1342 1284 { … … 1344 1286 { 1345 1287 assume(MATELEM(C,i,j) != NULL); // after CallPlural! 1346 number c = p_GetCoeff(MATELEM(C,i,j), rBase); 1288 number c = p_GetCoeff(MATELEM(C,i,j), rBase); 1347 1289 1348 1290 if( (iAltVarStart <= i) && (j <= iAltVarEnd) ) // S <= i < j <= E … … 1368 1310 } 1369 1311 1312 assume( 1 <= iAltVarStart ); 1313 assume( iAltVarStart < iAltVarEnd ); 1314 assume( iAltVarEnd <= N ); 1315 1316 bool bWeChangeRing = false; 1317 // for sanity 1318 ring rSaveRing = currRing; 1319 1320 if(rSaveRing != rG) 1321 { 1322 rChangeCurrRing(rG); 1323 bWeChangeRing = true; 1324 } 1325 1326 assume(rGR->qideal != NULL); 1327 assume(rG->qideal == NULL); 1328 1329 const ideal idQuotient = rGR->qideal; 1330 1331 // check for 1332 // y_{iAltVarStart}^2, y_{iAltVarStart+1}^2, \ldots, y_{iAltVarEnd}^2 (iAltVarEnd > iAltVarStart) 1333 // to be within quotient ideal. 1334 1335 bool bSCA = true; 1336 1337 for ( int i = iAltVarStart; (i <= iAltVarEnd) && bSCA; i++ ) 1338 { 1339 poly square = p_ISet(1, rSaveRing); 1340 p_SetExp(square, i, 2, rSaveRing); // square = var(i)^2. 1341 p_Setm(square, rSaveRing); 1342 1343 // square = NF( var(i)^2 | Q ) 1344 // NOTE: rSaveRing == currRing now! 1345 // NOTE: there is no better way to check this in general! 1346 square = kNF(idQuotient, NULL, square, 0, 0); 1347 1348 if( square != NULL ) // var(i)^2 is not in Q? 1349 { 1350 p_Delete(&square, rSaveRing); 1351 bSCA = false; 1352 } 1353 } 1354 1355 1356 if (bWeChangeRing) 1357 { 1358 rChangeCurrRing(rSaveRing); 1359 } 1360 1361 if(!bSCA) return false; 1362 1363 1364 1365 #ifdef PDEBUG 1366 // Print("AltVars: [%d, %d]\n", iAltVarStart, iAltVarEnd); 1367 #endif 1368 1369 1370 1370 ////////////////////////////////////////////////////////////////////////// 1371 // ok... let's setup it!!!1371 // ok... here we go. let's setup it!!! 1372 1372 ////////////////////////////////////////////////////////////////////////// 1373 ideal tempQ = id_KillSquares(idQuotient, iAltVarStart, iAltVarEnd, rG); // in rG!!! 1374 1375 rGR->nc->SCAQuotient() = idrMoveR(tempQ, rG, rGR); // deletes tempQ! 1373 1376 1374 1377 ncRingType( rGR, nc_exterior ); … … 1377 1380 scaLastAltVar( rGR, iAltVarEnd ); 1378 1381 1379 // ???????????????????????????????????????????????????????????????????????????????? 1380 // check ordering!!! alternating variables must be bigger than all other variables? 1381 1382 SetProcsSCA(rGR, rGR->p_Procs); 1383 1382 1383 1384 sca_p_ProcsSet(rGR, rGR->p_Procs); 1385 1386 1384 1387 return true; 1385 1388 } … … 1418 1421 assume(rIsSCA(currRing)); 1419 1422 1420 BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing); 1423 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 1424 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); 1425 1426 BOOLEAN bIdHomog = id_IsBiHomogeneous(F, m_iFirstAltVar, m_iLastAltVar, currRing); 1427 1428 assume( !bIdHomog || strat->homog ); // bIdHomog =====[implies]>>>>> strat->homog 1421 1429 1422 1430 strat->homog = strat->homog && bIdHomog; … … 1442 1450 // initHilbCrit(F, Q, &hilb, strat); 1443 1451 1444 // gr_initBba(F,strat);1452 // nc_gr_initBba(F,strat); 1445 1453 initBba(F, strat); // set enterS, red, initEcart, initEcartPair 1446 1454 … … 1476 1484 /////////////////////////////////////////////////////////////// 1477 1485 // SCA: 1478 const unsigned short m_iFirstAltVar = scaFirstAltVar(currRing);1479 const unsigned short m_iLastAltVar = scaLastAltVar(currRing);1480 1481 1482 1486 1483 1487 /* compute------------------------------------------------------- */ … … 1643 1647 1644 1648 // if(0) 1645 for( unsigned short i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )1646 if( p_GetExp(pSave, i, currRing) )1649 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) 1650 if( p_GetExp(pSave, i, currRing) != 0 ) 1647 1651 { 1652 assume(p_GetExp(pSave, i, currRing) == 1); 1653 1648 1654 const poly pNew = sca_pp_Mult_xi_pp(i, pNext, currRing); 1649 1655 … … 1783 1789 1784 1790 1785 1786 // y-Degree1787 inline long p_yDegree(const poly p, const ring r)1788 {1789 assume(rIsSCA(r));1790 1791 const unsigned short m_iFirstAltVar = scaFirstAltVar(r);1792 const unsigned short m_iLastAltVar = scaLastAltVar(r);1793 1794 long sum = 0;1795 1796 for(int i = m_iFirstAltVar; i <= m_iLastAltVar; i++)1797 sum += p_GetExp(p, i, r);1798 1799 return sum;1800 }1801 1802 1803 1804 1805 /**21806 * tests whether p is sca-homogeneous without respect to the actual weigths(=>all ones)1807 */1808 BOOLEAN p_IsYHomogeneous(const poly p, const ring r)1809 {1810 assume(rIsSCA(r));1811 1812 if( p == NULL ) return TRUE;1813 1814 poly q = p;1815 1816 const long o = p_yDegree(q, r);1817 pIter(q);1818 1819 while( q != NULL )1820 {1821 if (p_yDegree(q,r) != o) return FALSE;1822 pIter(q);1823 }1824 1825 return TRUE;1826 }1827 1828 1829 /*21830 *returns true if id is y-homogenous without respect to the aktual weights(=> all ones)1831 */1832 BOOLEAN id_IsYHomogeneous(const ideal id, const ring r)1833 {1834 if (id == NULL) return TRUE;1835 1836 const int iSize = IDELEMS(id);1837 1838 if (iSize == 0) return TRUE;1839 1840 BOOLEAN b = TRUE;1841 1842 for(int i = iSize - 1; (i >= 0 ) && b; i--)1843 b = p_IsYHomogeneous(id->m[i], r);1844 1845 return b;1846 }1847 1848 1791 // ////////////////////////////////////////////////////////////////////////////// 1849 1792 // sca mora... … … 1884 1827 ideal sca_mora(const ideal F, const ideal Q, const intvec *w, const intvec *, kStrategy strat) 1885 1828 { 1886 BOOLEAN bIdHomog = id_IsYHomogeneous(F, currRing); 1829 assume(rIsSCA(currRing)); 1830 1831 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing); 1832 const unsigned int m_iLastAltVar = scaLastAltVar(currRing); 1833 1834 ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing); 1835 1836 const ideal tempQ = currRing->nc->SCAQuotient(); 1837 1838 BOOLEAN bIdHomog = id_IsBiHomogeneous(tempF, m_iFirstAltVar, m_iLastAltVar, currRing); 1839 1840 assume( !bIdHomog || strat->homog ); // bIdHomog =====[implies]>>>>> strat->homog 1887 1841 1888 1842 strat->homog = strat->homog && bIdHomog; … … 1891 1845 assume( strat->homog == bIdHomog ); 1892 1846 #endif /*PDEBUG*/ 1893 1894 1847 1895 1848 #ifdef HAVE_ASSUME … … 1897 1850 sca_mora_loop_count = 0; 1898 1851 #endif 1852 1899 1853 #ifdef KDEBUG 1900 1854 om_Opts.MinTrack = 5; … … 1911 1865 initBuchMoraCrit(strat); 1912 1866 // initHilbCrit(F,NULL,&hilb,strat); // no Q! 1913 initMora( F,strat);1867 initMora(tempF, strat); 1914 1868 initBuchMoraPos(strat); 1915 /*Shdl=*/initBuchMora( F,NULL,strat); // no Q!1869 /*Shdl=*/initBuchMora(tempF, tempQ, strat); // temp Q, F! 1916 1870 // if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat); 1917 1871 /*updateS in initBuchMora has Hecketest … … 1951 1905 #endif 1952 1906 1953 1954 // 4SCA:1955 const unsigned short m_iFirstAltVar = scaFirstAltVar(currRing);1956 const unsigned short m_iLastAltVar = scaLastAltVar(currRing);1957 1907 1958 1908 while (strat->Ll >= 0) … … 2052 2002 const poly pNext = pNext(pSave); 2053 2003 2054 // if(0)2055 for( unsigned short i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )2056 if( p_GetExp(pSave, i, currRing) )2004 if(pNext != NULL) 2005 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ ) 2006 if( p_GetExp(pSave, i, currRing) != 0 ) 2057 2007 { 2058 2008 … … 2142 2092 } 2143 2093 } 2144 // if (Q!=NULL) updateResult(strat->Shdl,Q,strat);2094 if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat); 2145 2095 idTest(strat->Shdl); 2096 2097 id_Delete( &tempF, currRing); 2098 2146 2099 return (strat->Shdl); 2147 2100 } … … 2152 2105 2153 2106 2154 void SetProcsSCA(ring&rGR, p_Procs_s* p_Procs)2107 void sca_p_ProcsSet(ring rGR, p_Procs_s* p_Procs) 2155 2108 { 2156 2109 … … 2214 2167 #endif 2215 2168 } 2216 #endif 2169 2170 2171 // bi-Degree (x, y) of lm(p) 2172 // Y are ones from iFirstAltVar up to iLastAltVar 2173 inline void p_GetSCADegree(const poly p, 2174 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2175 long& dx, long& dy, const ring r) 2176 { 2177 const unsigned int N = r->N; 2178 2179 int i = 1; 2180 2181 dx = 0; 2182 dy = 0; 2183 2184 for(; i < iFirstAltVar; i++) 2185 dx += p_GetExp(p, i, r); 2186 2187 for(; i <= iLastAltVar; i++) 2188 dy += p_GetExp(p, i, r); 2189 2190 for(; i <= N; i++) 2191 dx += p_GetExp(p, i, r); 2192 } 2193 2194 // tests whether p is bi-homogeneous without respect to the actual weigths(=>all ones) 2195 // Polynomial is bi-homogeneous iff all monomials have the same bi-degree (x,y). 2196 // Y are ones from iFirstAltVar up to iLastAltVar 2197 bool p_IsBiHomogeneous(const poly p, 2198 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2199 const ring r) 2200 { 2201 if( p == NULL ) return true; 2202 2203 poly q = p; 2204 2205 2206 long dx, dy; 2207 2208 p_GetSCADegree( q, iFirstAltVar, iLastAltVar, dx, dy, r); // get bi degree of lm(p) 2209 2210 pIter(q); 2211 2212 for(; q != NULL; pIter(q) ) 2213 { 2214 long x, y; 2215 2216 p_GetSCADegree( q, iFirstAltVar, iLastAltVar, x, y, r); // get bi degree of q 2217 2218 if ( (x != dx) || (y != dy) ) return false; 2219 } 2220 2221 return true; 2222 } 2223 2224 2225 // returns true if id is bi-homogenous without respect to the aktual weights(=> all ones) 2226 bool id_IsBiHomogeneous(const ideal id, 2227 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2228 const ring r) 2229 { 2230 if (id == NULL) return true; // zero ideal 2231 2232 const int iSize = IDELEMS(id); 2233 2234 if (iSize == 0) return true; 2235 2236 bool b = true; 2237 2238 for(int i = iSize - 1; (i >= 0 ) && b; i--) 2239 b = p_IsBiHomogeneous(id->m[i], iFirstAltVar, iLastAltVar, r); 2240 2241 return b; 2242 } 2243 2244 2245 2246 2247 // reduce term lt(m) modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar: 2248 // either create a copy of m or return NULL 2249 inline poly m_KillSquares(const poly m, 2250 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2251 const ring r) 2252 { 2253 #ifdef PDEBUG 2254 p_Test(m, r); 2255 2256 #if 0 2257 Print("m_KillSquares, m = "); // ! 2258 p_Write(m, r); 2259 #endif 2260 #endif 2261 2262 assume( m != NULL ); 2263 2264 for(int k = iFirstAltVar; k <= iLastAltVar; k++) 2265 if( p_GetExp(m, k, r) > 1 ) 2266 return NULL; 2267 2268 return p_Head(m, r); 2269 } 2270 2271 2272 // reduce polynomial p modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar 2273 poly p_KillSquares(const poly p, 2274 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2275 const ring r) 2276 { 2277 #ifdef PDEBUG 2278 p_Test(p, r); 2279 2280 #if 0 2281 Print("p_KillSquares, p = "); // ! 2282 p_Write(p, r); 2283 #endif 2284 #endif 2285 2286 2287 if( p == NULL ) 2288 return NULL; 2289 2290 poly pResult = NULL; 2291 poly* ppPrev = &pResult; 2292 2293 for( poly q = p; q!= NULL; pIter(q) ) 2294 { 2295 #ifdef PDEBUG 2296 p_Test(q, r); 2297 #endif 2298 2299 // terms will be in the same order because of quasi-ordering! 2300 poly v = m_KillSquares(q, iFirstAltVar, iLastAltVar, r); 2301 2302 if( v != NULL ) 2303 { 2304 *ppPrev = v; 2305 ppPrev = &pNext(v); 2306 } 2307 2308 } 2309 2310 #ifdef PDEBUG 2311 p_Test(pResult, r); 2312 #if 0 2313 Print("p_KillSquares => "); // ! 2314 p_Write(pResult, r); 2315 #endif 2316 #endif 2317 2318 return(pResult); 2319 } 2320 2321 2322 2323 2324 // reduces ideal id modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar 2325 // returns the reduced ideal or zero ideal. 2326 ideal id_KillSquares(const ideal id, 2327 const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 2328 const ring r) 2329 { 2330 if (id == NULL) return id; // zero ideal 2331 2332 const int iSize = id->idelems(); 2333 2334 if (iSize == 0) return id; 2335 2336 ideal temp = idInit(iSize, 1); 2337 2338 #if 0 2339 PrintS("<id_KillSquares>\n"); 2340 { 2341 Print("ideal id: \n"); 2342 for (int i = 0; i < id->idelems(); i++) 2343 { 2344 Print("; id[%d] = ", i+1); 2345 p_Write(id->m[i], r); 2346 } 2347 Print(";\n"); 2348 PrintLn(); 2349 } 2350 #endif 2351 2352 2353 for (int j = 0; j < iSize; j++) 2354 temp->m[j] = p_KillSquares(id->m[j], iFirstAltVar, iLastAltVar, r); 2355 2356 idSkipZeroes(temp); 2357 2358 #if 0 2359 PrintS("<id_KillSquares>\n"); 2360 { 2361 Print("ideal temp: \n"); 2362 for (int i = 0; i < temp->idelems(); i++) 2363 { 2364 Print("; temp[%d] = ", i+1); 2365 p_Write(temp->m[i], r); 2366 } 2367 Print(";\n"); 2368 PrintLn(); 2369 } 2370 PrintS("</id_KillSquares>\n"); 2371 #endif 2372 2373 return temp; 2374 } 2375 2376 2377 2378 2379 #endif
Note: See TracChangeset
for help on using the changeset viewer.