Changeset e744d9 in git for Singular/dyn_modules/gfanlib/initial.cc
- Timestamp:
- Jul 17, 2014, 12:28:18 PM (9 years ago)
- Branches:
- (u'spielwiese', 'ec94ef7a30b928574c0c3daf41f6804dff5f6b69')
- Children:
- eb836ceccfffe01622457439ed104bca800bc101
- Parents:
- 3c0aa5079c417e92fdfaa03c1d87d73f5b365291
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2014-07-17 12:28:18+02:00
- git-committer:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:03+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/gfanlib/initial.cc
r3c0aa5 re744d9 23 23 d += p_GetExp(p,i+1,r)*w[i].toInt(); 24 24 } 25 return d; 26 } 27 28 /*** 29 * Computes the weighted multidegree of the leading term of p with respect to W. 30 * The weighted multidegree is a vector whose i-th entry is the weighted degree 31 * with respect to the i-th row vector of W. 32 **/ 33 gfan::ZVector WDeg(const poly p, const ring r, const gfan::ZMatrix W) 34 { 35 gfan::ZVector d = gfan::ZVector(W.getHeight()); 36 for (int i=0; i<W.getHeight(); i++) 37 d[i] = wDeg(p,r,W[i]); 25 38 return d; 26 39 } … … 81 94 82 95 /*** 83 * Returns the first terms of p of same weighted degree under w, 84 * this is not necessarily the initial form of p with respect to w! 96 * Returns the initial form of p with respect to w 85 97 **/ 86 98 poly initial(const poly p, const ring r, const gfan::ZVector w) 87 99 { 88 int n = r->N;89 int* expv = (int*) omAlloc(n*sizeof(int));90 100 poly q0 = p_Head(p,r); 91 101 poly q1 = q0; … … 93 103 for (poly currentTerm = p->next; currentTerm; pIter(currentTerm)) 94 104 { 95 if (wDeg(currentTerm,r,w)==d) 105 long e = wDeg(currentTerm,r,w); 106 if (e>d) 96 107 { 97 pNext(q1) = p_Head(currentTerm,r); 98 pIter(q1); 108 p_Delete(&q0,r); 109 q0 = p_Head(p,r); 110 q1 = q0; 111 d = e; 99 112 } 100 } 101 omFreeSize(expv,n*sizeof(int)); 113 else 114 if (e==d) 115 { 116 pNext(q1) = p_Head(currentTerm,r); 117 pIter(q1); 118 } 119 } 102 120 return q0; 103 121 } … … 105 123 /*** 106 124 * Runs the above procedure over all generators of an ideal. 125 * Returns the initial ideal if and only if the weight is in the maximal Groebner cone 126 * of the current ordering. 107 127 **/ 108 128 ideal initial(const ideal I, const ring r, const gfan::ZVector w) … … 113 133 return inI; 114 134 } 135 136 137 /*** 138 * Returns the initial form of p with respect to W, 139 * i.e. the sum over all terms of p with highest multidegree with respect to W. 140 **/ 141 poly initial(const poly p, const ring r, const gfan::ZMatrix W) 142 { 143 int n = rVar(r); 144 poly q0 = p_Head(p,r); 145 poly q1 = q0; 146 gfan::ZVector d = WDeg(p,r,W); 147 for (poly currentTerm = p->next; currentTerm; pIter(currentTerm)) 148 { 149 gfan::ZVector e = WDeg(currentTerm,r,W); 150 if (d<e) 151 { 152 p_Delete(&q0,r); 153 q0 = p_Head(p,r); 154 q1 = q0; 155 d = e; 156 } 157 else 158 if (d==e) 159 { 160 pNext(q1) = p_Head(currentTerm,r); 161 pIter(q1); 162 } 163 } 164 return q0; 165 } 166 167 /*** 168 * Runs the above procedure over all generators of an ideal. 169 * Returns the initial ideal if and only if the weight is in the maximal Groebner cone 170 * of the current ordering. 171 **/ 172 ideal initial(const ideal I, const ring r, const gfan::ZMatrix W) 173 { 174 int k = idSize(I); ideal inI = idInit(k); 175 for (int i=0; i<k; i++) 176 inI->m[i] = initial(I->m[i],r,W); 177 return inI; 178 } 179 115 180 116 181 #ifndef NDEBUG
Note: See TracChangeset
for help on using the changeset viewer.