Changeset f34215 in git
- Timestamp:
- Nov 8, 2010, 4:57:06 PM (13 years ago)
- Branches:
- (u'spielwiese', 'd1ba061a762c62d3a25159d8da8b6e17332291fa')
- Children:
- fb4075bf0613cccede0552d05c1b4ee37a7f6530
- Parents:
- a04c5ec2b888d58e53a0701c12400ddca144d53e
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2010-11-08 16:57:06+01:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:55:35+01:00
- Location:
- polys
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
polys/monomials/p_polys.cc
ra04c5e rf34215 1134 1134 } 1135 1135 1136 void p_Split(poly p, poly *h) 1137 { 1138 *h=pNext(p); 1139 pNext(p)=NULL; 1140 } 1141 1142 /*2 1143 * pair has no common factor ? or is no polynomial 1144 */ 1145 BOOLEAN p_HasNotCF(poly p1, poly p2, const ring r) 1146 { 1147 1148 if (p_GetComp(p1,r) > 0 || p_GetComp(p2,r) > 0) 1149 return FALSE; 1150 int i = rVar(r); 1151 loop 1152 { 1153 if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0)) 1154 return FALSE; 1155 i--; 1156 if (i == 0) 1157 return TRUE; 1158 } 1159 } 1160 1161 /*2 1162 * convert monomial given as string to poly, e.g. 1x3y5z 1163 */ 1164 const char * p_Read(const char *st, poly &rc, const ring r) 1165 { 1166 if (r==NULL) { rc=NULL;return st;} 1167 int i,j; 1168 rc = p_Init(r); 1169 const char *s = r->cf->nRead(st,&(rc->coef)); 1170 if (s==st) 1171 /* i.e. it does not start with a coeff: test if it is a ringvar*/ 1172 { 1173 j = r_IsRingVar(s,r); 1174 if (j >= 0) 1175 { 1176 p_IncrExp(rc,1+j,r); 1177 while (*s!='\0') s++; 1178 goto done; 1179 } 1180 } 1181 while (*s!='\0') 1182 { 1183 char ss[2]; 1184 ss[0] = *s++; 1185 ss[1] = '\0'; 1186 j = r_IsRingVar(ss,r); 1187 if (j >= 0) 1188 { 1189 const char *s_save=s; 1190 s = eati(s,&i); 1191 if (((unsigned long)i) > r->bitmask) 1192 { 1193 // exponent to large: it is not a monomial 1194 p_LmDelete(&rc,r); 1195 return s_save; 1196 } 1197 p_AddExp(rc,1+j, (long)i, r); 1198 } 1199 else 1200 { 1201 // 1st char of is not a varname 1202 p_LmDelete(&rc,r); 1203 s--; 1204 return s; 1205 } 1206 } 1207 done: 1208 if (r->cf->nIsZero(pGetCoeff(rc))) p_LmDelete(&rc,r); 1209 else 1210 { 1211 #ifdef HAVE_PLURAL 1212 // in super-commutative ring 1213 // squares of anti-commutative variables are zeroes! 1214 if(rIsSCA(r)) 1215 { 1216 const unsigned int iFirstAltVar = scaFirstAltVar(r); 1217 const unsigned int iLastAltVar = scaLastAltVar(r); 1218 1219 assume(rc != NULL); 1220 1221 for(unsigned int k = iFirstAltVar; k <= iLastAltVar; k++) 1222 if( p_GetExp(rc, k, r) > 1 ) 1223 { 1224 p_LmDelete(&rc, r); 1225 goto finish; 1226 } 1227 } 1228 #endif 1229 1230 p_Setm(rc,r); 1231 } 1232 finish: 1233 return s; 1234 } 1235 poly p_mInit(const char *st, BOOLEAN &ok, const ring r) 1236 { 1237 poly p; 1238 const char *s=p_Read(st,p,r); 1239 if (*s!='\0') 1240 { 1241 if ((s!=st)&&isdigit(st[0])) 1242 { 1243 errorreported=TRUE; 1244 } 1245 ok=FALSE; 1246 p_Delete(&p,r); 1247 return NULL; 1248 } 1249 #ifdef PDEBUG 1250 _p_Test(p,r,PDEBUG); 1251 #endif 1252 ok=!errorreported; 1253 return p; 1254 } 1255 1136 1256 /*2 1137 1257 * returns a polynomial representing the number n -
polys/monomials/p_polys.h
ra04c5e rf34215 1751 1751 return TRUE; 1752 1752 } 1753 void p_Split(poly p, poly * r); /*p => IN(p), r => REST(p) */ 1754 BOOLEAN p_HasNotCF(poly p1, poly p2, const ring r); 1755 poly p_mInit(const char *s, BOOLEAN &ok, const ring r); /* monom s -> poly, interpreter */ 1756 const char * p_Read(const char *s, poly &p,const ring r); /* monom -> poly */ 1753 1757 #endif // P_POLYS_H 1754 1758 -
polys/polys.cc
ra04c5e rf34215 52 52 { 53 53 if (ppNoether!=NULL) pDelete(&ppNoether); 54 //pVariables = r->N;55 54 //pOrdSgn = r->OrdSgn; 56 55 //pFDeg=r->pFDeg; … … 223 222 } 224 223 225 /*2226 * convert monomial given as string to poly, e.g. 1x3y5z227 */228 const char * p_Read(const char *st, poly &rc, const ring r)229 {230 if (r==NULL) { rc=NULL;return st;}231 int i,j;232 rc = p_Init(r);233 const char *s = r->cf->nRead(st,&(rc->coef));234 if (s==st)235 /* i.e. it does not start with a coeff: test if it is a ringvar*/236 {237 j = r_IsRingVar(s,r);238 if (j >= 0)239 {240 p_IncrExp(rc,1+j,r);241 while (*s!='\0') s++;242 goto done;243 }244 }245 while (*s!='\0')246 {247 char ss[2];248 ss[0] = *s++;249 ss[1] = '\0';250 j = r_IsRingVar(ss,r);251 if (j >= 0)252 {253 const char *s_save=s;254 s = eati(s,&i);255 if (((unsigned long)i) > r->bitmask)256 {257 // exponent to large: it is not a monomial258 p_LmDelete(&rc,r);259 return s_save;260 }261 p_AddExp(rc,1+j, (long)i, r);262 }263 else264 {265 // 1st char of is not a varname266 p_LmDelete(&rc,r);267 s--;268 return s;269 }270 }271 done:272 if (r->cf->nIsZero(pGetCoeff(rc))) p_LmDelete(&rc,r);273 else274 {275 #ifdef HAVE_PLURAL276 // in super-commutative ring277 // squares of anti-commutative variables are zeroes!278 if(rIsSCA(r))279 {280 const unsigned int iFirstAltVar = scaFirstAltVar(r);281 const unsigned int iLastAltVar = scaLastAltVar(r);282 283 assume(rc != NULL);284 285 for(unsigned int k = iFirstAltVar; k <= iLastAltVar; k++)286 if( p_GetExp(rc, k, r) > 1 )287 {288 p_LmDelete(&rc, r);289 goto finish;290 }291 }292 #endif293 p_Setm(rc,r);294 }295 finish:296 return s;297 }298 299 224 BOOLEAN _p_Test(poly p, ring r, int level); 300 poly pmInit(const char *st, BOOLEAN &ok)301 {302 poly p;303 const char *s=p_Read(st,p,currRing);304 if (*s!='\0')305 {306 if ((s!=st)&&isdigit(st[0]))307 {308 errorreported=TRUE;309 }310 ok=FALSE;311 pDelete(&p);312 return NULL;313 }314 #ifdef PDEBUG315 _p_Test(p,currRing,PDEBUG);316 #endif317 ok=!errorreported;318 return p;319 }320 225 321 226 /*2 … … 560 465 } 561 466 /*----------end of utilities for syzygies--------------*/ 562 563 /*2564 * pair has no common factor ? or is no polynomial565 */566 BOOLEAN pHasNotCF(poly p1, poly p2)567 {568 569 if (pGetComp(p1) > 0 || pGetComp(p2) > 0)570 return FALSE;571 int i = pVariables;572 loop573 {574 if ((pGetExp(p1, i) > 0) && (pGetExp(p2, i) > 0)) return FALSE;575 i--;576 if (i == 0) return TRUE;577 }578 }579 467 580 468 /*2 -
polys/polys.h
ra04c5e rf34215 11 11 12 12 #include <kernel/p_polys.h> 13 /*14 Some general remarks:15 We divide poly operations into roughly 4 categories:16 Level 2: operations on monomials/polynomials with constant time,17 or operations which are just dispatchers to other18 poly routines19 - implemented in: pInline2.h20 - debugging only if PDEBUG >= 221 - normally inlined, unless PDEBUG >= 2 || NO_INLINE222 Level 1: operations on monomials with time proportional to length23 - implemented in: pInline1.h24 - debugging only if PDEBUG >= 125 - normally inlined, unless PDEBUG >= 1 || NO_INLINE126 Level 0: short operations on polynomials with time proportional to27 length of poly28 - implemented in pInline0.cc29 - debugging if PDEBUG30 - normally _not_ inlined: can be forced with31 #define DO_PINLINE032 #include "pInline0.h"33 Misc : operations on polynomials which do not fit in any of the34 above categories35 - implemented in: polys*.cc36 - never inlined37 - debugging if PDEBUG >= 038 39 You can set PDEBUG on a per-file basis, before including "mod2.h" like40 #define PDEBUG 241 #include "mod2.h"42 However, PDEBUG will only be in effect, if !NDEBUG.43 44 All p_* operations take as last argument a ring45 and are ring independent. Their corresponding p* operations are usually46 just macros to the respective p_*(..,currRing).47 48 */49 13 50 14 /*************************************************************** … … 213 177 *************************************************************************/ 214 178 // sorts p, assumes all monomials in p are different 215 #define pSortMerger(p) p Sort(p)179 #define pSortMerger(p) p_SortMerge(p, currRing) 216 180 #define pSort(p) p_SortMerge(p, currRing) 217 181 … … 256 220 257 221 typedef poly* polyset; 258 extern int pVariables;259 222 extern int pOrdSgn; 260 223 extern BOOLEAN pLexOrder; … … 263 226 264 227 /*-------------predicate on polys ----------------------*/ 265 BOOLEAN pHasNotCF(poly p1, poly p2); /*has no common factor ?*/ 266 void pSplit(poly p, poly * r); /*p => IN(p), r => REST(p) */ 228 #define pHasNotCF(p1,p2) p_HasNotCF(p1,p2,currRing) 229 /*has no common factor ?*/ 230 #define pSplit(p,r) p_Split(p,r) 231 /*p => IN(p), r => REST(p) */ 267 232 268 233 … … 270 235 /*-------------ring management:----------------------*/ 271 236 extern void pSetGlobals(const ring r, BOOLEAN complete = TRUE); 237 272 238 // resets the pFDeg and pLDeg: if pLDeg is not given, it is 273 239 // set to currRing->pLDegOrig, i.e. to the respective LDegProc which 274 240 // only uses pFDeg (and not pDeg, or pTotalDegree, etc). 275 241 // If you use this, make sure your procs does not make any assumptions 276 // on or edering and/or OrdIndex -- otherwise they might return wrong results242 // on ordering and/or OrdIndex -- otherwise they might return wrong results 277 243 // on strat->tailRing 278 244 extern void pSetDegProcs(pFDegProc new_FDeg, pLDegProc new_lDeg = NULL); … … 283 249 #define pSetm(p) p_Setm(p, currRing) 284 250 // TODO: 285 #define pSetmComp pSetm251 #define pSetmComp(p) p_Setm(p, currRing) 286 252 287 253 /*************************************************************** … … 316 282 317 283 318 poly pmInit(const char *s, BOOLEAN &ok); /* monom s -> poly, interpreter */319 const char * p_Read(const char *s, poly &p,const ring r); /* monom -> poly */320 321 284 /*-------------operations on polynomials:------------*/ 322 285 poly pSub(poly a, poly b); 323 286 poly p_Power(poly p, int i, const ring r); 287 #define pmInit(a,b) p_mInit(a,b,currRing) 324 288 325 289 // ----------------- define to enable new p_procs -----*/ -
polys/polys1.cc
ra04c5e rf34215 446 446 return result; 447 447 } 448 449 450 void pSplit(poly p, poly *h)451 {452 *h=pNext(p);453 pNext(p)=NULL;454 }455 456 457 448 458 449 int pMaxCompProc(poly p)
Note: See TracChangeset
for help on using the changeset viewer.