Changeset e20214 in git
 Timestamp:
 Jul 13, 1999, 5:06:52 PM (24 years ago)
 Branches:
 (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
 Children:
 2eeb7d1017a21755a73976d7e957ee1db6cc06b2
 Parents:
 0a5f342e03dda534e299aecb4e831f39b5569cd7
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Singular/maps.cc
r0a5f34 re20214 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: maps.cc,v 1.1 4 19990309 12:28:49 obachmanExp $ */4 /* $Id: maps.cc,v 1.15 19990713 15:06:52 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT  the mapping of polynomials to other rings … … 22 22 #include "maps.h" 23 23 24 #define MAX_MAP_DEG 3224 #define MAX_MAP_DEG 128 25 25 26 26 /*2 … … 37 37 } 38 38 39 40 /*2 41 * return the image of var(v)^pExp, where var(v) maps to p 42 */ 43 poly maEvalVariable(poly p, int v,int pExp,matrix s) 44 { 45 if (pExp==1) 46 return pCopy(p); 47 48 poly res; 49 50 if((s!=NULL)&&(pExp<MAX_MAP_DEG)) 51 { 52 int j=2; 53 poly p0=p; 54 // find starting point 55 if(MATELEM(s,v,1)==NULL) 56 { 57 MATELEM(s,v,1)=pCopy(p/*theMap>m[v1]*/); 58 } 59 else 60 { 61 while((j<=pExp)&&(MATELEM(s,v,j)!=NULL)) 62 { 63 j++; 64 } 65 p0=MATELEM(s,v,j1); 66 } 67 // multiply 68 for(;j<=pExp;j++) 69 { 70 p0=MATELEM(s,v,j)=pMult(pCopy(p0/*MATELEM(s,v,j1)*/), 71 pCopy(p/*theMap>m[v1]*/)); 72 } 73 res=pCopy(p0/*MATELEM(s,v,pExp)*/); 74 } 75 else //if ((p>next!=NULL)&&(p>next>next==NULL)) 76 { 77 res=pPower(pCopy(p),pExp); 78 } 79 return res; 80 } 81 82 poly maEvalMonom(map theMap, poly p,ring preimage_r,matrix s) 83 { 84 poly q=pOne(); 85 pSetCoeff(q,nMap(pGetCoeff(p))); 86 87 int i; 88 for(i=preimage_r>N; i>0; i) 89 { 90 int pExp=pRingGetExp(preimage_r, p,i); 91 if (pExp != 0) 92 { 93 if (theMap>m[i1]!=NULL) 94 { 95 poly p1=theMap>m[i1]; 96 poly pp=maEvalVariable(p1,i,pExp,s); 97 q = pMult(q,pp); 98 } 99 else 100 { 101 pDelete(&q); 102 break; 103 } 104 } 105 } 106 int modulComp = pRingGetComp(preimage_r, p); 107 if (q!=NULL) pSetCompP(q,modulComp); 108 return q; 109 } 110 39 111 poly maEval(map theMap, poly p,ring preimage_r,matrix s) 40 112 { 41 poly result = NULL,q,pp; 42 int i,modulComp; 43 int varnum = preimage_r>N; 44 45 // for(i=1; i<=varnum; i++) 113 poly result = NULL; 114 int i; 115 116 // for(i=1; i<=preimage_r>N; i++) 46 117 // { 47 118 // pTest(theMap>m[i1]); 48 119 // } 49 while (p!=NULL) 50 { 51 q=pOne(); 52 pSetCoeff(q,nMap(pGetCoeff(p))); 53 54 for(i=1; i<=varnum; i++) 55 { 56 int pExp=pRingGetExp(preimage_r, p,i); 57 if (pExp != 0) 58 { 59 if (theMap>m[i1]!=NULL) 60 { 61 poly p1=theMap>m[i1]; 62 if((s!=NULL)&&(pExp<(MAX_MAP_DEG*2))) 63 { 64 int e=min(pExp,MAX_MAP_DEG); 65 if(MATELEM(s,i,e)!=NULL) 66 pp=pCopy(MATELEM(s,i,e)); 67 else 68 { 69 int j=2; 70 poly p0=p1; 71 if(MATELEM(s,i,1)==NULL) 72 { 73 MATELEM(s,i,1)=pCopy(p1/*theMap>m[i1]*/); 74 } 75 else 76 { 77 while((j<=e)&&(MATELEM(s,i,j)!=NULL)) 78 { 79 j++; 80 } 81 p0=MATELEM(s,i,j1); 82 } 83 for(;j<=e;j++) 84 { 85 p0=MATELEM(s,i,j)=pMult(pCopy(p0/*MATELEM(s,i,j1)*/), 86 pCopy(p1/*theMap>m[i1]*/)); 87 } 88 pp=pCopy(p0/*MATELEM(s,i,e)*/); 89 } 90 while(e!=pExp/*pRingGetExp(preimage_r, p,i)*/) 91 { 92 // e is the current exponent, 93 // MAX_MAP_DEG the max exponent in the table 94 // pExp the end exponent 95 pp=pMult(pp,pCopy(MATELEM(s,i,min(MAX_MAP_DEG,pExpe)))); 96 e+=min(MAX_MAP_DEG,pExpe); 97 } 98 } 99 else 100 { 101 pp = pPower(pCopy(p1/*theMap>m[i1]*/),pExp/*pRingGetExp(preimage_r, p,i)*/); 102 } 103 q = pMult(q,pp); 104 } 105 else 106 { 107 pDelete(&q); 108 break; 109 } 110 } 111 } 112 modulComp = pRingGetComp(preimage_r, p); 113 if (q!=NULL) pSetCompP(q,modulComp); 114 result = pAdd(result,q); 115 pIter(p); 116 } 117 if (currRing>minpoly!=NULL) result=pMult(result,pOne()); 120 // while (p!=NULL) 121 // { 122 // poly q=maEvalMonom(theMap,p,preimage_r,s); 123 // result = pAdd(result,q); 124 // pIter(p); 125 // } 126 if (p!=NULL) 127 { 128 int l = pLength(p)1; 129 poly* monoms; 130 if (l>0) 131 { 132 monoms = (poly*) Alloc(l*sizeof(poly)); 133 134 for (i=0; i<l; i++) 135 { 136 monoms[i]=maEvalMonom(theMap,p,preimage_r,s); 137 pIter(p); 138 } 139 } 140 result=maEvalMonom(theMap,p,preimage_r,s); 141 if (l>0) 142 { 143 for(i = l1; i>=0; i) 144 { 145 result=pAdd(result, monoms[i]); 146 } 147 Free((ADDRESS)monoms,l*sizeof(poly)); 148 } 149 if (currRing>minpoly!=NULL) result=pMult(result,pOne()); 150 } 118 151 pTest(result); 119 152 return result; … … 280 313 281 314 void maFindPerm(char **preim_names, int preim_n, char **preim_par, int preim_p, 282 char **names, int n, char **par, int nop, 315 char **names, int n, char **par, int nop, 283 316 int * perm, int *par_perm, int ch) 284 317 {
Note: See TracChangeset
for help on using the changeset viewer.