Changeset ef5568 in git
- Timestamp:
- Oct 4, 2004, 4:23:22 PM (19 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 30d73ec3764bd5a6c7e6efa89aa3fd8fb8c212eb
- Parents:
- 1fc8e4fad14ce067e400ed1ecaa5e3ab1346f5e7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/tgb.cc
r1fc8e4f ref5568 1043 1043 1044 1044 } 1045 1046 1047 static int iq_crit(const void* ap,const void* bp){ 1048 1049 sorted_pair_node* a=*((sorted_pair_node**)ap); 1050 sorted_pair_node* b=*((sorted_pair_node**)bp); 1051 assume(a->i>a->j); 1052 assume(b->i>b->j); 1053 int comp=pLmCmp(a->lcm_of_lm, b->lcm_of_lm); 1054 if(comp!=0) 1055 return comp; 1056 if (a->deg<b->deg) return -1; 1057 if (a->deg>b->deg) return 1; 1058 1059 1060 if (a->expected_length<b->expected_length) return -1; 1061 if (a->expected_length>b->expected_length) return 1; 1062 if (a->j>b->j) return 1; 1063 if (a->j<b->j) return -1; 1064 return 0; 1065 } 1066 1067 static sorted_pair_node** add_to_basis_ideal_quotient(poly h, int i_pos, int j_pos,calc_dat* c, int* ip) 1068 { 1069 1070 assume(h!=NULL); 1071 // BOOLEAN corr=lenS_correct(c->strat); 1072 BOOLEAN R_found=FALSE; 1073 void* hp; 1074 1075 ++(c->n); 1076 ++(c->S->ncols); 1077 int i,j; 1078 i=c->n-1; 1079 sorted_pair_node** nodes=(sorted_pair_node**) omalloc(sizeof(sorted_pair_node*)*i); 1080 int spc=0; 1081 c->T_deg=(int*) omrealloc(c->T_deg,c->n*sizeof(int)); 1082 c->T_deg[i]=pTotaldegree(h); 1083 hp=omrealloc(c->rep, c->n *sizeof(int)); 1084 if (hp!=NULL){ 1085 c->rep=(int*) hp; 1086 } else { 1087 exit(1); 1088 } 1089 c->short_Exps=(long *) omrealloc(c->short_Exps ,c->n*sizeof(long)); 1090 1091 hp=omrealloc(c->lengths, c->n *sizeof(int)); 1092 if (hp!=NULL){ 1093 c->lengths=(int*) hp; 1094 } else { 1095 exit(1); 1096 } 1097 c->lengths[i]=pLength(h); 1098 hp=omrealloc(c->states, c->n * sizeof(char*)); 1099 1100 c->states=(char**) hp; 1101 c->gcd_of_terms=(poly*) omrealloc(c->gcd_of_terms, c->n *sizeof(poly)); 1102 c->gcd_of_terms[i]=gcd_of_terms(h,c->r); 1103 c->rep[i]=i; 1104 hp=omalloc(i*sizeof(char)); 1105 if (hp!=NULL){ 1106 c->states[i]=(char*) hp; 1107 } else { 1108 exit(1); 1109 } 1110 hp=omrealloc(c->S->m,c->n*sizeof(poly)); 1111 if (hp!=NULL){ 1112 c->S->m=(poly*) hp; 1113 } else { 1114 exit(1); 1115 } 1116 c->S->m[i]=h; 1117 c->short_Exps[i]=p_GetShortExpVector(h,c->r); 1118 for (j=0;j<i;j++){ 1119 1120 //check product criterion 1121 1122 c->states[i][j]=UNCALCULATED; 1123 assume(p_LmDivisibleBy(c->S->m[i],c->S->m[j],c->r)== 1124 p_LmShortDivisibleBy(c->S->m[i],c->short_Exps[i],c->S->m[j],~(c->short_Exps[j]),c->r)); 1125 if(!c->F4_mode) 1126 { 1127 assume(!(p_LmDivisibleBy(c->S->m[j],c->S->m[i],c->r))); 1128 } 1129 //lies I[i] under I[j] ? 1130 1131 if ((c->lengths[i]==1) && (c->lengths[j]==1)) 1132 c->states[i][j]=HASTREP; 1133 else if (pHasNotCF(c->S->m[i],c->S->m[j])) 1134 { 1135 c->easy_product_crit++; 1136 c->states[i][j]=HASTREP; 1137 } 1138 else if(extended_product_criterion(c->S->m[i],c->gcd_of_terms[i],c->S->m[j],c->gcd_of_terms[j],c)) 1139 { 1140 c->states[i][j]=HASTREP; 1141 c->extended_product_crit++; 1142 //PrintS("E"); 1143 } 1144 // if (c->states[i][j]==UNCALCULATED){ 1145 1146 1147 // poly short_s=ksCreateShortSpoly(c->S->m[i],c->S->m[j],c->r); 1148 // if (short_s) 1149 // { 1150 sorted_pair_node* s=(sorted_pair_node*) omalloc(sizeof(sorted_pair_node)); 1151 s->i=max(i,j); 1152 s->j=min(i,j); 1153 s->expected_length=c->lengths[i]+c->lengths[j]-2; 1154 1155 poly lm=pOne(); 1156 1157 pLcm(c->S->m[i], c->S->m[j], lm); 1158 pSetm(lm); 1159 s->deg=pTotaldegree(lm); 1160 s->lcm_of_lm=lm; 1161 // pDelete(&short_s); 1162 //assume(lm!=NULL); 1163 nodes[spc]=s; 1164 spc++; 1165 // } 1166 //else 1167 //{ 1168 //c->states[i][j]=HASTREP; 1169 //} 1170 } 1171 1172 assume(spc==i); 1173 //now ideal quotient crit 1174 qsort(nodes,spc,sizeof(sorted_pair_node*),iq_crit); 1175 1176 sorted_pair_node** nodes_final=(sorted_pair_node**) omalloc(sizeof(sorted_pair_node*)*i); 1177 int spc_final=0; 1178 j=0; 1179 while(j<spc) 1180 { 1181 int lower=j; 1182 int upper; 1183 BOOLEAN has=FALSE; 1184 for(upper=lower+1;upper<spc;upper++) 1185 { 1186 1187 if(!pLmEqual(nodes[lower]->lcm_of_lm,nodes[upper]->lcm_of_lm)) 1188 { 1189 break; 1190 } 1191 if (has_t_rep(nodes[upper]->i,nodes[upper]->j,c)) 1192 has=TRUE; 1193 1194 } 1195 upper=upper-1; 1196 int z; 1197 assume(spc_final<=j); 1198 for(z=0;z<spc_final;z++) 1199 { 1200 if(p_LmDivisibleBy(nodes_final[z]->lcm_of_lm,nodes[lower]->lcm_of_lm,c->r)) 1201 { 1202 has=TRUE; 1203 break; 1204 } 1205 } 1206 1207 if(has) 1208 { 1209 for(;lower<=upper;lower++) 1210 { 1211 free_sorted_pair_node(nodes[lower],c->r); 1212 nodes[lower]=NULL; 1213 } 1214 j=upper+1; 1215 continue; 1216 } 1217 else 1218 { 1219 nodes_final[spc_final++]=nodes[lower]; 1220 nodes[lower]=NULL; 1221 for(lower=lower+1;lower<=upper;lower++) 1222 { 1223 free_sorted_pair_node(nodes[lower],c->r); 1224 nodes[lower]=NULL; 1225 } 1226 j=upper+1; 1227 continue; 1228 } 1229 } 1230 1231 // Print("i:%d,spc_final:%d",i,spc_final); 1232 1233 1234 1235 1236 assume(spc_final<=spc); 1237 omfree(nodes); 1238 nodes=NULL; 1239 1240 add_to_reductors(c, h, c->lengths[c->n-1]); 1241 //i=posInS(c->strat,c->strat->sl,h,0 ecart); 1242 1243 if (c->lengths[c->n-1]==1) 1244 shorten_tails(c,c->S->m[c->n-1]); 1245 //you should really update c->lengths, c->strat->lenS, and the oder of polys in strat if you sort after lengths 1246 1247 //for(i=c->strat->sl; i>0;i--) 1248 // if(c->strat->lenS[i]<c->strat->lenS[i-1]) printf("fehler bei %d\n",i); 1249 if (c->Rcounter>50) { 1250 c->Rcounter=0; 1251 cleanS(c->strat,c); 1252 } 1253 if(!ip){ 1254 qsort(nodes_final,spc_final,sizeof(sorted_pair_node*),pair_better_gen2); 1255 1256 1257 c->apairs=merge(c->apairs,c->pair_top+1,nodes_final,spc_final,c); 1258 c->pair_top+=spc_final; 1259 clean_top_of_pair_list(c); 1260 omfree(nodes_final); 1261 return NULL; 1262 } 1263 { 1264 *ip=spc_final; 1265 return nodes_final; 1266 } 1267 1268 1269 1270 } 1271 1272 1273 1274 1275 1276 1045 1277 #if 0 1046 1278 static poly redNF (poly h,kStrategy strat) … … 1619 1851 //remember to free res here 1620 1852 p=redTailShort(p, c->strat); 1621 sbuf[j]=add_to_basis (p,-1,-1,c,ibuf+j);1622 1853 sbuf[j]=add_to_basis_ideal_quotient(p,-1,-1,c,ibuf+j); 1854 // sbuf[j]=add_to_basis(p,-1,-1,c,ibuf+j); 1623 1855 } 1624 1856 int sum=0; … … 3135 3367 //remember to free res here 3136 3368 // p=redTailShort(p, c->strat); 3137 sbuf[j]=add_to_basis (p,-1,-1,c,ibuf+j);3369 sbuf[j]=add_to_basis_ideal_quotient(p,-1,-1,c,ibuf+j); 3138 3370 3139 3371 }
Note: See TracChangeset
for help on using the changeset viewer.