2 *returns a minimized set of generators of h1 */
| 49 | *returns a minimized set of generators of h1 |
| 50 | */ |
| 51 | ideal idMinBase (ideal h1, ideal *SB) |
| 52 | { |
| 53 | ideal h2, h3,h4,e; |
| 54 | int j,k; |
| 55 | int i,l,ll; |
| 56 | intvec * wth; |
| 57 | BOOLEAN homog; |
| 58 | if(rField_is_Ring(currRing)) |
| 59 | { |
| 60 | WarnS("minbase applies only to the local or homogeneous case over coefficient fields"); |
| 61 | e=idCopy(h1); |
| 62 | return e; |
| 63 | } |
| 64 | homog = idHomModule(h1,currRing->qideal,&wth); |
| 65 | if (rHasGlobalOrdering(currRing)) |
| 66 | { |
| 67 | if(!homog) |
| 68 | { |
| 69 | WarnS("minbase applies only to the local or homogeneous case over coefficient fields"); |
| 70 | e=idCopy(h1); |
| 71 | return e; |
| 72 | } |
| 73 | else |
| 74 | { |
| 75 | ideal re=kMin_std(h1,currRing->qideal,(tHomog)homog,&wth,h2,NULL,0,3); |
| 76 | idDelete(&re); |
| 77 | return h2; |
| 78 | } |
| 79 | } |
| 80 | e=idInit(1,h1->rank); |
| 81 | if (idIs0(h1)) |
| 82 | { |
| 83 | return e; |
| 84 | } |
| 85 | h2 = kStd(h1,currRing->qideal,isNotHomog,NULL); |
| 86 | if (SB!=NULL) *SB=h2; |
| 87 | h3 = idMaxIdeal(1); |
| 88 | h4=idMult(h2,h3); |
| 89 | idDelete(&h3); |
| 90 | h3=kStd(h4,currRing->qideal,isNotHomog,NULL); |
| 91 | k = IDELEMS(h3); |
| 92 | while ((k > 0) && (h3->m[k-1] == NULL)) k--; |
| 93 | j = -1; |
| 94 | l = IDELEMS(h2); |
| 95 | while ((l > 0) && (h2->m[l-1] == NULL)) l--; |
| 96 | for (i=l-1; i>=0; i--) |
| 97 | { |
| 98 | if (h2->m[i] != NULL) |
| 99 | { |
| 100 | ll = 0; |
| 101 | while ((ll < k) && ((h3->m[ll] == NULL) |
| 102 | || !pDivisibleBy(h3->m[ll],h2->m[i]))) |
| 103 | ll++; |
| 104 | if (ll >= k) |
| 105 | { |
| 106 | j++; |
| 107 | if (j > IDELEMS(e)-1) |
| 108 | { |
no test coverage detected