| 237 | } |
| 238 | |
| 239 | lists liMakeResolv(resolvente r, int length, int reallen, |
| 240 | int typ0, intvec ** weights, int add_row_shift) |
| 241 | { |
| 242 | // re-uses r, weights[i] |
| 243 | lists L=(lists)omAlloc0Bin(slists_bin); |
| 244 | if (length<=0) |
| 245 | { |
| 246 | // handle "empty" resolutions |
| 247 | L->Init(0); |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | int oldlength=length; |
| 252 | while (r[length-1]==NULL) length--; |
| 253 | if (reallen<=0) reallen=currRing->N; |
| 254 | reallen=si_max(reallen,length); |
| 255 | L->Init(reallen); |
| 256 | int i=0; |
| 257 | |
| 258 | while (i<length) |
| 259 | { |
| 260 | if (r[i]!=NULL) |
| 261 | { |
| 262 | if (i==0) |
| 263 | { |
| 264 | L->m[i].rtyp=typ0; |
| 265 | int j=IDELEMS(r[0])-1; |
| 266 | while ((j>0) && (r[0]->m[j]==NULL)) j--; |
| 267 | j++; |
| 268 | if (j!=IDELEMS(r[0])) |
| 269 | { |
| 270 | pEnlargeSet(&(r[0]->m),IDELEMS(r[0]),j-IDELEMS(r[0])); |
| 271 | IDELEMS(r[0])=j; |
| 272 | } |
| 273 | } |
| 274 | else |
| 275 | { |
| 276 | L->m[i].rtyp=MODUL_CMD; |
| 277 | int rank=IDELEMS(r[i-1]); |
| 278 | if (idIs0(r[i-1])) |
| 279 | { |
| 280 | idDelete(&(r[i])); |
| 281 | r[i]=id_FreeModule(rank, currRing); |
| 282 | } |
| 283 | else |
| 284 | { |
| 285 | r[i]->rank=si_max(rank,(int)id_RankFreeModule(r[i], currRing)); |
| 286 | } |
| 287 | idSkipZeroes(r[i]); |
| 288 | } |
| 289 | L->m[i].data=(void *)r[i]; |
| 290 | if ((weights!=NULL) && (weights[i]!=NULL)) |
| 291 | { |
| 292 | intvec *w=weights[i]; |
| 293 | (*w) += add_row_shift; |
| 294 | atSet((idhdl)&L->m[i],omStrDup("isHomog"),w,INTVEC_CMD); |
| 295 | weights[i] = NULL; |
| 296 | } |
no test coverage detected