! used for GB over ZZ: final reduction by constant elements background: any known constant element of ideal suppresses intermediate coefficient swell and beautifies output */
| 10863 | intermediate coefficient swell and beautifies output |
| 10864 | */ |
| 10865 | void finalReduceByMon(kStrategy strat) |
| 10866 | { |
| 10867 | assume(strat->tl<0); /* can only be called with no elements in T: |
| 10868 | i.e. after exitBuchMora */ |
| 10869 | /* do not use strat->S, strat->sl as they may be out of sync*/ |
| 10870 | if(!nCoeff_is_Z(currRing->cf)) |
| 10871 | return; |
| 10872 | poly p,pp; |
| 10873 | for(int j = 0; j<IDELEMS(strat->Shdl); j++) |
| 10874 | { |
| 10875 | if((strat->Shdl->m[j]!=NULL)&&(pNext(strat->Shdl->m[j]) == NULL)) |
| 10876 | { |
| 10877 | for(int i = 0; i<IDELEMS(strat->Shdl); i++) |
| 10878 | { |
| 10879 | if((i != j) && (strat->Shdl->m[i] != NULL)) |
| 10880 | { |
| 10881 | p = strat->Shdl->m[i]; |
| 10882 | while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p) |
| 10883 | #if HAVE_SHIFTBBA |
| 10884 | || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p)) |
| 10885 | #endif |
| 10886 | )) |
| 10887 | { |
| 10888 | number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf); |
| 10889 | if (!nEqual(dummy,p->coef)) |
| 10890 | { |
| 10891 | if (nIsZero(dummy)) |
| 10892 | { |
| 10893 | nDelete(&dummy); |
| 10894 | pLmDelete(&strat->Shdl->m[i]); |
| 10895 | p=strat->Shdl->m[i]; |
| 10896 | } |
| 10897 | else |
| 10898 | { |
| 10899 | p_SetCoeff(p,dummy,currRing); |
| 10900 | break; |
| 10901 | } |
| 10902 | } |
| 10903 | else |
| 10904 | { |
| 10905 | nDelete(&dummy); |
| 10906 | break; |
| 10907 | } |
| 10908 | } |
| 10909 | if (p!=NULL) |
| 10910 | { |
| 10911 | pp = pNext(p); |
| 10912 | while(pp != NULL) |
| 10913 | { |
| 10914 | if(pLmDivisibleBy(strat->Shdl->m[j], pp) |
| 10915 | #if HAVE_SHIFTBBA |
| 10916 | || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp)) |
| 10917 | #endif |
| 10918 | ) |
| 10919 | { |
| 10920 | number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf); |
| 10921 | if (!nEqual(dummy,pp->coef)) |
| 10922 | { |
no test coverage detected