Changeset 3ed0a6 in git for kernel/polys1.cc


Ignore:
Timestamp:
Dec 2, 2010, 5:34:19 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
815d74c712bea6b3c721aa0284a36bc1adaad7e4
Parents:
0885fd647459512277b7845bd58e1dc03b19d502
Message:
code cleanup: pOrdPolyMerge, pOrdPolyInsertSetm, p_PermPoly

git-svn-id: file:///usr/local/Singular/svn/trunk@13707 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/polys1.cc

    r0885fd r3ed0a6  
    12081208}
    12091209
    1210 // orders monoms of poly using merge sort (ususally faster than
    1211 // insertion sort). ASSUMES that pSetm was performed on monoms
    1212 poly pOrdPolyMerge(poly p)
    1213 {
    1214   poly qq,pp,result=NULL;
    1215 
    1216   if (p == NULL) return NULL;
    1217 
    1218   loop
    1219   {
    1220     qq = p;
    1221     loop
    1222     {
    1223       if (pNext(p) == NULL)
    1224       {
    1225         result=pAdd(result, qq);
    1226         pTest(result);
    1227         return result;
    1228       }
    1229       if (pLmCmp(p,pNext(p)) != 1)
    1230       {
    1231         pp = p;
    1232         pIter(p);
    1233         pNext(pp) = NULL;
    1234         result = pAdd(result, qq);
    1235         break;
    1236       }
    1237       pIter(p);
    1238     }
    1239   }
    1240 }
    1241 
    1242 // orders monoms of poly using insertion sort, performs pSetm on each monom
    1243 poly pOrdPolyInsertSetm(poly p)
    1244 {
    1245   poly qq,result = NULL;
    1246 
    1247 #if 0
    1248   while (p != NULL)
    1249   {
    1250     qq = p;
    1251     pIter(p);
    1252     qq->next = NULL;
    1253     pSetm(qq);
    1254     result = pAdd(result,qq);
    1255     pTest(result);
    1256   }
    1257 #else
    1258   while (p != NULL)
    1259   {
    1260     qq = p;
    1261     pIter(p);
    1262     qq->next = result;
    1263     result = qq;
    1264     pSetm(qq);
    1265   }
    1266   p = result;
    1267   result = NULL;
    1268   while (p != NULL)
    1269   {
    1270     qq = p;
    1271     pIter(p);
    1272     qq->next = NULL;
    1273     result = pAdd(result, qq);
    1274   }
    1275   pTest(result);
    1276 #endif
    1277   return result;
    1278 }
    1279 
    12801210/*2
    12811211*returns a re-ordered copy of a polynomial, with permutation of the variables
     
    14451375}
    14461376
    1447 #if 0
    1448 /*2
    1449 *returns a re-ordered copy of a polynomial, with permutation of the variables
    1450 */
    1451 poly p_PermPoly (poly p, int * perm, ring oldRing,
    1452    int *par_perm, int OldPar, ring newRing)
    1453 {
    1454   int OldpVariables = oldRing->N;
    1455   poly result = NULL;
    1456   poly result_last = NULL;
    1457   poly aq=NULL; /* the map coefficient */
    1458   poly qq; /* the mapped monomial */
    1459 
    1460   while (p != NULL)
    1461   {
    1462     if (OldPar==0)
    1463     {
    1464       qq = pInit();
    1465       number n=newRing->cf->nMap(pGetCoeff(p));
    1466       if ((newRing->minpoly!=NULL)
    1467       && ((rField_is_Zp_a(newRing)) || (rField_is_Q_a(newRing))))
    1468       {
    1469         newRing->cf->nNormalize(n);
    1470       }
    1471       pGetCoeff(qq)=n;
    1472     // coef may be zero:  pTest(qq);
    1473     }
    1474     else
    1475     {
    1476       qq=p_ISet(1, newRing);
    1477       aq=naPermNumber(pGetCoeff(p),par_perm,OldPar, oldRing);
    1478       if ((newRing->minpoly!=NULL)
    1479       && ((rField_is_Zp_a(newRing)) || (rField_is_Q_a(newRing))))
    1480       {
    1481         poly tmp=aq;
    1482         while (tmp!=NULL)
    1483         {
    1484           number n=pGetCoeff(tmp);
    1485           newRing->cf->nNormalize(n);
    1486           pGetCoeff(tmp)=n;
    1487           pIter(tmp);
    1488         }
    1489       }
    1490       //pTest(aq);
    1491     }
    1492     p_SetComp(qq, p_GetComp(p,oldRing), newRing);
    1493     if (newRing->cf->nIsZero(pGetCoeff(qq)))
    1494     {
    1495       p_DeleteLm(&qq, newRing);
    1496     }
    1497     else
    1498     {
    1499       int i;
    1500       int mapped_to_par=0;
    1501       for(i=1; i<=OldpVariables; i++)
    1502       {
    1503         int e=p_GetExp(p,i,oldRing);
    1504         if (e!=0)
    1505         {
    1506           if (perm==NULL)
    1507           {
    1508             p_SetExp(qq,i, e, newRing);
    1509           }
    1510           else if (perm[i]>0)
    1511             p_AddExp(qq,perm[i], e/*p_GetExp( p,i,oldRing)*/, newRing);
    1512           else if (perm[i]<0)
    1513           {
    1514             lnumber c=(lnumber)pGetCoeff(qq);
    1515             napAddExp(c->z,-perm[i],e/*p_GetExp( p,i,oldRing)*/);
    1516             mapped_to_par=1;
    1517           }
    1518           else
    1519           {
    1520             /* this variable maps to 0 !*/
    1521             p_DeleteLm(&qq, newRing);
    1522             break;
    1523           }
    1524         }
    1525       }
    1526       if (mapped_to_par
    1527       && (newRing->minpoly!=NULL))
    1528       {
    1529         number n=pGetCoeff(qq);
    1530         newRing->cf->nNormalize(n);
    1531         pGetCoeff(qq)=n;
    1532       }
    1533     }
    1534     pIter(p);
    1535     if (qq!=NULL)
    1536     {
    1537       p_Setm(qq, newRing);
    1538       //pTest(aq);
    1539       //pTest(qq);
    1540       if (aq!=NULL) qq=pMult(aq,qq);
    1541       aq = qq;
    1542       while (pNext(aq) != NULL) pIter(aq);
    1543       if (result_last==NULL)
    1544       {
    1545         result=qq;
    1546       }
    1547       else
    1548       {
    1549         pNext(result_last)=qq;
    1550       }
    1551       result_last=aq;
    1552       aq = NULL;
    1553     }
    1554     else if (aq!=NULL)
    1555     {
    1556       p_Delete(&aq, newRing);
    1557     }
    1558   }
    1559   result=pOrdPolyMerge(result);
    1560   //pTest(result);
    1561   return result;
    1562 }
    1563 #endif
    1564 
    15651377poly ppJet(poly p, int m)
    15661378{
Note: See TracChangeset for help on using the changeset viewer.