| 345 | } |
| 346 | } |
| 347 | ideal idDivRem(ideal A,const ideal quot, ideal &factor,ideal *unit,int lazyReduce) |
| 348 | { |
| 349 | /* special cases */ |
| 350 | if (idIs0(A) || idIs0(quot)) |
| 351 | { |
| 352 | factor=idInit(1,IDELEMS(quot)); |
| 353 | setUnit(A->rank,unit); |
| 354 | return idCopy(A); |
| 355 | } |
| 356 | /* ideal or module? */ |
| 357 | ring orig_ring=currRing; |
| 358 | int k=id_RankFreeModule(quot,orig_ring); |
| 359 | int lsmod=0; |
| 360 | if (k==0) { lsmod=1;k=1;} /*ideal*/ |
| 361 | /* NF(A 0 E,quot E 0) |
| 362 | * A,quot: 1..k, 0,E: k+1..k+IDELEMS(quot), |
| 363 | * E,0: k+IDELEMS(quot)..k+IDELEMS(quot)+IDELEMS(A) */ |
| 364 | /* new ring */ |
| 365 | ring syz_ring=rAssure_SyzOrder(orig_ring,TRUE); |
| 366 | rSetSyzComp(1,syz_ring); |
| 367 | rChangeCurrRing(syz_ring); |
| 368 | /* move ideals to new ring */ |
| 369 | ideal s_quot; |
| 370 | ideal s_A; |
| 371 | if (orig_ring != syz_ring) |
| 372 | { |
| 373 | s_quot=idrCopyR_NoSort(quot,orig_ring,syz_ring); |
| 374 | s_A=idrCopyR_NoSort(A,orig_ring,syz_ring); |
| 375 | } |
| 376 | else |
| 377 | { |
| 378 | s_quot=id_Copy(quot,syz_ring); |
| 379 | s_A=id_Copy(A,syz_ring); |
| 380 | } |
| 381 | /* quot[i] -> quot[i]+e(k+i+1) */ |
| 382 | for(int i=0;i<IDELEMS(s_quot);i++) |
| 383 | { |
| 384 | p_Shift(&s_quot->m[i],lsmod,syz_ring); |
| 385 | poly p=p_One(syz_ring); |
| 386 | p_SetComp(p,k+i+2,syz_ring); |
| 387 | p_Setm(p,syz_ring); |
| 388 | s_quot->m[i]=p_Add_q(s_quot->m[i],p,syz_ring); |
| 389 | } |
| 390 | s_quot->rank=k+IDELEMS(quot)+1; |
| 391 | /* A[i] -> A[i]*e(1) */ |
| 392 | if (lsmod==1) |
| 393 | { |
| 394 | for(int i=0;i<IDELEMS(s_A);i++) |
| 395 | { |
| 396 | p_Shift(&s_A->m[i],1,syz_ring); |
| 397 | } |
| 398 | } |
| 399 | if (unit!=NULL) |
| 400 | { |
| 401 | int u_k=k+IDELEMS(quot)+2; |
| 402 | for(int i=0;i<IDELEMS(s_A);i++) |
| 403 | { |
| 404 | poly p=p_One(syz_ring); |
no test coverage detected