- Timestamp:
- Apr 23, 1998, 8:17:40 PM (26 years ago)
- Branches:
- (u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
- Children:
- 356dc3d199dbfae000f47b6c6d67ce4cffcb5771
- Parents:
- 1d202e7f25871522d0ff3683f371e598b0a40eed
- Location:
- Singular
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ChangeLog
r1d202e r41b473 1 Thu Apr 23 20:16:24 MET DST 1998 hannes 2 * fixed bug in rKill of Q-rings (ring.cc, polys.cc) 1 3 Wed Apr 22 09:42:35 MET DST 1998 hannes 2 4 * several changes concerning stdfac -
Singular/polys.cc
r1d202e r41b473 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1.2 2 1998-04-08 16:04:31Singular Exp $ */4 /* $Id: polys.cc,v 1.23 1998-04-23 18:17:39 Singular Exp $ */ 5 5 6 6 /* … … 34 34 pCompProc pComp0; 35 35 36 int pVariables; // number of variables 36 int pVariables; // number of variables 37 37 int pVariablesW; // number of words of pVariables exponents 38 38 int pVariables1W; // number of words of (pVariables+1) exponents … … 41 41 int pLexSgn; // 1, for lex monom comps; -1 otherwise (exception: ls) 42 42 int pVarOffset; // controls the way exponents are stored in a vector 43 int pVarLowIndex; // lowest exponent index 44 int pVarHighIndex; // highest exponent index 43 int pVarLowIndex; // lowest exponent index 44 int pVarHighIndex; // highest exponent index 45 45 int pVarCompIndex; // Location of component in exponent vector 46 46 … … 116 116 { 117 117 p->Order = (((Order_t)pGetExp(p,1))<<(sizeof(Exponent_t)*8)) 118 + (Order_t)pGetExp(p,2); 118 + (Order_t)pGetExp(p,2); 119 119 } 120 120 … … 157 157 } \ 158 158 while(0) 159 159 160 160 #define Mreturn(d, multiplier) \ 161 161 { \ 162 162 if (d > 0) return multiplier; \ 163 163 return -multiplier; \ 164 } 164 } 165 165 166 166 static int pComp_otEXP_nwONE(poly p1, poly p2); … … 177 177 static int pComp_otEXPCOMP_nwODD(poly p1, poly p2); 178 178 179 179 180 180 // comp_nwONE is used if pVariables1W == 1 and component is compatible 181 181 // with ordering 182 static int pComp_otEXP_nwONE(poly p1, poly p2) 182 static int pComp_otEXP_nwONE(poly p1, poly p2) 183 183 { 184 184 register long d = pGetOrder(p1) - pGetOrder(p2); … … 193 193 // comp_otEXPCOMP_nwONE : pVariables1W == 1, priority is 194 194 // given to exponents, component is incompatible with ordering 195 static int pComp_otEXPCOMP_nwONE(poly p1, poly p2) 195 static int pComp_otEXPCOMP_nwONE(poly p1, poly p2) 196 196 { 197 197 register long d = pGetOrder(p1) - pGetOrder(p2); … … 206 206 // comp_otEXPCOMP_nwONE : pVariables1W == 1, priority is given to component, 207 207 // component is incompatible with ordering 208 static int pComp_otCOMPEXP_nwONE(poly p1, poly p2) 208 static int pComp_otCOMPEXP_nwONE(poly p1, poly p2) 209 209 { 210 210 register long d = pGetComp(p2) - pGetComp(p1); … … 213 213 if (d) Mreturn(d, pOrdSgn); 214 214 _pMonComp_otEXP_nwONE(p1, p2, d, goto NotEqual , return 0); 215 215 216 216 NotEqual: 217 217 Mreturn(d, pLexSgn); … … 219 219 220 220 // comp_nwTWO : pVariables1W == 2 and component is compatible with ordering 221 static int pComp_otEXP_nwTWO(poly p1, poly p2) 221 static int pComp_otEXP_nwTWO(poly p1, poly p2) 222 222 { 223 223 register long d = pGetOrder(p1) - pGetOrder(p2); … … 232 232 // comp_otEXPCOMP_nwTWO : pVariables1W == 2, priority is given to exponents, 233 233 // component is incompatible with ordering 234 static int pComp_otEXPCOMP_nwTWO(poly p1, poly p2) 234 static int pComp_otEXPCOMP_nwTWO(poly p1, poly p2) 235 235 { 236 236 register long d = pGetOrder(p1) - pGetOrder(p2); … … 238 238 if (d) Mreturn(d, pOrdSgn); 239 239 _pMonComp_otEXPCOMP_nwTWO(p1, p2, d, goto NotEqual, return 0); 240 240 241 241 NotEqual: 242 242 Mreturn(d, pLexSgn); … … 245 245 // comp_otEXPCOMP_nwTWO : pVariables1W == 2, priority is given to component, 246 246 // component is incompatible with ordering 247 static int pComp_otCOMPEXP_nwTWO(poly p1, poly p2) 247 static int pComp_otCOMPEXP_nwTWO(poly p1, poly p2) 248 248 { 249 249 register long d = pGetComp(p2) - pGetComp(p1); … … 252 252 if (d) Mreturn(d, pOrdSgn); 253 253 _pMonComp_otEXP_nwTWO(p1, p2, d, goto NotEqual , return 0); 254 254 255 255 NotEqual: 256 256 Mreturn(d, pLexSgn); … … 259 259 // comp_nwEVEN : pVariables1W == 2*i and component is compatible 260 260 // with ordering 261 static int pComp_otEXP_nwEVEN(poly p1, poly p2) 261 static int pComp_otEXP_nwEVEN(poly p1, poly p2) 262 262 { 263 263 register long d = pGetOrder(p1) - pGetOrder(p2); … … 272 272 // comp_otEXPCOMP_nwEVEN : pVariables1W == 2*i, priority is given to exponents, 273 273 // component is incompatible with ordering 274 static int pComp_otEXPCOMP_nwEVEN(poly p1, poly p2) 274 static int pComp_otEXPCOMP_nwEVEN(poly p1, poly p2) 275 275 { 276 276 register long d = pGetOrder(p1) - pGetOrder(p2); … … 285 285 // comp_otEXPCOMP_nwEVEN : pVariables1W == 2*i, priority is given to component, 286 286 // component is incompatible with ordering 287 static int pComp_otCOMPEXP_nwEVEN(poly p1, poly p2) 287 static int pComp_otCOMPEXP_nwEVEN(poly p1, poly p2) 288 288 { 289 289 register long d = pGetComp(p2) - pGetComp(p1); … … 292 292 if (d) Mreturn(d, pOrdSgn); 293 293 _pMonComp_otEXP_nwEVEN(p1, p2, pVariablesW, d, goto NotEqual, return 0); 294 294 295 295 NotEqual: 296 296 Mreturn(d, pLexSgn); … … 299 299 // comp_nwODD : pVariables1W == 2*i and component is compatible 300 300 // with ordering 301 static int pComp_otEXP_nwODD(poly p1, poly p2) 301 static int pComp_otEXP_nwODD(poly p1, poly p2) 302 302 { 303 303 register long d = pGetOrder(p1) - pGetOrder(p2); … … 312 312 // comp_otEXPCOMP_nwODD : pVariables1W == 2*i, priority is given to exponents, 313 313 // component is incompatible with ordering 314 static int pComp_otEXPCOMP_nwODD(poly p1, poly p2) 314 static int pComp_otEXPCOMP_nwODD(poly p1, poly p2) 315 315 { 316 316 register long d = pGetOrder(p1) - pGetOrder(p2); 317 if (d) 317 if (d) 318 318 { 319 319 if (d > 0) return pOrdSgn; 320 320 return -pOrdSgn; 321 321 } 322 322 323 323 _pMonComp_otEXPCOMP_nwODD(p1, p2, pVariables1W, d, goto NotEqual , return 0); 324 324 325 325 NotEqual: 326 326 Mreturn(d, pLexSgn); … … 329 329 // comp_otCOMPEXP_nwODD : pVariables1W == 2*i, priority is given to component, 330 330 // component is incompatible with ordering 331 static int pComp_otCOMPEXP_nwODD(poly p1, poly p2) 331 static int pComp_otCOMPEXP_nwODD(poly p1, poly p2) 332 332 { 333 333 register long d = pGetComp(p2) - pGetComp(p1); … … 336 336 if (d) Mreturn(d, pOrdSgn); 337 337 _pMonComp_otEXP_nwODD(p1, p2, pVariablesW, d, goto NotEqual, return 0); 338 338 339 339 NotEqual: 340 340 Mreturn(d, pLexSgn); … … 924 924 int pTotaldegree(poly p) 925 925 { 926 return pExpQuerSum(p); 926 return pExpQuerSum(p); 927 927 } 928 928 … … 1127 1127 else 1128 1128 { 1129 // component is compatible with exponent vector 1129 // component is compatible with exponent vector 1130 1130 if (pVariables1W == 1) *p = pComp_otEXP_nwONE; 1131 1131 else if (pVariables1W == 2) *p = pComp_otEXP_nwTWO; … … 1134 1134 } 1135 1135 break; 1136 1136 1137 1137 #ifdef PDEBUG 1138 1138 case ringorder_lp: … … 1155 1155 else 1156 1156 { 1157 // component is compatible with exponent vector 1157 // component is compatible with exponent vector 1158 1158 if (pVariables1W == 1) *p = pComp_otEXP_nwONE; 1159 1159 else if (pVariables1W == 2) *p = pComp_otEXP_nwTWO; … … 1167 1167 #endif 1168 1168 } 1169 1169 1170 1170 if (o_r == ringorder_lp || o_r == ringorder_ls) 1171 1171 { … … 1202 1202 *p = pComp_otCOMPEXP_nwEVEN; 1203 1203 break; 1204 1204 1205 1205 #ifdef PDEBUG 1206 1206 case ringorder_lp: … … 1373 1373 { 1374 1374 int i; 1375 pComponentOrder=1; 1376 if (ppNoether!=NULL) pDelete(&ppNoether); 1375 pVariables = r->N; 1376 if (complete) 1377 { 1378 pComponentOrder=1; 1379 if (ppNoether!=NULL) pDelete(&ppNoether); 1377 1380 #ifdef SRING 1378 pSRING=FALSE;1379 pAltVars=r->N+1;1381 pSRING=FALSE; 1382 pAltVars=r->N+1; 1380 1383 #endif 1381 pVariables = r->N; 1382 1383 // set the various size parameters and initialize memory1384 if ((((pVariables+1)*sizeof(Exponent_t)) % sizeof(void*)) == 0)1385 pVariables1W = (pVariables+1)*sizeof(Exponent_t) / sizeof(void*);1386 else1387 pVariables1W = ((pVariables+1)*sizeof(Exponent_t) / sizeof(void*)) + 1; 1388 1389 if ((((pVariables)*sizeof(Exponent_t)) % sizeof(void*)) == 0)1390 pVariablesW = (pVariables)*sizeof(Exponent_t) / sizeof(void*);1391 else1392 pVariablesW = ((pVariables)*sizeof(Exponent_t) / sizeof(void*)) + 1;1384 1385 // set the various size parameters and initialize memory 1386 if ((((pVariables+1)*sizeof(Exponent_t)) % sizeof(void*)) == 0) 1387 pVariables1W = (pVariables+1)*sizeof(Exponent_t) / sizeof(void*); 1388 else 1389 pVariables1W = ((pVariables+1)*sizeof(Exponent_t) / sizeof(void*)) + 1; 1390 1391 if ((((pVariables)*sizeof(Exponent_t)) % sizeof(void*)) == 0) 1392 pVariablesW = (pVariables)*sizeof(Exponent_t) / sizeof(void*); 1393 else 1394 pVariablesW = ((pVariables)*sizeof(Exponent_t) / sizeof(void*)) + 1; 1395 } 1393 1396 1394 1397 pMonomSize = POLYSIZE + (pVariables + 1) * sizeof(Exponent_t); 1395 if ((pMonomSize % sizeof(void*)) == 0) 1396 { 1397 pMonomSizeW = pMonomSize/sizeof(void*); 1398 } 1399 else 1400 { 1401 pMonomSizeW = pMonomSize/sizeof(void*) + 1; 1402 pMonomSize = pMonomSizeW*sizeof(void*); 1403 } 1404 1405 // Set default Var Indicies 1406 pSetVarIndicies(pVariables); 1407 1408 // Initialize memory management 1398 1399 // Initialize memory management 1409 1400 mmSpecializeBlock(pMonomSize); 1410 1411 pOrdSgn = r->OrdSgn; 1412 pVectorOut=(r->order[0]==ringorder_c); 1413 order=r->order; 1414 block0=r->block0; 1415 block1=r->block1; 1416 firstwv=NULL; 1417 polys_wv=r->wvhdl; 1418 /*------- only one real block ----------------------*/ 1419 pLexOrder=FALSE; 1420 pMixedOrder=FALSE; 1421 pFDeg=pDeg; 1422 if (pOrdSgn == 1) pLDeg = ldegb; 1423 else pLDeg = ldeg0; 1424 /*======== ordering type is (_,c) =========================*/ 1425 if ((order[0]==ringorder_unspec) 1426 ||( 1427 ((order[1]==ringorder_c)||(order[1]==ringorder_C)) 1428 && (order[0]!=ringorder_M) 1429 && (order[2]==0)) 1430 ) 1431 { 1432 if ((order[0]!=ringorder_unspec) 1433 && (order[1]==ringorder_C)) 1434 pComponentOrder=-1; 1435 if (pOrdSgn == -1) pLDeg = ldeg0c; 1436 SimpleChoose(order[0],order[1], &pComp0); 1437 SetpSetm(order[0],0); 1438 } 1439 /*======== ordering type is (c,_) =========================*/ 1440 else if (((order[0]==ringorder_c)||(order[0]==ringorder_C)) 1441 && (order[1]!=ringorder_M) 1442 && (order[2]==0)) 1443 { 1444 /* pLDeg = ldeg0; is standard*/ 1445 if (order[0]==ringorder_C) 1446 pComponentOrder=-1; 1447 SimpleChooseC(order[1], &pComp0); 1448 SetpSetm(order[1],1); 1449 } 1450 /*------- more than one block ----------------------*/ 1451 else 1452 { 1453 //pLexOrder=TRUE; 1454 pVectorOut=order[0]==ringorder_c; 1455 if ((pVectorOut)||(order[0]==ringorder_C)) 1456 { 1457 if(block1[1]!=pVariables) pLexOrder=TRUE; 1458 } 1401 1402 if (complete) 1403 { 1404 if ((pMonomSize % sizeof(void*)) == 0) 1405 { 1406 pMonomSizeW = pMonomSize/sizeof(void*); 1407 } 1459 1408 else 1460 1409 { 1461 if(block1[0]!=pVariables) pLexOrder=TRUE; 1462 } 1463 /*the number of orderings:*/ 1464 i = 0; 1465 while (order[++i] != 0); 1466 do 1467 { 1468 i--; 1469 HighSet(i, order[i]);/*sets also pMixedOrder to TRUE, if...*/ 1470 SetpSetm(order[i],i); 1471 } 1472 while (i != 0); 1473 1474 pComp0 = BlockComp; 1475 if ((order[0]!=ringorder_c)&&(order[0]!=ringorder_C)) 1476 { 1477 pLDeg = ldeg1c; 1478 } 1410 pMonomSizeW = pMonomSize/sizeof(void*) + 1; 1411 pMonomSize = pMonomSizeW*sizeof(void*); 1412 } 1413 1414 // Set default Var Indicies 1415 pSetVarIndicies(pVariables); 1416 1417 pOrdSgn = r->OrdSgn; 1418 pVectorOut=(r->order[0]==ringorder_c); 1419 order=r->order; 1420 block0=r->block0; 1421 block1=r->block1; 1422 firstwv=NULL; 1423 polys_wv=r->wvhdl; 1424 /*------- only one real block ----------------------*/ 1425 pLexOrder=FALSE; 1426 pMixedOrder=FALSE; 1427 pFDeg=pDeg; 1428 if (pOrdSgn == 1) pLDeg = ldegb; 1429 else pLDeg = ldeg0; 1430 /*======== ordering type is (_,c) =========================*/ 1431 if ((order[0]==ringorder_unspec) 1432 ||( 1433 ((order[1]==ringorder_c)||(order[1]==ringorder_C)) 1434 && (order[0]!=ringorder_M) 1435 && (order[2]==0)) 1436 ) 1437 { 1438 if ((order[0]!=ringorder_unspec) 1439 && (order[1]==ringorder_C)) 1440 pComponentOrder=-1; 1441 if (pOrdSgn == -1) pLDeg = ldeg0c; 1442 SimpleChoose(order[0],order[1], &pComp0); 1443 SetpSetm(order[0],0); 1444 } 1445 /*======== ordering type is (c,_) =========================*/ 1446 else if (((order[0]==ringorder_c)||(order[0]==ringorder_C)) 1447 && (order[1]!=ringorder_M) 1448 && (order[2]==0)) 1449 { 1450 /* pLDeg = ldeg0; is standard*/ 1451 if (order[0]==ringorder_C) 1452 pComponentOrder=-1; 1453 SimpleChooseC(order[1], &pComp0); 1454 SetpSetm(order[1],1); 1455 } 1456 /*------- more than one block ----------------------*/ 1479 1457 else 1480 1458 { 1481 pLDeg = ldeg1; 1482 } 1483 pFDeg = pWTotaldegree; // may be improved: pTotaldegree for lp/dp/ls/.. blocks 1484 } 1485 if ((pLexOrder) || (pOrdSgn==-1)) 1486 { 1487 test &= ~Sy_bit(OPT_REDTAIL); /* noredTail */ 1459 //pLexOrder=TRUE; 1460 pVectorOut=order[0]==ringorder_c; 1461 if ((pVectorOut)||(order[0]==ringorder_C)) 1462 { 1463 if(block1[1]!=pVariables) pLexOrder=TRUE; 1464 } 1465 else 1466 { 1467 if(block1[0]!=pVariables) pLexOrder=TRUE; 1468 } 1469 /*the number of orderings:*/ 1470 i = 0; 1471 while (order[++i] != 0); 1472 do 1473 { 1474 i--; 1475 HighSet(i, order[i]);/*sets also pMixedOrder to TRUE, if...*/ 1476 SetpSetm(order[i],i); 1477 } 1478 while (i != 0); 1479 1480 pComp0 = BlockComp; 1481 if ((order[0]!=ringorder_c)&&(order[0]!=ringorder_C)) 1482 { 1483 pLDeg = ldeg1c; 1484 } 1485 else 1486 { 1487 pLDeg = ldeg1; 1488 } 1489 // may be improved: pTotaldegree for lp/dp/ls/.. blocks 1490 pFDeg = pWTotaldegree; 1491 } 1492 if ((pLexOrder) || (pOrdSgn==-1)) 1493 { 1494 test &= ~Sy_bit(OPT_REDTAIL); /* noredTail */ 1495 } 1488 1496 } 1489 1497 } -
Singular/ring.cc
r1d202e r41b473 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.2 1 1998-04-03 17:38:41Singular Exp $ */4 /* $Id: ring.cc,v 1.22 1998-04-23 18:17:37 Singular Exp $ */ 5 5 6 6 /* … … 42 42 43 43 // internally changes the gloabl ring and resets the relevant 44 // global variables: 44 // global variables: 45 45 // complete == FALSE : only delete operations are enabled 46 46 // complete == TRUE : full reset of all variables 47 47 void rChangeCurrRing(ring r, BOOLEAN complete) 48 48 { 49 /*------------ set global ring vars --------------------------------*/ 50 currRing = r; 49 51 if (r != NULL) 50 52 { 53 /*------------ set global ring vars --------------------------------*/ 54 currQuotient=r->qideal; 55 51 56 /*------------ set redTail, except reset by nSetChar or pChangeRing */ 52 test |= Sy_bit(OPT_REDTAIL); 57 if (complete) 58 { 59 test |= Sy_bit(OPT_REDTAIL); 60 } 53 61 54 62 /*------------ global variables related to coefficients ------------*/ … … 58 66 pSetGlobals(r, complete); 59 67 68 69 if (complete) 70 { 60 71 /*------------ set naMinimalPoly -----------------------------------*/ 61 if (r->minpoly!=NULL) 62 { 63 naMinimalPoly=((lnumber)r->minpoly)->z; 64 } 65 66 /*------------ set global ring vars --------------------------------*/ 67 currRing = r; 68 currQuotient=r->qideal; 72 if (r->minpoly!=NULL) 73 { 74 naMinimalPoly=((lnumber)r->minpoly)->z; 75 } 69 76 70 77 #ifdef DRING 71 pDRING=FALSE;72 pSDRING=FALSE;73 if (hasFlag(h,FLAG_DRING)) rDSet();78 pDRING=FALSE; 79 pSDRING=FALSE; 80 if (hasFlag(h,FLAG_DRING)) rDSet(); 74 81 #endif // DRING 75 82 76 83 #ifdef SRING 77 if ((currRing->partN<=currRing->N)84 if ((currRing->partN<=currRing->N) 78 85 #ifdef DRING 79 86 && (!hasFlag(h,FLAG_DRING)) 80 87 #endif 81 82 {83 pAltVars=currRing->partN;84 pSRING=TRUE;85 pSDRING=TRUE;86 }87 else88 {89 pAltVars=currRing->N+1;90 }88 ) 89 { 90 pAltVars=currRing->partN; 91 pSRING=TRUE; 92 pSDRING=TRUE; 93 } 94 else 95 { 96 pAltVars=currRing->N+1; 97 } 91 98 #endif // SRING 92 99 93 100 /*------------ set spolys ------------------------------------------*/ 94 if (complete) spSet(r); 95 } 96 } 97 101 spSet(r); 102 } 103 } 104 else 105 { 106 currQuotient=NULL; 107 } 108 } 109 98 110 void rSetHdl(idhdl h, BOOLEAN complete) 99 111 { … … 115 127 } 116 128 else complete=FALSE; 117 129 118 130 // clean up history 119 131 if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) 120 132 || ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data)))) 121 133 { 122 134 sLastPrinted.CleanUp(); 123 135 memset(&sLastPrinted,0,sizeof(sleftv)); 124 136 } 125 137 126 138 /*------------ change the global ring -----------------------*/ 127 139 rChangeCurrRing(rg,complete); … … 143 155 if ((rg->parameter!=NULL) && (rg->ch<2)) 144 156 { 145 146 147 148 149 150 151 152 157 for (i=0;i<rg->P;i++) 158 { 159 if(strlen(rg->parameter[i])>1) 160 { 161 pShortOut=(int)FALSE; 162 break; 163 } 164 } 153 165 } 154 166 if (pShortOut) 155 167 { 156 157 158 159 160 161 162 163 164 } 165 } 166 } 167 168 for (i=(rg->N-1);i>=0;i--) 169 { 170 if(strlen(rg->names[i])>1) 171 { 172 pShortOut=(int)FALSE; 173 break; 174 } 175 } 176 } 177 } 178 } 179 168 180 } 169 181 … … 171 183 { 172 184 idhdl tmp=NULL; 173 185 174 186 if (s!=NULL) tmp = enterid(s, myynest, RING_CMD, &idroot); 175 187 if (tmp==NULL) return NULL; 176 188 177 189 if (ppNoether!=NULL) pDelete(&ppNoether); 178 190 if ((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) … … 181 193 memset(&sLastPrinted,0,sizeof(sleftv)); 182 194 } 183 195 184 196 currRing = IDRING(tmp); 185 197 186 198 currRing->ch = 32003; 187 199 currRing->N = 3; … … 219 231 /*polynomial ring*/ 220 232 currRing->OrdSgn = 1; 221 233 222 234 /* complete ring intializations */ 223 235 rComplete(currRing); … … 243 255 int i=0,j,typ=1; 244 256 int sz = (int)sqrt((double)(order->length()-2)); 245 257 246 258 while ((i<sz) && (typ==1)) 247 259 { … … 267 279 */ 268 280 idhdl rInit(char *s, sleftv* pn, sleftv* rv, sleftv* ord, 269 281 BOOLEAN isDRing) 270 282 { 271 283 int ch; … … 286 298 } 287 299 pn=pn->next; 288 300 289 301 int l, last; 290 302 int typ = 1; … … 294 306 BOOLEAN ffChar=FALSE; 295 307 /*every entry in the new ring is initialized to 0*/ 296 308 297 309 /* characteristic -----------------------------------------------*/ 298 310 /* input: 0 ch=0 : Q parameter=NULL ffChar=FALSE … … 315 327 if (fftable[l]==0) 316 328 { 317 318 } 329 ch = IsPrime(ch); 330 } 319 331 else 320 332 { 321 322 323 324 325 326 327 328 329 330 331 } 333 char *m[1]={(char *)sNoName}; 334 nfSetChar(ch,m); 335 if(errorreported) 336 { 337 errorreported=0; 338 ch=IsPrime(ch); 339 } 340 else 341 { 342 ffChar=TRUE; 343 } 332 344 } 333 345 } … … 338 350 } 339 351 memset(&tmpR,0,sizeof(tmpR)); 340 352 341 353 tmpR.ch = ch; 342 354 343 355 /* parameter -------------------------------------------------------*/ 344 356 sleftv* hs; 345 357 const char* h; 346 358 347 359 if ((pn!=NULL)&& (ffChar||(ch==-1))) 348 360 { … … 351 363 { 352 364 WarnS("too many parameters"); 353 if (ffChar) hs=pn->next; 365 if (ffChar) hs=pn->next; 354 366 else hs=pn; 355 367 hs->CleanUp(); 356 if (ffChar) 357 { 358 359 360 } 368 if (ffChar) 369 { 370 pn->next=NULL; 371 Free((ADDRESS)hs,sizeof(sleftv)); 372 } 361 373 else pn=NULL; 362 374 } … … 365 377 * and for deallocating sleftv*-lists: 366 378 * don't deallocate the first but all other entries*/ 367 379 368 380 if (pn!=NULL) 369 381 { … … 374 386 tmpR.P=ffChar; /* GF(q): 1, R: 0 */ 375 387 WarnS("too many parameters"); 376 if (ffChar) hs=pn->next; 388 if (ffChar) hs=pn->next; 377 389 else hs=pn; 378 390 hs->CleanUp(); … … 390 402 if ((h==sNoName)&&(sl->Typ()==POLY_CMD)) 391 403 { 392 393 394 395 396 404 hs=(leftv)Alloc(sizeof(sleftv)); 405 iiConvert(POLY_CMD,ANY_TYPE,-1,sl,hs); 406 sl->next=hs->next; 407 hs->next=NULL; 408 h=hs->Name(); 397 409 } 398 410 if (h==sNoName) 399 411 { 400 401 402 403 404 412 WerrorS("parameter expected"); 413 pn->CleanUp(); 414 rv->CleanUp(); 415 ord->CleanUp(); 416 return NULL; 405 417 } 406 418 *p=mstrdup(h); … … 408 420 if (hs!=NULL) 409 421 { 410 411 422 hs->CleanUp(); 423 Free((ADDRESS)hs,sizeof(sleftv)); 412 424 } 413 425 hs=sl; … … 420 432 if (ch==0) tmpR.ch=1; 421 433 } 422 434 423 435 /* names and number of variables-------------------------------------*/ 424 436 { … … 442 454 if (sl==NULL) 443 455 { 444 445 446 447 448 449 450 451 452 456 if (i==tmpR.N-1) 457 tmpname=mstrdup(""); 458 else 459 { 460 tmpname=(char*)AllocL(strlen(tmpR.names[i-tmpR.partN])+2); 461 strcpy(tmpname,"d"); 462 strcat(tmpname,tmpR.names[i-tmpR.partN]); 463 } 464 h=tmpname; 453 465 } 454 466 else 455 467 #endif 456 468 h=sl->Name(); 457 469 if ((h==sNoName)&&(sl->Typ()==POLY_CMD)) 458 470 { 459 460 461 462 463 471 hs=(leftv)Alloc(sizeof(sleftv)); 472 iiConvert(POLY_CMD,ANY_TYPE,-1,sl,hs); 473 sl->next=hs->next; 474 hs->next=NULL; 475 h=hs->Name(); 464 476 } 465 477 if (h==sNoName) 466 478 { 467 468 469 470 479 WerrorS("expected name of ring variable"); 480 sl->CleanUp(); 481 ord->CleanUp(); 482 return NULL; 471 483 } 472 484 tmpR.names[i] = mstrdup(h); 473 485 if (hs!=NULL) 474 486 { 475 476 487 hs->CleanUp(); 488 Free((ADDRESS)hs,sizeof(sleftv)); 477 489 } 478 490 hs=sl; … … 481 493 { 482 494 #endif 483 484 485 486 495 sl=sl->next; 496 hs->next=NULL; 497 hs->CleanUp(); 498 if (hs!=rv) Free((ADDRESS)hs,sizeof(sleftv)); 487 499 #ifdef DRING 488 500 } 489 501 if (tmpname!=NULL) 490 502 { 491 492 503 FreeL((ADDRESS)tmpname); 504 tmpname=NULL; 493 505 } 494 506 #endif 495 507 } 496 508 497 509 /* ordering -------------------------------------------------------------*/ 498 510 sl = ord; … … 517 529 else if (i!=1) 518 530 WarnS("more than one ordering c/C -- ignored"); 519 531 520 532 /* allocating */ 521 533 tmpR.order=(int *)Alloc0(n*sizeof(int)); … … 523 535 tmpR.block1=(int *)Alloc0(n*sizeof(int)); 524 536 tmpR.wvhdl=(short**)Alloc0(n*sizeof(short*)); 525 537 526 538 /* init orders */ 527 539 sl=ord; … … 532 544 intvec *iv; 533 545 iv = (intvec *)(sl->data); 534 546 535 547 /* the format of an ordering: 536 548 * iv[0]: factor … … 543 555 case ringorder_ws: 544 556 case ringorder_Ws: 545 557 typ=-1; 546 558 case ringorder_wp: 547 559 case ringorder_Wp: 548 549 550 551 552 553 554 560 tmpR.wvhdl[n]=(short*)AllocL((iv->length()-1)*sizeof(short)); 561 for (l=2;l<iv->length();l++) 562 tmpR.wvhdl[n][l-2]=(short)(*iv)[l]; 563 tmpR.block0[n]=last+1; 564 last+=iv->length()-2; 565 tmpR.block1[n]=last; 566 break; 555 567 case ringorder_ls: 556 568 case ringorder_ds: 557 569 case ringorder_Ds: 558 570 typ=-1; 559 571 case ringorder_lp: 560 572 case ringorder_dp: 561 573 case ringorder_Dp: 562 563 564 565 566 567 568 574 tmpR.block0[n]=last+1; 575 //last+=(*iv)[0]; 576 if (iv->length()==3) last+=(*iv)[2]; 577 else last+=(*iv)[0]; 578 tmpR.block1[n]=last; 579 if (rCheckIV(iv)) return NULL; 580 break; 569 581 case ringorder_c: 570 582 case ringorder_C: 571 572 583 if (rCheckIV(iv)) return NULL; 584 break; 573 585 case ringorder_a: 574 575 576 577 578 579 580 581 582 586 tmpR.block0[n]=last+1; 587 tmpR.block1[n]=last+iv->length()-2; 588 tmpR.wvhdl[n]=(short*)AllocL((iv->length()-1)*sizeof(short)); 589 for (l=2;l<iv->length();l++) 590 { 591 tmpR.wvhdl[n][l-2]=(short)(*iv)[l]; 592 if ((*iv)[l]<0) typ=-1; 593 } 594 break; 583 595 case ringorder_M: 584 585 586 587 588 589 590 591 592 593 594 595 596 { 597 int Mtyp=rTypeOfMatrixOrder(iv); 598 if (Mtyp==0) return NULL; 599 if (Mtyp==-1) typ=-1; 600 tmpR.wvhdl[n]=(short*)AllocL((iv->length()-1)*sizeof(short)); 601 for (l=2;l<iv->length();l++) 602 tmpR.wvhdl[n][l-2]=(short)(*iv)[l]; 603 tmpR.block0[n]=last+1; 604 last+=(int)sqrt((double)(iv->length()-2)); 605 tmpR.block1[n]=last; 606 break; 607 } 596 608 #ifdef TEST 597 609 default: 598 599 610 Print("order ??? %d\n",(*iv)[1]); 611 break; 600 612 #endif 601 613 } … … 611 623 else n--; 612 624 while ((tmpR.order[n]==ringorder_c) 613 625 ||(tmpR.order[n]==ringorder_C)) 614 626 n--; 615 627 if (tmpR.block1[n]!=tmpR.N) 616 628 { 617 629 if ((tmpR.order[n]==ringorder_dp) || 618 619 620 621 622 623 { 624 625 626 627 628 629 630 631 632 630 (tmpR.order[n]==ringorder_ds) || 631 (tmpR.order[n]==ringorder_Dp) || 632 (tmpR.order[n]==ringorder_Ds) || 633 (tmpR.order[n]==ringorder_lp) || 634 (tmpR.order[n]==ringorder_ls)) 635 { 636 tmpR.block1[n]=tmpR.N; 637 if (tmpR.block0[n]>tmpR.N/*tmpR.block1[n]*/) 638 { 639 tmpR.block1[n]=tmpR.block0[n]; 640 goto ord_mismatch; 641 //Werror("mismatch of number of vars (%d) and ordering (>=%d vars)", 642 // tmpR.N,tmpR.block0[n]); 643 //return NULL; 644 } 633 645 } 634 646 else 635 647 { 636 648 ord_mismatch: 637 638 639 649 Werror("mismatch of number of vars (%d) and ordering (%d vars)", 650 tmpR.N,tmpR.block1[n]); 651 return NULL; 640 652 } 641 653 } … … 649 661 return NULL; 650 662 } 651 663 652 664 memcpy(IDRING(tmp),&tmpR,sizeof(tmpR)); 653 665 rSetHdl(tmp,TRUE); 654 666 655 667 #ifdef RDEBUG 656 668 rNumber++; 657 669 currRing->no =rNumber; 658 #endif 659 670 #endif 671 660 672 return currRingHdl; 661 673 } 662 674 663 675 // set those fields of the ring, which can be computed from other fields: 664 // More particularly, sets r->VarOffset 676 // More particularly, sets r->VarOffset 665 677 666 678 void rComplete(ring r) … … 671 683 r->VarCompIndex = (short) VarCompIndex; 672 684 } 673 685 674 686 /*2 675 687 * set a new ring from the data: … … 685 697 } 686 698 #endif 687 699 688 700 int rIsRingVar(char *n) 689 701 { … … 708 720 if ((r==NULL)||(r->order==NULL)) 709 721 return; /*to avoid printing after errors....*/ 710 722 711 723 int nblocks=rBlocks(r); 712 724 713 725 mmTestP(r,sizeof(ip_sring)); 714 726 mmTestP(r->order,nblocks*sizeof(int)); … … 717 729 mmTestP(r->wvhdl,nblocks*sizeof(short *)); 718 730 mmTestP(r->names,r->N*sizeof(char *)); 719 731 720 732 nblocks--; 721 722 733 734 723 735 if ((r->parameter!=NULL)&&(r->ch>1)) 724 736 PrintS("// # ground field : "); … … 738 750 while (nop<r->P) 739 751 { 740 741 742 752 PrintS(*sp); 753 PrintS(" "); 754 sp++; nop++; 743 755 } 744 756 PrintS("\n// minpoly : "); 745 757 if (r==currRing) 746 758 { 747 759 StringSetS(""); nWrite(r->minpoly); PrintS(StringAppendS("\n")); 748 760 } 749 761 else if (r->minpoly==NULL) 750 762 { 751 763 PrintS("0\n"); 752 764 } 753 765 else 754 766 { 755 767 PrintS("...\n"); 756 768 } 757 769 } … … 759 771 { 760 772 Print("// primitive element : %s\n", r->parameter[0]); 761 if (r==currRing) 762 { 763 764 765 } 766 } 773 if (r==currRing) 774 { 775 StringSetS("// minpoly : "); 776 nfShowMipo();PrintS(StringAppend("\n")); 777 } 778 } 767 779 } 768 780 Print("// number of vars : %d",r->N); 769 781 770 782 //for (nblocks=0; r->order[nblocks]; nblocks++); 771 783 nblocks=rBlocks(r)-1; 772 784 773 785 for (int l=0, nlen=0 ; l<nblocks; l++) 774 786 { 775 787 int i; 776 788 Print("\n// block %3d : ",l+1); 777 789 778 790 Print("ordering %c", (" acCMldDwWldDwWu")[r->order[l]]); 779 791 if ((r->order[l]>=ringorder_lp)&&(r->order[l]!=ringorder_unspec)) 780 792 { 781 793 if (r->order[l]>=ringorder_ls) 782 794 PrintS("s"); 783 795 else 784 785 } 786 796 PrintS("p"); 797 } 798 787 799 if ((r->order[l] != ringorder_c) && (r->order[l] != ringorder_C)) 788 800 { … … 790 802 for (i = r->block0[l]-1; i<r->block1[l]; i++) 791 803 { 792 793 794 } 795 } 796 804 nlen = strlen(r->names[i]); 805 Print("%s ",r->names[i]); 806 } 807 } 808 797 809 if (r->wvhdl[l]!=NULL) 798 810 { 799 811 for (int j= 0; 800 801 802 { 803 804 805 806 807 808 812 j<(r->block1[l]-r->block0[l]+1)*(r->block1[l]-r->block0[l]+1); 813 j+=i) 814 { 815 PrintS("\n// : weights "); 816 for (i = 0; i<=r->block1[l]-r->block0[l]; i++) 817 { 818 Print("%*d " ,nlen,r->wvhdl[l][i+j],i+j); 819 } 820 if (r->order[l]!=ringorder_M) break; 809 821 } 810 822 } … … 833 845 if (r->qideal!=NULL) 834 846 { 835 836 837 847 idDelete(&r->qideal); 848 r->qideal=NULL; 849 currQuotient=NULL; 838 850 } 839 851 if (ppNoether!=NULL) pDelete(&ppNoether); 840 852 if ((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) 841 853 { 842 843 854 sLastPrinted.CleanUp(); 855 memset(&sLastPrinted,0,sizeof(sleftv)); 844 856 } 845 857 currRing=NULL; … … 852 864 idDelete(&r->qideal); 853 865 r->qideal=NULL; 854 if (savecurrRing!=NULL)rChangeCurrRing(savecurrRing,FALSE);866 rChangeCurrRing(savecurrRing,FALSE); 855 867 } 856 868 int i=1; … … 861 873 if (iiLocalRing[j]==r) 862 874 { 863 864 875 if (j<myynest) Warn("killing the basering for level %d",j); 876 iiLocalRing[j]=NULL; 865 877 } 866 878 } … … 874 886 for (j=0; j<i; j++) 875 887 { 876 877 888 if (r->wvhdl[j]!=NULL) 889 FreeL(r->wvhdl[j]); 878 890 } 879 891 Free((ADDRESS)r->wvhdl,i*sizeof(short *)); 880 892 if(r->names!=NULL) 881 893 { 882 883 884 885 886 894 for (i=0; i<r->N; i++) 895 { 896 FreeL((ADDRESS)r->names[i]); 897 } 898 Free((ADDRESS)r->names,r->N*sizeof(char *)); 887 899 } 888 900 if (r->parameter!=NULL) 889 901 { 890 891 892 893 894 895 896 897 898 902 int len=0; 903 char **s=r->parameter; 904 while (len<r->P) 905 { 906 FreeL((ADDRESS)*s); 907 s++; 908 len++; 909 } 910 Free((ADDRESS)r->parameter,r->P*sizeof(char *)); 899 911 } 900 912 } … … 920 932 { 921 933 if ((currRingHdl!=h) 922 923 924 934 && (IDTYP(currRingHdl)==IDTYP(h)) 935 && (h->data.uring==currRingHdl->data.uring)) 936 break; 925 937 currRingHdl=IDNEXT(currRingHdl); 926 938 } … … 934 946 { 935 947 if (((IDTYP(h)==RING_CMD)||(IDTYP(h)==QRING_CMD)) 936 937 948 && (h->data.uring==r) 949 && (h!=n)) 938 950 return h; 939 951 h=IDNEXT(h); … … 945 957 { 946 958 int order=0; 947 959 948 960 switch (*ordername) 949 961 { … … 982 994 { 983 995 int nblocks,l,i; 984 996 985 997 for (nblocks=0; r->order[nblocks]; nblocks++); 986 998 nblocks--; 987 999 988 1000 StringSetS(""); 989 1001 for (l=0; ; l++) … … 993 1005 { 994 1006 if (r->order[l]>=ringorder_ls) 995 1007 StringAppendS("s"); 996 1008 else 997 1009 StringAppendS("p"); 998 1010 } 999 1011 if ((r->order[l] != ringorder_c) && (r->order[l] != ringorder_C)) … … 1001 1013 if (r->wvhdl[l]!=NULL) 1002 1014 { 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1015 StringAppendS("("); 1016 for (int j= 0; 1017 j<(r->block1[l]-r->block0[l]+1)*(r->block1[l]-r->block0[l]+1); 1018 j+=i+1) 1019 { 1020 char c=','; 1021 for (i = 0; i<r->block1[l]-r->block0[l]; i++) 1022 { 1023 StringAppend("%d," ,r->wvhdl[l][i+j]); 1024 } 1025 if (r->order[l]!=ringorder_M) 1026 { 1027 StringAppend("%d)" ,r->wvhdl[l][i+j]); 1028 break; 1029 } 1030 if (j+i+1==(r->block1[l]-r->block0[l]+1)*(r->block1[l]-r->block0[l]+1)) 1031 c=')'; 1032 StringAppend("%d%c" ,r->wvhdl[l][i+j],c); 1033 } 1022 1034 } 1023 1035 else 1024 1036 StringAppend("(%d)",r->block1[l]-r->block0[l]+1); 1025 1037 } 1026 1038 if (l==nblocks) return mstrdup(StringAppendS("")); … … 1034 1046 int l=2; 1035 1047 char *s; 1036 1048 1037 1049 for (i=0; i<r->N; i++) 1038 1050 { … … 1054 1066 char *s; 1055 1067 int i; 1056 1068 1057 1069 if (r->parameter==NULL) 1058 1070 { … … 1095 1107 { 1096 1108 if (r->parameter==NULL) return mstrdup(""); 1097 1109 1098 1110 int i; 1099 1111 int l=2; 1100 1112 1101 1113 for (i=0; i<r->P; i++) 1102 1114 { … … 1125 1137 FreeL((ADDRESS)ord); 1126 1138 return res; 1127 } 1139 } 1128 1140 1129 1141 int rChar(ring r) … … 1182 1194 if (r1->parameter!=NULL) 1183 1195 { 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1196 if (strcmp(r1->parameter[0],r2->parameter[0])==0) /* 1 char */ 1197 { 1198 tmpR.parameter=(char **)Alloc(sizeof(char *)); 1199 tmpR.parameter[0]=mstrdup(r1->parameter[0]); 1200 tmpR.P=1; 1201 } 1202 else 1203 { 1204 WerrorS("GF(p,n)+GF(p,n)"); 1205 return -1; 1206 } 1195 1207 } 1196 1208 } … … 1199 1211 if (r1->minpoly!=NULL) 1200 1212 { 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1213 if (r2->minpoly!=NULL) 1214 { 1215 nSetChar(r1->ch,TRUE,r1->parameter,r1->P); 1216 if ((strcmp(r1->parameter[0],r2->parameter[0])==0) /* 1 char */ 1217 && naEqual(r1->minpoly,r2->minpoly)) 1218 { 1219 tmpR.parameter=(char **)Alloc(sizeof(char *)); 1220 tmpR.parameter[0]=mstrdup(r1->parameter[0]); 1221 tmpR.minpoly=naCopy(r1->minpoly); 1222 tmpR.P=1; 1223 nSetChar(currRing->ch,TRUE,currRing->parameter,currRing->P); 1224 } 1225 else 1226 { 1227 nSetChar(currRing->ch,TRUE,currRing->parameter,currRing->P); 1228 WerrorS("different minpolys"); 1229 return -1; 1230 } 1231 } 1232 else 1233 { 1234 if ((strcmp(r1->parameter[0],r2->parameter[0])==0) /* 1 char */ 1235 && (r2->P==1)) 1236 { 1237 tmpR.parameter=(char **)Alloc0(sizeof(char *)); 1238 tmpR.parameter[0]=mstrdup(r1->parameter[0]); 1239 tmpR.P=1; 1240 nSetChar(r1->ch,TRUE,r1->parameter,r1->P); 1241 tmpR.minpoly=naCopy(r1->minpoly); 1242 nSetChar(currRing->ch,TRUE,currRing->parameter,currRing->P); 1243 } 1244 else 1245 { 1246 WerrorS("different parameters and minpoly!=0"); 1247 return -1; 1248 } 1249 } 1238 1250 } 1239 1251 else /* r1->minpoly==NULL */ 1240 1252 { 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1253 if (r2->minpoly!=NULL) 1254 { 1255 if ((strcmp(r1->parameter[0],r2->parameter[0])==0) /* 1 char */ 1256 && (r1->P==1)) 1257 { 1258 tmpR.parameter=(char **)Alloc(sizeof(char *)); 1259 tmpR.parameter[0]=mstrdup(r1->parameter[0]); 1260 tmpR.P=1; 1261 nSetChar(r2->ch,TRUE,r2->parameter,r2->P); 1262 tmpR.minpoly=naCopy(r2->minpoly); 1263 nSetChar(currRing->ch,TRUE,currRing->parameter,currRing->P); 1264 } 1265 else 1266 { 1267 WerrorS("different parameters and minpoly!=0"); 1268 return -1; 1269 } 1270 } 1271 else 1272 { 1273 int len=rPar(r1)+rPar(r2); 1274 tmpR.parameter=(char **)Alloc(len*sizeof(char *)); 1275 int i; 1276 for (i=0;i<r1->P;i++) 1277 { 1278 tmpR.parameter[i]=mstrdup(r1->parameter[i]); 1279 } 1280 int j,l; 1281 for(j=0;j<r2->P;j++) 1282 { 1283 for(l=0;l<i;l++) 1284 { 1285 if(strcmp(tmpR.parameter[l],r2->parameter[j])==0) 1286 break; 1287 } 1288 if (l==i) 1289 { 1290 tmpR.parameter[i]=mstrdup(r2->parameter[j]); 1291 i++; 1292 } 1293 } 1294 if (i!=len) 1295 { 1296 ReAlloc(tmpR.parameter,len*sizeof(char *),i*sizeof(char *)); 1297 } 1298 } 1287 1299 } 1288 1300 } … … 1293 1305 { 1294 1306 if ((r2->ch==0) /* Q */ 1295 1296 { 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 || (r2->ch==-r1->ch)) /* Z/p */ 1308 { 1309 tmpR.ch=r1->ch; 1310 tmpR.parameter=(char **)Alloc(rPar(r1)*sizeof(char *)); 1311 tmpR.P=r1->P; 1312 memcpy(tmpR.parameter,r1->parameter,rPar(r1)*sizeof(char *)); 1313 if (r1->minpoly!=NULL) 1314 { 1315 nSetChar(r1->ch,TRUE,r1->parameter,r1->P); 1316 tmpR.minpoly=naCopy(r1->minpoly); 1317 nSetChar(currRing->ch,TRUE,currRing->parameter,currRing->P); 1318 } 1307 1319 } 1308 1320 else /* R, Q(a),Z/q,Z/p(a),GF(p,n) */ 1309 1321 { 1310 1311 1322 WerrorS("Z/p(a)+(R,Q(a),Z/q(a),GF(q,n))"); 1323 return -1; 1312 1324 } 1313 1325 } … … 1321 1333 if ((r2->ch<-1)||(r2->ch==1)) /* Z/p(a),Q(a) */ 1322 1334 { 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1335 tmpR.ch=r2->ch; 1336 tmpR.P=r2->P; 1337 tmpR.parameter=(char **)Alloc(rPar(r2)*sizeof(char *)); 1338 memcpy(tmpR.parameter,r2->parameter,rPar(r2)*sizeof(char *)); 1339 if (r2->minpoly!=NULL) 1340 { 1341 nSetChar(r1->ch,TRUE,r1->parameter,r1->P); 1342 tmpR.minpoly=naCopy(r2->minpoly); 1343 nSetChar(currRing->ch,TRUE,currRing->parameter,currRing->P); 1344 } 1333 1345 } 1334 1346 else if (r2->ch>1) /* Z/p,GF(p,n) */ 1335 1347 { 1336 1337 1338 1339 1340 1341 1342 1348 tmpR.ch=r2->ch; 1349 if (r2->parameter!=NULL) 1350 { 1351 tmpR.parameter=(char **)Alloc(sizeof(char *)); 1352 tmpR.P=1; 1353 tmpR.parameter[0]=mstrdup(r2->parameter[0]); 1354 } 1343 1355 } 1344 1356 else 1345 1357 { 1346 1347 1358 WerrorS("Q+R"); 1359 return -1; /* R */ 1348 1360 } 1349 1361 } … … 1352 1364 if (r2->ch==0) /* Q */ 1353 1365 { 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1366 tmpR.ch=r1->ch; 1367 tmpR.P=rPar(r1); 1368 tmpR.parameter=(char **)Alloc0(rPar(r1)*sizeof(char *)); 1369 int i; 1370 for(i=0;i<r1->P;i++) 1371 { 1372 tmpR.parameter[i]=mstrdup(r1->parameter[i]); 1373 } 1374 if (r1->minpoly!=NULL) 1375 { 1376 nSetChar(r1->ch,TRUE,r1->parameter,r1->P); 1377 tmpR.minpoly=naCopy(r1->minpoly); 1378 nSetChar(currRing->ch,TRUE,currRing->parameter,currRing->P); 1379 } 1368 1380 } 1369 1381 else /* R, Z/p,GF(p,n) */ 1370 1382 { 1371 1372 1383 WerrorS("Q(a)+(R,Z/p,GF(p,n))"); 1384 return -1; 1373 1385 } 1374 1386 } … … 1377 1389 if (r2->ch==0) /* Q */ 1378 1390 { 1379 1391 tmpR.ch=r1->ch; 1380 1392 } 1381 1393 else if (r2->ch==-r1->ch) /* Z/p(a) */ 1382 1394 { 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1395 tmpR.ch=r2->ch; 1396 tmpR.P=rPar(r2); 1397 tmpR.parameter=(char **)Alloc(rPar(r2)*sizeof(char *)); 1398 int i; 1399 for(i=0;i<r2->P;i++) 1400 { 1401 tmpR.parameter[i]=mstrdup(r2->parameter[i]); 1402 } 1403 if (r2->minpoly!=NULL) 1404 { 1405 nSetChar(r2->ch,TRUE,r2->parameter,r2->P); 1406 tmpR.minpoly=naCopy(r2->minpoly); 1407 nSetChar(currRing->ch,TRUE,currRing->parameter,currRing->P); 1408 } 1397 1409 } 1398 1410 else 1399 1411 { 1400 1401 1412 WerrorS("Z/p+(GF(q,n),Z/q(a),R,Q(a))"); 1413 return -1; /* GF(p,n),Z/q(a),R,Q(a) */ 1402 1414 } 1403 1415 } … … 1408 1420 char **names=(char **)Alloc0(l*sizeof(char*)); 1409 1421 k=0; 1410 1422 1411 1423 // collect all varnames from r1, except those which are parameters 1412 1424 // of r2, or those which are the empty string … … 1414 1426 { 1415 1427 BOOLEAN b=TRUE; 1416 1428 1417 1429 if (*(r1->names[i]) == '\0') 1418 1430 b = FALSE; … … 1421 1433 for(j=0;j<r2->P;j++) 1422 1434 { 1423 1424 1425 1426 1427 1428 } 1429 } 1430 1435 if (strcmp(r1->names[i],r2->parameter[j])==0) 1436 { 1437 b=FALSE; 1438 break; 1439 } 1440 } 1441 } 1442 1431 1443 if (b) 1432 1444 { … … 1443 1455 { 1444 1456 BOOLEAN b=TRUE; 1445 1457 1446 1458 if (*(r2->names[i]) == '\0') 1447 1459 b = FALSE; … … 1450 1462 for(j=0;j<r1->P;j++) 1451 1463 { 1452 1453 1454 1455 1456 1457 } 1458 } 1459 1464 if (strcmp(r2->names[i],r1->parameter[j])==0) 1465 { 1466 b=FALSE; 1467 break; 1468 } 1469 } 1470 } 1471 1460 1472 if (b) 1461 1473 { 1462 1474 for(j=0;j<r1->N;j++) 1463 1475 { 1464 1465 1466 1467 1468 1476 if (strcmp(r1->names[j],r2->names[i])==0) 1477 { 1478 b=FALSE; 1479 break; 1480 } 1469 1481 } 1470 1482 if (b) 1471 1483 { 1472 1473 1474 1484 names[k]=mstrdup(r2->names[i]); 1485 //Print("name : %d : %s\n",k,r2->names[i]); 1486 k++; 1475 1487 } 1476 1488 //else … … 1535 1547 for (i=0;i<b;i++) 1536 1548 { 1537 1538 1539 1549 tmpR.order[i]=rb->order[i]; 1550 tmpR.block0[i]=rb->block0[i]; 1551 tmpR.block1[i]=rb->block1[i]; 1540 1552 } 1541 1553 tmpR.block0[0]=1; … … 1545 1557 for (i=0;r1->order[i]!=0;i++) 1546 1558 { 1547 1548 1549 1559 tmpR.order[i]=r1->order[i]; 1560 tmpR.block0[i]=r1->block0[i]; 1561 tmpR.block1[i]=r1->block1[i]; 1550 1562 } 1551 1563 j=i; 1552 1564 i--; 1553 1565 if ((r1->order[i]==ringorder_c) 1554 1555 { 1556 1557 1566 ||(r1->order[i]==ringorder_C)) 1567 { 1568 j--; 1569 tmpR.order[b-2]=r1->order[i]; 1558 1570 } 1559 1571 for (i=0;r2->order[i]!=0;i++,j++) 1560 1572 { 1561 1562 1563 1564 1565 1566 1567 1573 if ((r2->order[i]!=ringorder_c) 1574 &&(r2->order[i]!=ringorder_C)) 1575 { 1576 tmpR.order[j]=r2->order[i]; 1577 tmpR.block0[j]=r2->block0[i]+r1->N; 1578 tmpR.block1[j]=r2->block1[i]+r1->N; 1579 } 1568 1580 } 1569 1581 if((r1->OrdSgn==-1)||(r2->OrdSgn==-1)) 1570 1582 tmpR.OrdSgn=-1; 1571 1583 } 1572 1584 } … … 1575 1587 { 1576 1588 int b=rBlocks(r1); 1577 1589 1578 1590 tmpR.order=(int*)Alloc0(b*sizeof(int)); 1579 1591 tmpR.block0=(int*)Alloc0(b*sizeof(int)); … … 1613 1625 int *pi; 1614 1626 ring res=(ring)Alloc(sizeof(ip_sring)); 1615 1627 1616 1628 memcpy4(res,r,sizeof(ip_sring)); 1617 1629 if (r->parameter!=NULL) … … 1680 1692 return rOrderType_ExpComp; 1681 1693 return rOrderType_Exp; 1682 1694 1683 1695 default: 1684 1696 assume(r->order[0] == ringorder_lp || … … 1687 1699 r->order[0] == ringorder_Ds || 1688 1700 r->order[0] == ringorder_Ws); 1689 1701 1690 1702 if (r->order[1] == ringorder_c) return rOrderType_ExpComp; 1691 1703 return rOrderType_Exp; … … 1698 1710 } 1699 1711 } 1700 else 1712 else 1701 1713 return rOrderType_General; 1702 1714 } … … 1704 1716 BOOLEAN rHasSimpleOrder(ring r) 1705 1717 { 1706 return 1718 return 1707 1719 (r->order[0] == ringorder_unspec) || 1708 1720 ((r->order[2] == 0) && … … 1710 1722 r->order[0] != ringorder_M)); 1711 1723 } 1724 1712 1725 // returns TRUE, if simple lp or ls ordering 1713 1726 BOOLEAN rHasSimpleLexOrder(ring r) … … 1720 1733 } 1721 1734 1722 1735
Note: See TracChangeset
for help on using the changeset viewer.