Changeset 33161fd in git
- Timestamp:
- May 30, 2012, 10:05:27 PM (11 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 210d1bfc080ce1cf56ed7c937c68613a6c8cc989
- Parents:
- 2407cbbcbfa07c81823bde4407a9c0ae473b292c
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-05-30 22:05:27+02:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:44+02:00
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/schreyer.lib
r2407cb r33161fd 1078 1078 1079 1079 /// TODO: save shortcut (syz: |-.->) LM(LM(m) * "t") -> syz? 1080 proc SSFindReducer(def product, def syzterm, def L , def T, list #)1080 proc SSFindReducer(def product, def syzterm, def L/*, def T*/, list #) 1081 1081 { 1082 1082 if( typeof( attrib(basering, "DEBUG") ) == "int" ) … … 1096 1096 "product: ", product; 1097 1097 "L: ", L; 1098 "T: ", T;1098 // "T: ", T; 1099 1099 if( size(#) > 0 ) 1100 1100 { … … 1125 1125 } 1126 1126 1127 // def product = m * t; 1128 1129 bigint c = leadcomp(product); int r = int(c); 1130 1131 def a, b, bb; 1132 1133 vector nf = [0]; 1134 1135 // looking for an appropriate diviser 1136 for( int k = ncols(L); k > 0; k-- ) 1137 { 1138 a = L[k]; 1139 // with the same mod. component 1140 if( leadcomp(a) == c ) 1141 { 1142 b = - (leadmonomial(product) / leadmonomial(L[k])); 1143 1144 // which divides the product: looking for the 1st appropriate one! 1145 if( b != 0 ) 1127 if( typeof(#[1]) == "module" ) 1128 { 1129 vector my = FindReducer(product, syzterm, L/*, T*/, #[1]); 1130 } else 1131 { 1132 vector my = FindReducer(product, syzterm, L/*, T*/); 1133 } 1134 1135 1136 if( @SYZCHECK ) 1137 { 1138 bigint c = leadcomp(product); int r = int(c); 1139 1140 def a, b, bb; 1141 1142 vector nf = [0]; 1143 1144 // looking for an appropriate diviser 1145 for( int k = ncols(L); k > 0; k-- ) 1146 { 1147 a = L[k]; 1148 // with the same mod. component 1149 if( leadcomp(a) == c ) 1146 1150 { 1147 bb = b * gen(k); 1148 1149 if (size(bb + syzterm) == 0) // cannot allow something like: a*gen(i) - a*gen(i) 1151 b = - (leadmonomial(product) / leadmonomial(L[k])); 1152 1153 // which divides the product: looking for the 1st appropriate one! 1154 if( b != 0 ) 1150 1155 { 1151 nf = [0]; 1152 } else 1153 { 1154 nf = bb; 1155 } 1156 1157 // new syz. term should not be in <LS = #> 1158 if( size(#) > 0 ) 1159 { 1160 if( typeof(#[1]) == "module" ) 1156 bb = b * gen(k); 1157 1158 if (size(bb + syzterm) == 0) // cannot allow something like: a*gen(i) - a*gen(i) 1161 1159 { 1162 nf = NF(bb, #[1]); 1160 nf = [0]; 1161 } else 1162 { 1163 nf = bb; 1164 } 1165 1166 // new syz. term should not be in <LS = #> 1167 if( size(#) > 0 ) 1168 { 1169 if( typeof(#[1]) == "module" ) 1170 { 1171 nf = NF(bb, #[1]); 1172 } 1173 } 1174 1175 // while the complement (the fraction) is not reducible by leading syzygies 1176 if( nf != 0 ) // nf must be == bb!!! 1177 { 1178 /// TODO: save shortcut LM(m) * T[i] -> ? 1179 1180 // choose ANY such reduction... (with the biggest index?) 1181 break; 1163 1182 } 1164 1183 } 1165 1166 // while the complement (the fraction) is not reducible by leading syzygies1167 if( nf != 0 ) // nf must be == bb!!!1168 {1169 /// TODO: save shortcut LM(m) * T[i] -> ?1170 1171 // choose ANY such reduction... (with the biggest index?)1172 break;1173 }1174 1184 } 1175 1185 } 1176 } 1177 if( @DEBUG ) 1178 { 1179 "SSFindReducer::Output: ", nf; 1180 } 1181 return (nf); 1186 1187 if( my != nf ) 1188 { 1189 "ERROR in FindReducer => ", my, " != nf: ", nf; 1190 $; 1191 } 1192 } 1193 1194 if( @DEBUG ) 1195 { 1196 "SSFindReducer::Output: ", my; 1197 } 1198 1199 return (my); 1182 1200 } 1183 1201 … … 1243 1261 def product = m * t; 1244 1262 1245 s = SSFindReducer(product, syzterm, L , T, #);1263 s = SSFindReducer(product, syzterm, L/*, T*/, #); 1246 1264 1247 1265 if( size(s) != 0 ) … … 1426 1444 } else 1427 1445 { 1428 a2 = SSFindReducer( aa * L[r], a, L , T, LS);1446 a2 = SSFindReducer( aa * L[r], a, L/*, T*/, LS); 1429 1447 } 1430 1448 … … 1445 1463 while (size(spoly) > 0) 1446 1464 { 1447 a2 = SSFindReducer( lead(spoly), [0], L , T, LS);1465 a2 = SSFindReducer( lead(spoly), [0], L/*, T*/, LS); 1448 1466 spoly = Tail(spoly); 1449 1467 … … 1827 1845 exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms); 1828 1846 exportto(Schreyer, Syzextra::Sort_c_ds); 1847 1848 exportto(Schreyer, Syzextra::FindReducer); 1829 1849 } 1830 1850 /* … … 1871 1891 exportto(Schreyer, Syzextra_g::Compute2LeadingSyzygyTerms); 1872 1892 exportto(Schreyer, Syzextra_g::Sort_c_ds); 1893 1894 exportto(Schreyer, Syzextra_g::FindReducer); 1873 1895 1874 1896 } -
dyn_modules/syzextra/mod_main.cc
r2407cb r33161fd 595 595 if( __DEBUG__ ) 596 596 { 597 PrintS(" 597 PrintS("cmp_c_ds: a & b have the same comp & deg! "); PrintLn(); 598 598 } 599 599 #endif … … 1070 1070 1071 1071 1072 /// return a new term: leading coeff * leading monomial of p 1073 /// with 0 leading component! 1074 static inline poly leadmonom(const poly p, const ring r) 1075 { 1076 poly m = NULL; 1077 1078 if( p != NULL ) 1079 { 1080 assume( p != NULL ); 1081 assume( p_LmTest(p, r) ); 1082 1083 m = p_LmInit(p, r); 1084 p_SetCoeff0(m, n_Copy(p_GetCoeff(p, r), r), r); 1085 1086 p_SetComp(m, 0, r); 1087 p_Setm(m, r); 1088 1089 assume( p_GetComp(m, r) == 0 ); 1090 assume( m != NULL ); 1091 assume( pNext(m) == NULL ); 1092 assume( p_LmTest(m, r) ); 1093 } 1094 1095 return m; 1096 } 1097 1098 1099 /// TODO: save shortcut (syz: |-.->) LM(LM(m) * "t") -> syz? 1100 /// proc SSFindReducer(def product, def syzterm, def L, def T, list #) 1101 static BOOLEAN FindReducer(leftv res, leftv h) 1102 { 1103 const ring r = currRing; 1104 1105 NoReturn(res); 1106 1107 1108 #ifndef NDEBUG 1109 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE))); 1110 #else 1111 const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE))); 1112 #endif 1113 1114 const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0))); 1115 const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)0))); 1116 const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0))); 1117 1118 if ((h==NULL) || (h->Typ()!=VECTOR_CMD && h->Typ() !=POLY_CMD) || (h->Data() == NULL)) 1119 { 1120 WerrorS("`FindReducer(<poly/vector>, <vector>, <ideal/module>[,<module>])` expected"); 1121 return TRUE; 1122 } 1123 1124 const poly product = (poly) h->Data(); h = h->Next(); 1125 1126 assume (product != NULL); 1127 1128 1129 if ((h==NULL) || (h->Typ()!=VECTOR_CMD)) 1130 { 1131 WerrorS("`FindReducer(<poly/vector>, <vector>, <ideal/module>[,<module>])` expected"); 1132 return TRUE; 1133 } 1134 1135 const poly syzterm = (poly) h->Data(); h = h->Next(); 1136 1137 int c = 0; 1138 1139 if (syzterm != NULL) 1140 c = p_GetComp(syzterm, r) - 1; 1141 1142 1143 if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL)) 1144 { 1145 WerrorS("`FindReducer(<poly/vector>, <vector>, <ideal/module>[,<module>])` expected"); 1146 return TRUE; 1147 } 1148 1149 const ideal L = (ideal) h->Data(); h = h->Next(); 1150 1151 assume( IDELEMS(L) > 0 ); 1152 assume( c >= 0 && c < IDELEMS(L) ); 1153 1154 1155 /* 1156 if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL)) 1157 { 1158 WerrorS("`FindReducer(<poly/vector>, <vector>, <ideal/module>[,<module>])` expected"); 1159 return TRUE; 1160 } 1161 1162 const ideal T = (ideal) h->Data(); h = h->Next(); 1163 */ 1164 1165 ideal LS = NULL; 1166 1167 if ((h != NULL) && (h->Typ() ==MODUL_CMD) && (h->Data() != NULL)) 1168 { 1169 LS = (ideal)h->Data(); 1170 h = h->Next(); 1171 } 1172 1173 if( __TAILREDSYZ__ ) 1174 assume (LS != NULL); 1175 1176 assume( h == NULL ); 1177 1178 if( __DEBUG__ ) 1179 { 1180 PrintS("FindReducer(product, syzterm, L, T, #)::Input: \n"); 1181 1182 PrintS("product: "); dPrint(product, r, r, 2); 1183 PrintS("syzterm: "); dPrint(syzterm, r, r, 2); 1184 PrintS("L: "); dPrint(L, r, r, 2); 1185 // PrintS("T: "); dPrint(T, r, r, 4); 1186 1187 if( LS == NULL ) 1188 PrintS("LS: NULL\n"); 1189 else 1190 { 1191 PrintS("LS: "); dPrint(LS, r, r, 2); 1192 } 1193 } 1194 1195 1196 if (__SYZCHECK__ && syzterm != NULL) 1197 { 1198 const poly m = L->m[c]; 1199 1200 assume( m != NULL ); assume( pNext(m) == NULL ); 1201 1202 poly lm = p_Mult_mm(leadmonom(syzterm, r), m, r); 1203 assume( p_EqualPolys(lm, product, r) ); 1204 1205 // def @@c = leadcomp(syzterm); int @@r = int(@@c); 1206 // def @@product = leadmonomial(syzterm) * L[@@r]; 1207 1208 p_Delete(&lm, r); 1209 } 1210 1211 1212 res->rtyp = VECTOR_CMD; 1213 1214 // looking for an appropriate diviser q = L[k]... 1215 for( int k = IDELEMS(L)-1; k>= 0; k-- ) 1216 { 1217 const poly p = L->m[k]; 1218 1219 // ... which divides the product, looking for the _1st_ appropriate one! 1220 if( !p_LmDivisibleBy(p, product, r) ) 1221 continue; 1222 1223 1224 const poly q = p_New(r); 1225 pNext(q) = NULL; 1226 p_ExpVectorDiff(q, product, p, r); // (LM(product) / LM(L[k])) 1227 p_SetComp(q, k + 1, r); 1228 p_Setm(q, r); 1229 1230 // cannot allow something like: a*gen(i) - a*gen(i) 1231 if (syzterm != NULL && (k == c)) 1232 if (p_ExpVectorEqual(syzterm, q, r)) 1233 { 1234 if( __DEBUG__ ) 1235 { 1236 Print("FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: "); 1237 dPrint(syzterm, r, r, 1); 1238 } 1239 1240 p_LmFree(q, r); 1241 continue; 1242 } 1243 1244 // while the complement (the fraction) is not reducible by leading syzygies 1245 if( LS != NULL ) 1246 { 1247 BOOLEAN ok = TRUE; 1248 1249 for(int kk = IDELEMS(LS)-1; kk>= 0; kk-- ) 1250 { 1251 const poly pp = LS->m[kk]; 1252 1253 if( p_LmDivisibleBy(pp, q, r) ) 1254 { 1255 if( __DEBUG__ ) 1256 { 1257 Print("FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", kk+1); 1258 dPrint(pp, r, r, 1); 1259 } 1260 1261 ok = FALSE; // q in <LS> :(( 1262 break; 1263 } 1264 } 1265 1266 if(!ok) 1267 { 1268 p_LmFree(q, r); 1269 continue; 1270 } 1271 } 1272 1273 p_SetCoeff0(q, n_Neg( n_Div( p_GetCoeff(product, r), p_GetCoeff(p, r), r), r), r); 1274 1275 if( __DEBUG__ ) 1276 { 1277 PrintS("FindReducer::Output: \n"); 1278 dPrint(q, r, r, 1); 1279 } 1280 1281 res->data = q; 1282 return FALSE; 1283 } 1284 1285 res->data = NULL; 1286 return FALSE; 1287 1288 } 1289 1290 1291 1072 1292 /// Get leading term without a module component 1073 1293 static BOOLEAN leadmonom(leftv res, leftv h) … … 1080 1300 const poly p = (poly)(h->Data()); 1081 1301 1082 poly m = NULL; 1083 1084 if( p != NULL ) 1085 { 1086 assume( p != NULL ); 1087 assume( p_LmTest(p, r) ); 1088 1089 m = p_LmInit(p, r); 1090 p_SetCoeff0(m, n_Copy(p_GetCoeff(p, r), r), r); 1091 1092 // if( p_GetComp(m, r) != 0 ) 1093 // { 1094 p_SetComp(m, 0, r); 1095 p_Setm(m, r); 1096 // } 1097 1098 assume( p_GetComp(m, r) == 0 ); 1099 assume( m != NULL ); 1100 assume( p_LmTest(m, r) ); 1101 } 1302 const poly m = leadmonom(p, r); 1102 1303 1103 1304 res->rtyp = POLY_CMD; … … 1721 1922 1722 1923 ADD(psModulFunctions, currPack->libname, "Sort_c_ds", FALSE, Sort_c_ds); 1924 ADD(psModulFunctions, currPack->libname, "FindReducer", FALSE, FindReducer); 1925 1723 1926 1724 1927 // ADD(psModulFunctions, currPack->libname, "GetAMData", FALSE, GetAMData);
Note: See TracChangeset
for help on using the changeset viewer.