Changeset c6a3eb2 in git
- Timestamp:
- Feb 28, 2011, 2:20:22 PM (13 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38077648e7239f98078663eb941c3c979511150a')
- Children:
- 89abbe07ab1f0d917faf8b67ce6eb62994353b25
- Parents:
- 8e45403dd5d584f695e8de3d811c76579d3a7a55
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-02-28 14:20:22+01:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:59:33+01:00
- Location:
- libpolys/polys
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/monomials/maps.cc
r8e45403 rc6a3eb2 7 7 */ 8 8 9 #include <kernel/mod2.h> 10 #include <kernel/options.h> 11 #include <kernel/febase.h> 12 #include <kernel/polys.h> 13 #include <kernel/numbers.h> 14 #include <kernel/ring.h> 15 #include <kernel/ideals.h> 16 #include <kernel/matpol.h> 9 #include <misc/options.h> 10 #include <monomials/p_polys.h> 11 #include <coeffs/coeffs.h> 12 #include <coeffs/numbers.h> 13 #include <monomials/ring.h> 14 #include <simpleideals.h> 17 15 #include <omalloc/omalloc.h> 18 #include <kernel/kstd1.h> 19 #include <kernel/longtrans.h> 20 #include <kernel/maps.h> 21 #include <kernel/prCopy.h> 16 #include <polys/prCopy.h> 17 #include <polys/ext_fields/longtrans.h> 18 #include <polys/monomials/maps.h> 22 19 23 20 #ifdef HAVE_PLURAL … … 36 33 * copy a map 37 34 */ 38 map maCopy(map theMap )35 map maCopy(map theMap, const ring r) 39 36 { 40 37 int i; 41 38 map m=(map)idInit(IDELEMS(theMap),0); 42 39 for (i=IDELEMS(theMap)-1; i>=0; i--) 43 m->m[i] = p Copy(theMap->m[i]);40 m->m[i] = p_Copy(theMap->m[i],r); 44 41 m->preimage=omStrDup(theMap->preimage); 45 42 return m; … … 50 47 * return the image of var(v)^pExp, where var(v) maps to p 51 48 */ 52 poly maEvalVariable(poly p, int v,int pExp, matrix s)49 poly maEvalVariable(poly p, int v,int pExp, ideal s, const ring dst_r) 53 50 { 54 51 if (pExp==1) 55 return p Copy(p);52 return p_Copy(p,dst_r); 56 53 57 54 poly res; … … 64 61 if(MATELEM(s,v,1)==NULL) 65 62 { 66 MATELEM(s,v,1)=p Copy(p/*theMap->m[v-1]*/);63 MATELEM(s,v,1)=p_Copy(p/*theMap->m[v-1]*/,dst_r); 67 64 } 68 65 else … … 77 74 for(;j<=pExp;j++) 78 75 { 79 p0=MATELEM(s,v,j)=pp Mult_qq(p0, p);80 p Normalize(p0);81 } 82 res=p Copy(p0/*MATELEM(s,v,pExp)*/);76 p0=MATELEM(s,v,j)=pp_Mult_qq(p0, p,dst_r); 77 p_Normalize(p0, dst_r); 78 } 79 res=p_Copy(p0/*MATELEM(s,v,pExp)*/,dst_r); 83 80 } 84 81 else //if ((p->next!=NULL)&&(p->next->next==NULL)) 85 82 { 86 res=p Power(pCopy(p),pExp);83 res=p_Power(p_Copy(p,dst_r),pExp,dst_r); 87 84 } 88 85 return res; 89 86 } 90 87 91 static poly maEvalMonom(map theMap, poly p,ring preimage_r,matrix s, nMapFunc nMap) 92 { 93 poly q=pNSet(nMap(pGetCoeff(p))); 88 static poly maEvalMonom(map theMap, poly p,ring preimage_r, ideal s, 89 nMapFunc nMap, const ring dst_r) 90 { 91 poly q=p_NSet(nMap(pGetCoeff(p),preimage_r->cf,dst_r->cf),dst_r); 94 92 95 93 int i; … … 102 100 { 103 101 poly p1=theMap->m[i-1]; 104 poly pp=maEvalVariable(p1,i,pExp,s );105 q = p Mult(q,pp);102 poly pp=maEvalVariable(p1,i,pExp,s,dst_r); 103 q = p_Mult_q(q,pp,dst_r); 106 104 } 107 105 else 108 106 { 109 p Delete(&q);107 p_Delete(&q,dst_r); 110 108 break; 111 109 } … … 113 111 } 114 112 int modulComp = p_GetComp( p,preimage_r); 115 if (q!=NULL) p SetCompP(q,modulComp);113 if (q!=NULL) p_SetCompP(q,modulComp,dst_r); 116 114 return q; 117 115 } 118 116 119 poly maEval(map theMap, poly p,ring preimage_r,nMapFunc nMap, matrix s)117 poly maEval(map theMap, poly p,ring preimage_r,nMapFunc nMap, ideal s, const ring dst_r) 120 118 { 121 119 poly result = NULL; … … 142 140 for (i=0; i<l; i++) 143 141 { 144 monoms[i]=maEvalMonom(theMap,p,preimage_r,s, nMap );142 monoms[i]=maEvalMonom(theMap,p,preimage_r,s, nMap, dst_r); 145 143 pIter(p); 146 144 } 147 145 } 148 result=maEvalMonom(theMap,p,preimage_r,s, nMap );146 result=maEvalMonom(theMap,p,preimage_r,s, nMap, dst_r); 149 147 if (l>0) 150 148 { 151 149 for(i = l-1; i>=0; i--) 152 150 { 153 result=p Add(result, monoms[i]);151 result=p_Add_q(result, monoms[i], dst_r); 154 152 } 155 153 omFreeSize((ADDRESS)monoms,l*sizeof(poly)); 156 154 } 157 if (currRing->minpoly!=NULL) result=pMinPolyNormalize(result); 158 } 159 pTest(result); 155 if (dst_r->minpoly!=NULL) result=pMinPolyNormalize(result); 156 } 160 157 return result; 161 158 } … … 166 163 *be carefull: there is no range check for the variables of p 167 164 */ 168 static poly pChangeSizeOfPoly(ring p_ring, poly p,int minvar,int maxvar )165 static poly pChangeSizeOfPoly(ring p_ring, poly p,int minvar,int maxvar, const ring dst_r) 169 166 { 170 167 int i; … … 173 170 174 171 if (p==NULL) return result; 175 else result = p Init();172 else result = p_Init(dst_r); 176 173 resultWorkP = result; 177 174 while (p!=NULL) 178 175 { 179 176 for (i=minvar;i<=maxvar;i++) 180 p SetExp(resultWorkP,i-minvar+1,p_GetExp(p,i,p_ring));181 p SetComp(resultWorkP,p_GetComp(p,p_ring));182 n=n Copy(pGetCoeff(p));183 p SetCoeff(resultWorkP,n);184 p Setm(resultWorkP);177 p_SetExp(resultWorkP,i-minvar+1,p_GetExp(p,i,p_ring),dst_r); 178 p_SetComp(resultWorkP,p_GetComp(p,p_ring),dst_r); 179 n=n_Copy(pGetCoeff(p),dst_r->cf); 180 p_SetCoeff(resultWorkP,n,dst_r); 181 p_Setm(resultWorkP,dst_r); 185 182 pIter(p); 186 183 if (p!=NULL) 187 184 { 188 pNext(resultWorkP) = p Init();185 pNext(resultWorkP) = p_Init(dst_r); 189 186 pIter(resultWorkP); 190 187 } … … 199 196 * (assumes) that both ring have the same coeff.field 200 197 */ 201 ideal maGetPreimage(ring theImageRing, map theMap, ideal id )202 { 203 ring sourcering = currRing;198 ideal maGetPreimage(ring theImageRing, map theMap, ideal id, const ring dst_r) 199 { 200 ring sourcering = dst_r; 204 201 205 202 #ifdef HAVE_PLURAL … … 219 216 ideal temp2; 220 217 221 int imagepvariables = theImageRing->N;222 int N = pVariables+imagepvariables;218 int imagepvariables = rVar(theImageRing); 219 int N = rVar(dst_r)+imagepvariables; 223 220 224 221 ring tmpR; … … 229 226 } 230 227 231 if (n SetMap(theImageRing) != nCopy)228 if (n_SetMap(theImageRing->cf,dst_r->cf) != ndCopyMap) 232 229 { 233 230 Werror("Coefficient fields/rings must be equal"); … … 235 232 } 236 233 237 // change to new ring238 rChangeCurrRing(tmpR);239 234 if (id==NULL) 240 235 j = 0; … … 246 241 for (i=0;i<sourcering->N;i++) 247 242 { 248 q = p ISet(-1);249 p SetExp(q,i+1+imagepvariables,1);250 p Setm(q);243 q = p_ISet(-1,tmpR); 244 p_SetExp(q,i+1+imagepvariables,1,tmpR); 245 p_Setm(q,tmpR); 251 246 if ((i<IDELEMS(theMap)) && (theMap->m[i]!=NULL)) 252 247 { 253 p = pSort(pChangeSizeOfPoly(theImageRing,theMap->m[i],1,imagepvariables)); 254 p=pAdd(p,q); 248 p = p_SortMerge( 249 pChangeSizeOfPoly(theImageRing,theMap->m[i],1,imagepvariables,tmpR), 250 tmpR); 251 p=p_Add_q(p,q,tmpR); 255 252 } 256 253 else … … 263 260 for (i=sourcering->N;i<sourcering->N+j0;i++) 264 261 { 265 temp1->m[i] = p Sort(pChangeSizeOfPoly(theImageRing,266 id->m[i-sourcering->N],1,imagepvariables));262 temp1->m[i] = p_SortMerge(pChangeSizeOfPoly(theImageRing, 263 id->m[i-sourcering->N],1,imagepvariables,tmpR),tmpR); 267 264 } 268 265 for (i=sourcering->N+j0;i<sourcering->N+j;i++) 269 266 { 270 temp1->m[i] = p Sort(pChangeSizeOfPoly(theImageRing,271 272 1,imagepvariables));267 temp1->m[i] = p_SortMerge(pChangeSizeOfPoly(theImageRing, 268 theImageRing->qideal->m[i-sourcering->N-j0], 269 1,imagepvariables,tmpR),tmpR); 273 270 } 274 271 // we ignore here homogenity - may be changed later: 275 272 temp2 = kStd(temp1,NULL,isNotHomog,NULL); 276 id Delete(&temp1);273 id_Delete(&temp1,tmpR); 277 274 for (i=0;i<IDELEMS(temp2);i++) 278 275 { 279 if (pLowVar(temp2->m[i])<imagepvariables) p Delete(&(temp2->m[i]));276 if (pLowVar(temp2->m[i])<imagepvariables) p_Delete(&(temp2->m[i]),tmpR); 280 277 } 281 278 282 279 // let's get back to the original ring 283 rChangeCurrRing(sourcering);280 //rChangeCurrRing(sourcering); 284 281 temp1 = idInit(5,1); 285 282 j = 0; … … 289 286 if (p!=NULL) 290 287 { 291 q = p Sort(pChangeSizeOfPoly(tmpR, p,imagepvariables+1,N));288 q = p_SortMerge(pChangeSizeOfPoly(tmpR, p,imagepvariables+1,N),sourcering); 292 289 if (j>=IDELEMS(temp1)) 293 290 { … … 375 372 * embeds poly p from the subring r into the current ring 376 373 */ 377 poly maIMap(ring r, poly p )374 poly maIMap(ring r, poly p, const ring dst_r) 378 375 { 379 376 /* the simplest case:*/ 380 if(r== currRing) return pCopy(p);381 nMapFunc nMap=n SetMap(r);377 if(r==dst_r) return p_Copy(p,dst_r); 378 nMapFunc nMap=n_SetMap(r->cf,dst_r->cf); 382 379 int *perm=(int *)omAlloc0((r->N+1)*sizeof(int)); 383 380 //int *par_perm=(int *)omAlloc0(rPar(r)*sizeof(int)); 384 381 maFindPerm(r->names,r->N, r->parameter, r->P, 385 currRing->names,currRing->N,currRing->parameter, currRing->P,386 perm,NULL, currRing->ch);387 poly res=p PermPoly(p,perm,r, nMap /*,par_perm,rPar(r)*/);382 dst_r->names,dst_r->N,dst_r->parameter, dst_r->P, 383 perm,NULL, dst_r->ch); 384 poly res=p_PermPoly(p,perm,r,dst_r, nMap /*,par_perm,rPar(r)*/); 388 385 omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int)); 389 386 //omFreeSize((ADDRESS)par_perm,rPar(r)*sizeof(int)); … … 464 461 // This is a very dirty way to cancel monoms whose number equals the 465 462 // MinPoly 466 poly pMinPolyNormalize(poly p )467 { 468 number one = n Init(1);463 poly pMinPolyNormalize(poly p, const ring r) 464 { 465 number one = n_Init(1,r->cf); 469 466 spolyrec rp; 470 467 … … 474 471 { 475 472 // this returns 0, if p == MinPoly 476 number product = n Mult(pGetCoeff(p), one);477 if ((product == NULL)||(n IsZero(product)))478 { 479 p LmDelete(&p);473 number product = n_Mult(pGetCoeff(p), one,r->cf); 474 if ((product == NULL)||(n_IsZero(product,r->cf))) 475 { 476 p_LmDelete(&p,r); 480 477 } 481 478 else 482 479 { 483 p SetCoeff(p, product);480 p_SetCoeff(p, product,r); 484 481 pNext(q) = p; 485 482 q = p; -
libpolys/polys/monomials/maps.h
r8e45403 rc6a3eb2 16 16 typedef struct sip_smap * map; 17 17 18 poly maEval(map theMap, poly p, ring dst_ring, nMapFunc nMap ); //,matrixs=NULL);19 map maCopy(map theMap, ring dst_ring);18 poly maEval(map theMap, poly p, ring dst_ring, nMapFunc nMap, ideal s=NULL); 19 map maCopy(map theMap, const ring dst_ring); 20 20 21 21 ideal maGetPreimage(ring theImageRing, map theMap,ideal id); -
libpolys/polys/monomials/p_polys.cc
r8e45403 rc6a3eb2 2885 2885 2886 2886 /*2 2887 * handle memory request for sets of polynomials (ideals) 2888 * l is the length of *p, increment is the difference (may be negative) 2889 */ 2890 void pEnlargeSet(poly* *p, int l, int increment) 2891 { 2892 poly* h; 2893 2894 h=(poly*)omReallocSize((poly*)*p,l*sizeof(poly),(l+increment)*sizeof(poly)); 2895 if (increment>0) 2896 { 2897 //for (i=l; i<l+increment; i++) 2898 // h[i]=NULL; 2899 memset(&(h[l]),0,increment*sizeof(poly)); 2900 } 2901 *p=h; 2902 } 2903 2904 /*2 2887 2905 *returns a re-ordered copy of a polynomial, with permutation of the variables 2888 2906 */ -
libpolys/polys/monomials/p_polys.h
r8e45403 rc6a3eb2 339 339 inline poly pLast(poly a) { int l; return pLast(a, l);} 340 340 static inline poly pReverse(poly p); 341 void pEnlargeSet(poly**p, int length, int increment); 341 342 342 343 … … 381 382 long pLDeg1c_WFirstTotalDegree(poly p,int *l, ring r); 382 383 BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r); 384 385 long p_Deg(poly a, const ring r); 383 386 /*************************************************************** 384 387 * -
libpolys/polys/monomials/ring.cc
r8e45403 rc6a3eb2 3379 3379 static void rOptimizeLDeg(ring r) 3380 3380 { 3381 if (r->pFDeg == p Deg)3381 if (r->pFDeg == p_Deg) 3382 3382 { 3383 3383 if (r->pLDeg == pLDeg1) … … 3520 3520 3521 3521 if (rOrd_is_Totaldegree_Ordering(r) || rOrd_is_WeightedDegree_Ordering(r)) 3522 r->pFDeg = p Deg;3522 r->pFDeg = p_Deg; 3523 3523 3524 3524 r->pFDegOrig = r->pFDeg; -
libpolys/polys/monomials/ring.h
r8e45403 rc6a3eb2 55 55 int ncols; 56 56 #define IDELEMS(i) ((i)->ncols) 57 #define MATCOLS(i) ((i)->ncols) 58 #define MATROWS(i) ((i)->nrows) 59 #define MATELEM(mat,i,j) ((mat)->m)[MATCOLS((mat)) * ((i)-1) + (j)-1] 57 60 }; 58 61 typedef struct sip_sideal * ideal; 62 63 struct sip_smap 64 { 65 poly *m; 66 char *preimage; 67 int nrows; 68 int ncols; 69 }; 70 typedef struct sip_smap * map; 71 59 72 typedef enum 60 73 { -
libpolys/polys/polys.h
r8e45403 rc6a3eb2 273 273 inline void wrp(poly p) {p_wrp(p, currRing, currRing);} 274 274 275 void pEnlargeSet(polyset *p, int length, int increment);276 275 #define pISet(i) p_ISet(i,currRing) 277 276 #define pNSet(n) p_NSet(n,currRing) -
libpolys/polys/polys1.cc
r8e45403 rc6a3eb2 33 33 34 34 35 /*236 * handle memory request for sets of polynomials (ideals)37 * l is the length of *p, increment is the difference (may be negative)38 */39 void pEnlargeSet(polyset *p, int l, int increment)40 {41 polyset h;42 43 h=(polyset)omReallocSize((poly*)*p,l*sizeof(poly),(l+increment)*sizeof(poly));44 if (increment>0)45 {46 //for (i=l; i<l+increment; i++)47 // h[i]=NULL;48 memset(&(h[l]),0,increment*sizeof(poly));49 }50 *p=h;51 }52 53 35 poly ppJet(poly p, int m) 54 36 {
Note: See TracChangeset
for help on using the changeset viewer.