Changeset 462f5d in git
- Timestamp:
- Aug 2, 2016, 2:20:33 PM (7 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- 39b90e9373410f209be536692f8ad127c852cc0e
- Parents:
- 2ca98b322f5cd4132f63aa412234febf9a402043
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/extra.cc
r2ca98b3 r462f5d 310 310 char tbuf[MAXPATHLEN]; 311 311 char *s=omFindExec((char*)h->Data(),tbuf); 312 312 if(s==NULL) s=(char*)""; 313 313 res->data=(void *)omStrDup(s); 314 314 res->rtyp=STRING_CMD; … … 1098 1098 h=h->next; 1099 1099 int lVblock=(int)((long)(h->Data())); 1100 if (sh<0) 1101 { 1102 WerrorS("negative shift for pLPshift"); 1103 return TRUE; 1104 } 1105 int L = pmLastVblock(p,lVblock); 1106 if (L+sh-1 > uptodeg) 1107 { 1108 WerrorS("pLPshift: too big shift requested\n"); 1109 return TRUE; 1110 } 1100 1111 res->data = pLPshift(p,sh,uptodeg,lVblock); 1101 1112 res->rtyp = POLY_CMD; … … 3376 3387 } 3377 3388 else 3378 3379 3380 3381 3389 { 3390 WerrorS("expected `system(\"HNF\",<matrix|intmat|bigintmat>)`"); 3391 return TRUE; 3392 } 3382 3393 } 3383 3394 else return TRUE; -
kernel/GBEngine/shiftgb.cc
r2ca98b3 r462f5d 47 47 /* assume shift takes place, shifts the poly p by sh */ 48 48 /* p is like TObject: lm in currRing = r, tail in tailRing */ 49 /* copies p */ 49 50 50 51 if (p==NULL) return(p); … … 58 59 59 60 poly q = NULL; 60 poly s = p_mLPshift(p, sh, uptodeg, lV, r); // lm in currRing 61 poly s = p_mLPshift(p_Head(p,r), sh, uptodeg, lV, r); // lm in currRing 62 /* pNext(s) will be fixed below */ 61 63 poly pp = pNext(p); 62 64 63 65 while (pp != NULL) 64 66 { 65 q = p_Add_q(q, p_mLPshift(pp,sh,uptodeg,lV,strat->tailRing),strat->tailRing);67 poly h=p_mLPshift(p_Head(pp,strat->tailRing),sh,uptodeg,lV,strat->tailRing); 66 68 pIter(pp); 69 70 q = p_Add_q(q, h,strat->tailRing); 67 71 } 68 72 pNext(s) = q; … … 71 75 } 72 76 73 74 77 poly p_LPshift(poly p, int sh, int uptodeg, int lV, const ring r) 75 78 { … … 78 81 79 82 /* assume sh and uptodeg agree TODO check */ 80 81 if (p==NULL) return(p); 83 assume(sh>=0); 84 82 85 if (sh == 0) return(p); /* the zero shift */ 83 86 84 87 poly q = NULL; 85 poly pp = p; // do not take copies88 poly pp = p; 86 89 while (pp!=NULL) 87 90 { 88 q = p_Add_q(q, p_mLPshift(pp,sh,uptodeg,lV,r),r);91 poly h=pp; 89 92 pIter(pp); 93 pNext(h)=NULL; 94 h=p_mLPshift(h,sh,uptodeg,lV,r); 95 q = p_Add_q(q, h,r); 90 96 } 91 97 return(q); … … 98 104 if (sh == 0) return(p); /* the zero shift */ 99 105 100 if (sh < 0 ) 101 { 102 #ifdef PDEBUG 103 PrintS("pmLPshift: negative shift requested\n"); 104 #endif 105 return(NULL); /* violation, 2check */ 106 } 107 106 assume(sh>=0); 108 107 int L = p_mLastVblock(p,lV,r); 109 if (L+sh-1 > uptodeg) 110 { 111 #ifdef PDEBUG 112 PrintS("p_mLPshift: too big shift requested\n"); 113 #endif 114 return(NULL); /* violation, 2check */ 115 } 108 assume(L+sh-1<=uptodeg); 109 116 110 int *e=(int *)omAlloc0((r->N+1)*sizeof(int)); 117 111 int *s=(int *)omAlloc0((r->N+1)*sizeof(int)); … … 123 117 for (j=1; j<= L*lV ; j++) 124 118 { 119 assume(e[j]<=1); 125 120 if (e[j]==1) 126 121 { 122 assume(j + (sh*lV)<=r->N); 127 123 s[j + (sh*lV)] = e[j]; /* actually 1 */ 128 #ifdef PDEBUG 129 omCheckAddr(s); 130 #endif 131 } 132 #ifdef PDEBUG 133 else 134 { 135 if (e[j]!=0) 136 { 137 // Print("p_mLPshift: ex[%d]=%d\n",j,e[j]); 138 } 139 } 140 #endif 141 } 142 poly m = p_One(r); 143 p_SetExpV(m,s,r); 124 } 125 } 126 p_SetExpV(p,s,r); 144 127 freeT(e, r->N); 145 128 freeT(s, r->N); … … 148 131 // number c = pGetCoeff(p); 149 132 // p_SetCoeff0(m,p_GetCoeff(p,r),r); 150 p_SetComp(m,p_GetComp(p,r),r); // component is preserved151 p_SetCoeff0(m,n_Copy(p_GetCoeff(p,r),r->cf),r); // coeff is preserved152 return(m);153 }154 155 poly pLPshift(poly p, int sh, int uptodeg, int lV)156 {157 /* assume shift takes place */158 /* shifts the poly p by sh */159 /* deletes p */160 161 /* assume sh and uptodeg agree */162 163 if (sh == 0) return(p); /* the zero shift */164 165 poly q = NULL;166 poly pp = p;167 while (pp!=NULL)168 {169 poly h=pp;170 pIter(pp);171 pNext(h)=NULL;172 h=pmLPshift(h,sh,uptodeg,lV);173 q = p_Add_q(q, h,currRing);174 }175 return(q);176 }177 178 poly pmLPshift(poly p, int sh, int uptodeg, int lV)179 {180 /* TODO: use a shortcut with p_ version */181 /* pm is a monomial */182 183 if (sh == 0) return(p); /* the zero shift */184 185 if (sh < 0 )186 {187 #ifdef PDEBUG188 PrintS("pmLPshift: negative shift requested\n");189 #endif190 return(NULL); /* violation, 2check */191 }192 193 int L = pmLastVblock(p,lV);194 if (L+sh-1 > uptodeg)195 {196 #ifdef PDEBUG197 PrintS("pmLPshift: too big shift requested\n");198 #endif199 return(NULL); /* violation, 2check */200 }201 int *e=(int *)omAlloc0((currRing->N+1)*sizeof(int));202 int *s=(int *)omAlloc0((currRing->N+1)*sizeof(int));203 pGetExpV(p,e);204 int j;205 for (j=1; j<=currRing->N; j++)206 {207 if (e[j]==1)208 {209 s[j + (sh*lV)] = e[j]; /* actually 1 */210 }211 }212 pSetExpV(p,s);213 /* pSetm(m); */ /* done in the pSetExpV */214 freeT(e, currRing->N);215 freeT(s, currRing->N);216 133 return(p); 217 }218 219 int pLastVblock(poly p, int lV)220 {221 /* returns the number of maximal block */222 /* appearing among the monomials of p */223 /* the 0th block is the 1st one */224 poly q = p; //p_Copy(p,currRing); /* need it ? */225 int ans = 0;226 int ansnew = 0;227 while (q!=NULL)228 {229 ansnew = pmLastVblock(q,lV);230 ans = si_max(ans,ansnew);231 pIter(q);232 }233 /* do not need to delete q */234 return(ans);235 }236 237 int pmLastVblock(poly p, int lV)238 {239 /* for a monomial p, returns the number of the last block */240 /* where a nonzero exponent is sitting */241 if (pIsConstantPoly(p))242 {243 return(int(0));244 }245 int *e=(int *)omAlloc0((currRing->N+1)*sizeof(int));246 pGetExpV(p,e);247 int j,b;248 j = currRing->N;249 while ( (!e[j]) && (j>=1) ) j--;250 freeT(e, currRing->N);251 if (j==0)252 {253 #ifdef PDEBUG254 PrintS("pmLastVblock: unexpected zero exponent vector\n");255 #endif256 return(j);257 }258 b = (int)(j/lV) + 1; /* the number of the block, >=1 */259 return (b);260 134 } 261 135 … … 288 162 /* appearing among the monomials of p */ 289 163 /* the 0th block is the 1st one */ 290 poly q = p; //p_Copy(p,currRing); /* need it ? */164 poly q = p; 291 165 int ans = 0; 292 166 int ansnew = 0; … … 297 171 pIter(q); 298 172 } 299 /* do not need to delete q */300 173 return(ans); 301 174 } … … 314 187 j = r->N; 315 188 while ( (!e[j]) && (j>=1) ) j--; 316 if (j==0) 317 { 318 #ifdef PDEBUG 319 PrintS("pmLastVblock: unexpected zero exponent vector\n"); 320 #endif 321 return(j); 322 } 189 freeT(e, r->N); 190 assume(j>0); 323 191 b = (int)((j+lV-1)/lV); /* the number of the block, >=1 */ 324 freeT(e,r->N);325 192 return (b); 326 193 } -
kernel/GBEngine/shiftgb.h
r2ca98b3 r462f5d 27 27 int p_LastVblock(poly p, int lV, const ring r); 28 28 29 poly pLPshift(poly p, int sh, int uptodeg, int lV);30 poly pmLPshift(poly p, int sh, int uptodeg, int lV); 29 //poly pLPshift(poly p, int sh, int uptodeg, int lV); 30 #define pLPshift(p,sh,uptodeg,lV) p_LPshift(p,sh,uptodeg,lV,currRing) 31 31 32 int pLastVblock(poly p, int lV); 33 int pmLastVblock(poly p, int lV); 32 //int pLastVblock(poly p, int lV); 33 #define pLastVblock(p,lV) p_LastVblock(p,lV,currRing) 34 //int pmLastVblock(poly p, int lV); 35 #define pmLastVblock(p,lV) p_mLastVblock(p,lV,currRing) 34 36 35 37 int pFirstVblock(poly p, int lV);
Note: See TracChangeset
for help on using the changeset viewer.