! used for GB over ZZ: look for constant and monomial elements in the ideal background: any known constant element of ideal suppresses intermediate coefficient swell */
| 10533 | intermediate coefficient swell |
| 10534 | */ |
| 10535 | poly preIntegerCheck(const ideal Forig, const ideal Q) |
| 10536 | { |
| 10537 | if(!nCoeff_is_Z(currRing->cf)) |
| 10538 | return NULL; |
| 10539 | ideal F = idCopy(Forig); |
| 10540 | idSkipZeroes(F); |
| 10541 | poly pmon; |
| 10542 | ring origR = currRing; |
| 10543 | ideal monred = idInit(1,1); |
| 10544 | for(int i=0; i<idElem(F); i++) |
| 10545 | { |
| 10546 | if(pNext(F->m[i]) == NULL) |
| 10547 | idInsertPoly(monred, pCopy(F->m[i])); |
| 10548 | } |
| 10549 | int posconst = idPosConstant(F); |
| 10550 | if((posconst != -1) && (!nIsZero(F->m[posconst]->coef))) |
| 10551 | { |
| 10552 | idDelete(&F); |
| 10553 | idDelete(&monred); |
| 10554 | return NULL; |
| 10555 | } |
| 10556 | int idelemQ = 0; |
| 10557 | if(Q!=NULL) |
| 10558 | { |
| 10559 | idelemQ = IDELEMS(Q); |
| 10560 | for(int i=0; i<idelemQ; i++) |
| 10561 | { |
| 10562 | if(pNext(Q->m[i]) == NULL) |
| 10563 | idInsertPoly(monred, pCopy(Q->m[i])); |
| 10564 | } |
| 10565 | idSkipZeroes(monred); |
| 10566 | posconst = idPosConstant(monred); |
| 10567 | //the constant, if found, will be from Q |
| 10568 | if((posconst != -1) && (!nIsZero(monred->m[posconst]->coef))) |
| 10569 | { |
| 10570 | pmon = pCopy(monred->m[posconst]); |
| 10571 | idDelete(&F); |
| 10572 | idDelete(&monred); |
| 10573 | return pmon; |
| 10574 | } |
| 10575 | } |
| 10576 | ring QQ_ring = rCopy0(currRing,FALSE); |
| 10577 | nKillChar(QQ_ring->cf); |
| 10578 | QQ_ring->cf = nInitChar(n_Q, NULL); |
| 10579 | rComplete(QQ_ring,1); |
| 10580 | QQ_ring = rAssure_c_dp(QQ_ring); |
| 10581 | rChangeCurrRing(QQ_ring); |
| 10582 | nMapFunc nMap = n_SetMap(origR->cf, QQ_ring->cf); |
| 10583 | ideal II = idInit(IDELEMS(F)+idelemQ+2,id_RankFreeModule(F, origR)); |
| 10584 | for(int i = 0, j = 0; i<IDELEMS(F); i++) |
| 10585 | II->m[j++] = prMapR(F->m[i], nMap, origR, QQ_ring); |
| 10586 | for(int i = 0, j = IDELEMS(F); i<idelemQ; i++) |
| 10587 | II->m[j++] = prMapR(Q->m[i], nMap, origR, QQ_ring); |
| 10588 | ideal one = kStd(II, NULL, isNotHomog, NULL); |
| 10589 | idSkipZeroes(one); |
| 10590 | if(idIsConstant(one)) |
| 10591 | { |
| 10592 | //one should be <1> |
no test coverage detected