Changeset 6438a12 in git


Ignore:
Timestamp:
Dec 2, 2010, 5:33:15 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
8da499bc3f1e6d45955a2d3fbea2d8623790a352
Parents:
5698bbfd7b3c79fd778de53d05635f3bf8c2a250
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2010-12-02 17:33:15+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:57:46+01:00
Message:
code cleanup: pOrdPolyMerge, pOrdPolyInsertSetm
Location:
libpolys/polys
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/polys1.cc

    r5698bb r6438a12  
    1 /****************************************
     1</****************************************
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
     
    9898}
    9999
    100 number pInitContent(poly ph);
    101 number pInitContent_a(poly ph);
    102 
    103 void p_Content(poly ph, const ring r)
    104 {
    105 #ifdef HAVE_RINGS
    106   if (rField_is_Ring(r))
    107   {
    108     if (ph!=NULL)
    109     {
    110       number k = nGetUnit(pGetCoeff(ph));
    111       if (!nGreaterZero(pGetCoeff(ph))) k = nNeg(k); // in-place negation
    112       if (!nIsOne(k))
    113       {
    114         number tmpNumber = k;
    115         k = nInvers(k);
    116         nDelete(&tmpNumber);
    117         poly h = pNext(ph);
    118         p_Mult_nn(ph,k,currRing);
    119         pNormalize(ph);
    120       }
    121       nDelete(&k);
    122     }
    123     return;
    124   }
    125 #endif
    126   number h,d;
    127   poly p;
    128 
    129   //  if(TEST_OPT_CONTENTSB) return;
    130   if(pNext(ph)==NULL)
    131   {
    132     pSetCoeff(ph,nInit(1));
    133   }
    134   else
    135   {
    136     nNormalize(pGetCoeff(ph));
    137     if(!nGreaterZero(pGetCoeff(ph))) ph = pNeg(ph);
    138     if (rField_is_Q())
    139     {
    140       h=pInitContent(ph);
    141       p=ph;
    142     }
    143     else if ((rField_is_Extension(r))
    144     && ((rPar(r)>1)||(r->minpoly==NULL)))
    145     {
    146       h=pInitContent_a(ph);
    147       p=ph;
    148     }
    149     else
    150     {
    151       h=nCopy(pGetCoeff(ph));
    152       p = pNext(ph);
    153     }
    154     while (p!=NULL)
    155     {
    156       nNormalize(pGetCoeff(p));
    157       d=nGcd(h,pGetCoeff(p),r);
    158       nDelete(&h);
    159       h = d;
    160       if(nIsOne(h))
    161       {
    162         break;
    163       }
    164       pIter(p);
    165     }
    166     p = ph;
    167     //number tmp;
    168     if(!nIsOne(h))
    169     {
    170       while (p!=NULL)
    171       {
    172         //d = nDiv(pGetCoeff(p),h);
    173         //tmp = nIntDiv(pGetCoeff(p),h);
    174         //if (!nEqual(d,tmp))
    175         //{
    176         //  StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
    177         //  nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
    178         //  nWrite(tmp);Print(StringAppendS("\n"));
    179         //}
    180         //nDelete(&tmp);
    181         if (rField_is_Zp_a(currRing) || rField_is_Q_a(currRing))
    182           d = nDiv(pGetCoeff(p),h);
    183         else
    184           d = nIntDiv(pGetCoeff(p),h);
    185         pSetCoeff(p,d);
    186         pIter(p);
    187       }
    188     }
    189     nDelete(&h);
    190 #ifdef HAVE_FACTORY
    191     if ( (nGetChar() == 1) || (nGetChar() < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
    192     {
    193       singclap_divide_content(ph);
    194       if(!nGreaterZero(pGetCoeff(ph))) ph = pNeg(ph);
    195     }
    196 #endif
    197     if (rField_is_Q_a(r))
    198     {
    199       number hzz = nlInit(1, r);
    200       h = nlInit(1, r);
    201       p=ph;
    202       while (p!=NULL)
    203       { // each monom: coeff in Q_a
    204         lnumber c_n_n=(lnumber)pGetCoeff(p);
    205         napoly c_n=c_n_n->z;
    206         while (c_n!=NULL)
    207         { // each monom: coeff in Q
    208           d=nlLcm(hzz,pGetCoeff(c_n),r->algring);
    209           n_Delete(&hzz,r->algring);
    210           hzz=d;
    211           pIter(c_n);
    212         }
    213         c_n=c_n_n->n;
    214         while (c_n!=NULL)
    215         { // each monom: coeff in Q
    216           d=nlLcm(h,pGetCoeff(c_n),r->algring);
    217           n_Delete(&h,r->algring);
    218           h=d;
    219           pIter(c_n);
    220         }
    221         pIter(p);
    222       }
    223       /* hzz contains the 1/lcm of all denominators in c_n_n->z*/
    224       /* h contains the 1/lcm of all denominators in c_n_n->n*/
    225       number htmp=nlInvers(h);
    226       number hzztmp=nlInvers(hzz);
    227       number hh=nlMult(hzz,h);
    228       nlDelete(&hzz,r->algring);
    229       nlDelete(&h,r->algring);
    230       number hg=nlGcd(hzztmp,htmp,r->algring);
    231       nlDelete(&hzztmp,r->algring);
    232       nlDelete(&htmp,r->algring);
    233       h=nlMult(hh,hg);
    234       nlDelete(&hg,r->algring);
    235       nlDelete(&hh,r->algring);
    236       nlNormalize(h);
    237       if(!nlIsOne(h))
    238       {
    239         p=ph;
    240         while (p!=NULL)
    241         { // each monom: coeff in Q_a
    242           lnumber c_n_n=(lnumber)pGetCoeff(p);
    243           napoly c_n=c_n_n->z;
    244           while (c_n!=NULL)
    245           { // each monom: coeff in Q
    246             d=nlMult(h,pGetCoeff(c_n));
    247             nlNormalize(d);
    248             nlDelete(&pGetCoeff(c_n),r->algring);
    249             pGetCoeff(c_n)=d;
    250             pIter(c_n);
    251           }
    252           c_n=c_n_n->n;
    253           while (c_n!=NULL)
    254           { // each monom: coeff in Q
    255             d=nlMult(h,pGetCoeff(c_n));
    256             nlNormalize(d);
    257             nlDelete(&pGetCoeff(c_n),r->algring);
    258             pGetCoeff(c_n)=d;
    259             pIter(c_n);
    260           }
    261           pIter(p);
    262         }
    263       }
    264       nlDelete(&h,r->algring);
    265     }
    266   }
    267 }
    268 
    269 void pSimpleContent(poly ph,int smax)
    270 {
    271   //if(TEST_OPT_CONTENTSB) return;
    272   if (ph==NULL) return;
    273   if (pNext(ph)==NULL)
    274   {
    275     pSetCoeff(ph,nInit(1));
    276     return;
    277   }
    278   if ((pNext(pNext(ph))==NULL)||(!rField_is_Q()))
    279   {
    280     return;
    281   }
    282   number d=pInitContent(ph);
    283   if (nlSize(d)<=smax)
    284   {
    285     //if (TEST_OPT_PROT) PrintS("G");
    286     return;
    287   }
    288   poly p=ph;
    289   number h=d;
    290   if (smax==1) smax=2;
    291   while (p!=NULL)
    292   {
    293 #if 0
    294     d=nlGcd(h,pGetCoeff(p),currRing);
    295     nlDelete(&h,currRing);
    296     h = d;
    297 #else
    298     nlInpGcd(h,pGetCoeff(p),currRing);
    299 #endif
    300     if(nlSize(h)<smax)
    301     {
    302       //if (TEST_OPT_PROT) PrintS("g");
    303       return;
    304     }
    305     pIter(p);
    306   }
    307   p = ph;
    308   if (!nlGreaterZero(pGetCoeff(p))) h=nlNeg(h);
    309   if(nlIsOne(h)) return;
    310   //if (TEST_OPT_PROT) PrintS("c");
    311   //
    312   number inv=nlInvers(h);
    313   p_Mult_nn(p,inv,currRing);
    314   pNormalize(p);
    315   //while (p!=NULL)
    316   //{
    317 #if 1
    318   //  d = nlIntDiv(pGetCoeff(p),h);
    319   //  pSetCoeff(p,d);
    320 #else
    321   //  nlInpIntDiv(pGetCoeff(p),h,currRing);
    322 #endif
    323   //  pIter(p);
    324   //}
    325   nlDelete(&inv,currRing);
    326   nlDelete(&h,currRing);
    327 }
    328 
    329 number pInitContent(poly ph)
    330 // only for coefficients in Q
    331 #if 0
    332 {
    333   //assume(!TEST_OPT_CONTENTSB);
    334   assume(ph!=NULL);
    335   assume(pNext(ph)!=NULL);
    336   assume(rField_is_Q());
    337   if (pNext(pNext(ph))==NULL)
    338   {
    339     return nlGetNom(pGetCoeff(pNext(ph)),currRing);
    340   }
    341   poly p=ph;
    342   number n1=nlGetNom(pGetCoeff(p),currRing);
    343   pIter(p);
    344   number n2=nlGetNom(pGetCoeff(p),currRing);
    345   pIter(p);
    346   number d;
    347   number t;
    348   loop
    349   {
    350     nlNormalize(pGetCoeff(p));
    351     t=nlGetNom(pGetCoeff(p),currRing);
    352     if (nlGreaterZero(t))
    353       d=nlAdd(n1,t);
    354     else
    355       d=nlSub(n1,t);
    356     nlDelete(&t,currRing);
    357     nlDelete(&n1,currRing);
    358     n1=d;
    359     pIter(p);
    360     if (p==NULL) break;
    361     nlNormalize(pGetCoeff(p));
    362     t=nlGetNom(pGetCoeff(p),currRing);
    363     if (nlGreaterZero(t))
    364       d=nlAdd(n2,t);
    365     else
    366       d=nlSub(n2,t);
    367     nlDelete(&t,currRing);
    368     nlDelete(&n2,currRing);
    369     n2=d;
    370     pIter(p);
    371     if (p==NULL) break;
    372   }
    373   d=nlGcd(n1,n2,currRing);
    374   nlDelete(&n1,currRing);
    375   nlDelete(&n2,currRing);
    376   return d;
    377 }
    378 #else
    379 {
    380   number d=pGetCoeff(ph);
    381   if(SR_HDL(d)&SR_INT) return d;
    382   int s=mpz_size1(d->z);
    383   int s2=-1;
    384   number d2;
    385   loop
    386   {
    387     pIter(ph);
    388     if(ph==NULL)
    389     {
    390       if (s2==-1) return nlCopy(d);
    391       break;
    392     }
    393     if (SR_HDL(pGetCoeff(ph))&SR_INT)
    394     {
    395       s2=s;
    396       d2=d;
    397       s=0;
    398       d=pGetCoeff(ph);
    399       if (s2==0) break;
    400     }
    401     else
    402     if (mpz_size1((pGetCoeff(ph)->z))<=s)
    403     {
    404       s2=s;
    405       d2=d;
    406       d=pGetCoeff(ph);
    407       s=mpz_size1(d->z);
    408     }
    409   }
    410   return nlGcd(d,d2,currRing);
    411 }
    412 #endif
    413 
    414 number pInitContent_a(poly ph)
    415 // only for coefficients in K(a) anf K(a,...)
    416 {
    417   number d=pGetCoeff(ph);
    418   int s=naParDeg(d);
    419   if (s /* naParDeg(d)*/ <=1) return naCopy(d);
    420   int s2=-1;
    421   number d2;
    422   int ss;
    423   loop
    424   {
    425     pIter(ph);
    426     if(ph==NULL)
    427     {
    428       if (s2==-1) return naCopy(d);
    429       break;
    430     }
    431     if ((ss=naParDeg(pGetCoeff(ph)))<s)
    432     {
    433       s2=s;
    434       d2=d;
    435       s=ss;
    436       d=pGetCoeff(ph);
    437       if (s2<=1) break;
    438     }
    439   }
    440   return naGcd(d,d2,currRing);
    441 }
    442 
    443 
    444 //void pContent(poly ph)
    445 //{
    446 //  number h,d;
    447 //  poly p;
    448 //
    449 //  p = ph;
    450 //  if(pNext(p)==NULL)
    451 //  {
    452 //    pSetCoeff(p,nInit(1));
    453 //  }
    454 //  else
    455 //  {
    456 //#ifdef PDEBUG
    457 //    if (!pTest(p)) return;
    458 //#endif
    459 //    nNormalize(pGetCoeff(p));
    460 //    if(!nGreaterZero(pGetCoeff(ph)))
    461 //    {
    462 //      ph = pNeg(ph);
    463 //      nNormalize(pGetCoeff(p));
    464 //    }
    465 //    h=pGetCoeff(p);
    466 //    pIter(p);
    467 //    while (p!=NULL)
    468 //    {
    469 //      nNormalize(pGetCoeff(p));
    470 //      if (nGreater(h,pGetCoeff(p))) h=pGetCoeff(p);
    471 //      pIter(p);
    472 //    }
    473 //    h=nCopy(h);
    474 //    p=ph;
    475 //    while (p!=NULL)
    476 //    {
    477 //      d=nGcd(h,pGetCoeff(p));
    478 //      nDelete(&h);
    479 //      h = d;
    480 //      if(nIsOne(h))
    481 //      {
    482 //        break;
    483 //      }
    484 //      pIter(p);
    485 //    }
    486 //    p = ph;
    487 //    //number tmp;
    488 //    if(!nIsOne(h))
    489 //    {
    490 //      while (p!=NULL)
    491 //      {
    492 //        d = nIntDiv(pGetCoeff(p),h);
    493 //        pSetCoeff(p,d);
    494 //        pIter(p);
    495 //      }
    496 //    }
    497 //    nDelete(&h);
    498 //#ifdef HAVE_FACTORY
    499 //    if ( (nGetChar() == 1) || (nGetChar() < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
    500 //    {
    501 //      pTest(ph);
    502 //      singclap_divide_content(ph);
    503 //      pTest(ph);
    504 //    }
    505 //#endif
    506 //  }
    507 //}
    508 #if 0
    509 void p_Content(poly ph, ring r)
    510 {
    511   number h,d;
    512   poly p;
    513 
    514   if(pNext(ph)==NULL)
    515   {
    516     pSetCoeff(ph,n_Init(1,r));
    517   }
    518   else
    519   {
    520     n_Normalize(pGetCoeff(ph),r);
    521     if(!n_GreaterZero(pGetCoeff(ph),r)) ph = p_Neg(ph,r);
    522     h=n_Copy(pGetCoeff(ph),r);
    523     p = pNext(ph);
    524     while (p!=NULL)
    525     {
    526       n_Normalize(pGetCoeff(p),r);
    527       d=n_Gcd(h,pGetCoeff(p),r);
    528       n_Delete(&h,r);
    529       h = d;
    530       if(n_IsOne(h,r))
    531       {
    532         break;
    533       }
    534       pIter(p);
    535     }
    536     p = ph;
    537     //number tmp;
    538     if(!n_IsOne(h,r))
    539     {
    540       while (p!=NULL)
    541       {
    542         //d = nDiv(pGetCoeff(p),h);
    543         //tmp = nIntDiv(pGetCoeff(p),h);
    544         //if (!nEqual(d,tmp))
    545         //{
    546         //  StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
    547         //  nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
    548         //  nWrite(tmp);Print(StringAppendS("\n"));
    549         //}
    550         //nDelete(&tmp);
    551         d = n_IntDiv(pGetCoeff(p),h,r);
    552         p_SetCoeff(p,d,r);
    553         pIter(p);
    554       }
    555     }
    556     n_Delete(&h,r);
    557 #ifdef HAVE_FACTORY
    558     //if ( (n_GetChar(r) == 1) || (n_GetChar(r) < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
    559     //{
    560     //  singclap_divide_content(ph);
    561     //  if(!n_GreaterZero(pGetCoeff(ph),r)) ph = p_Neg(ph,r);
    562     //}
    563 #endif
    564   }
    565 }
    566 #endif
    567 
    568 poly p_Cleardenom(poly ph, const ring r)
    569 {
    570   poly start=ph;
    571   number d, h;
    572   poly p;
    573 
    574 #ifdef HAVE_RINGS
    575   if (rField_is_Ring(r))
    576   {
    577     p_Content(ph,r);
    578     return start;
    579   }
    580 #endif
    581   if (rField_is_Zp(r) && TEST_OPT_INTSTRATEGY) return start;
    582   p = ph;
    583   if(pNext(p)==NULL)
    584   {
    585     /*
    586     if (TEST_OPT_CONTENTSB)
    587     {
    588       number n=nGetDenom(pGetCoeff(p));
    589       if (!nIsOne(n))
    590       {
    591         number nn=nMult(pGetCoeff(p),n);
    592         nNormalize(nn);
    593         pSetCoeff(p,nn);
    594       }
    595       nDelete(&n);
    596     }
    597     else
    598     */
    599       pSetCoeff(p,nInit(1));
    600   }
    601   else
    602   {
    603     h = nInit(1);
    604     while (p!=NULL)
    605     {
    606       nNormalize(pGetCoeff(p));
    607       d=nLcm(h,pGetCoeff(p),currRing);
    608       nDelete(&h);
    609       h=d;
    610       pIter(p);
    611     }
    612     /* contains the 1/lcm of all denominators */
    613     if(!nIsOne(h))
    614     {
    615       p = ph;
    616       while (p!=NULL)
    617       {
    618         /* should be:
    619         * number hh;
    620         * nGetDenom(p->coef,&hh);
    621         * nMult(&h,&hh,&d);
    622         * nNormalize(d);
    623         * nDelete(&hh);
    624         * nMult(d,p->coef,&hh);
    625         * nDelete(&d);
    626         * nDelete(&(p->coef));
    627         * p->coef =hh;
    628         */
    629         d=nMult(h,pGetCoeff(p));
    630         nNormalize(d);
    631         pSetCoeff(p,d);
    632         pIter(p);
    633       }
    634       nDelete(&h);
    635       if (nGetChar()==1)
    636       {
    637         loop
    638         {
    639           h = nInit(1);
    640           p=ph;
    641           while (p!=NULL)
    642           {
    643             d=nLcm(h,pGetCoeff(p),currRing);
    644             nDelete(&h);
    645             h=d;
    646             pIter(p);
    647           }
    648           /* contains the 1/lcm of all denominators */
    649           if(!nIsOne(h))
    650           {
    651             p = ph;
    652             while (p!=NULL)
    653             {
    654               /* should be:
    655               * number hh;
    656               * nGetDenom(p->coef,&hh);
    657               * nMult(&h,&hh,&d);
    658               * nNormalize(d);
    659               * nDelete(&hh);
    660               * nMult(d,p->coef,&hh);
    661               * nDelete(&d);
    662               * nDelete(&(p->coef));
    663               * p->coef =hh;
    664               */
    665               d=nMult(h,pGetCoeff(p));
    666               nNormalize(d);
    667               pSetCoeff(p,d);
    668               pIter(p);
    669             }
    670             nDelete(&h);
    671           }
    672           else
    673           {
    674             nDelete(&h);
    675             break;
    676           }
    677         }
    678       }
    679     }
    680     if (h!=NULL) nDelete(&h);
    681  
    682     p_Content(ph,r);
    683 #ifdef HAVE_RATGRING
    684     if (rIsRatGRing(r))
    685     {
    686       /* quick unit detection in the rational case is done in gr_nc_bba */
    687       pContentRat(ph);
    688       start=ph;
    689     }
    690 #endif
    691   }
    692   return start;
    693 }
    694 
    695 void p_Cleardenom_n(poly ph,const ring r,number &c)
    696 {
    697   number d, h;
    698   poly p;
    699 
    700   p = ph;
    701   if(pNext(p)==NULL)
    702   {
    703     c=nInvers(pGetCoeff(p));
    704     pSetCoeff(p,nInit(1));
    705   }
    706   else
    707   {
    708     h = nInit(1);
    709     while (p!=NULL)
    710     {
    711       nNormalize(pGetCoeff(p));
    712       d=nLcm(h,pGetCoeff(p),r);
    713       nDelete(&h);
    714       h=d;
    715       pIter(p);
    716     }
    717     c=h;
    718     /* contains the 1/lcm of all denominators */
    719     if(!nIsOne(h))
    720     {
    721       p = ph;
    722       while (p!=NULL)
    723       {
    724         /* should be:
    725         * number hh;
    726         * nGetDenom(p->coef,&hh);
    727         * nMult(&h,&hh,&d);
    728         * nNormalize(d);
    729         * nDelete(&hh);
    730         * nMult(d,p->coef,&hh);
    731         * nDelete(&d);
    732         * nDelete(&(p->coef));
    733         * p->coef =hh;
    734         */
    735         d=nMult(h,pGetCoeff(p));
    736         nNormalize(d);
    737         pSetCoeff(p,d);
    738         pIter(p);
    739       }
    740       if (nGetChar()==1)
    741       {
    742         loop
    743         {
    744           h = nInit(1);
    745           p=ph;
    746           while (p!=NULL)
    747           {
    748             d=nLcm(h,pGetCoeff(p),r);
    749             nDelete(&h);
    750             h=d;
    751             pIter(p);
    752           }
    753           /* contains the 1/lcm of all denominators */
    754           if(!nIsOne(h))
    755           {
    756             p = ph;
    757             while (p!=NULL)
    758             {
    759               /* should be:
    760               * number hh;
    761               * nGetDenom(p->coef,&hh);
    762               * nMult(&h,&hh,&d);
    763               * nNormalize(d);
    764               * nDelete(&hh);
    765               * nMult(d,p->coef,&hh);
    766               * nDelete(&d);
    767               * nDelete(&(p->coef));
    768               * p->coef =hh;
    769               */
    770               d=nMult(h,pGetCoeff(p));
    771               nNormalize(d);
    772               pSetCoeff(p,d);
    773               pIter(p);
    774             }
    775             number t=nMult(c,h);
    776             nDelete(&c);
    777             c=t;
    778           }
    779           else
    780           {
    781             break;
    782           }
    783           nDelete(&h);
    784         }
    785       }
    786     }
    787   }
    788 }
    789 
    790 number p_GetAllDenom(poly ph, const ring r)
    791 {
    792   number d=n_Init(1,r);
    793   poly p = ph;
    794 
    795   while (p!=NULL)
    796   {
    797     number h=n_GetDenom(pGetCoeff(p),r);
    798     if (!n_IsOne(h,r))
    799     {
    800       number dd=n_Mult(d,h,r);
    801       n_Delete(&d,r);
    802       d=dd;
    803     }
    804     n_Delete(&h,r);
    805     pIter(p);
    806   }
    807   return d;
    808 }
    809 
    810 /*2
    811 *tests if p is homogeneous with respect to the actual weigths
    812 */
    813 BOOLEAN pIsHomogeneous (poly p)
    814 {
    815   poly qp=p;
    816   int o;
    817 
    818   if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
    819   pFDegProc d;
    820   if (pLexOrder && (currRing->order[0]==ringorder_lp))
    821     d=p_Totaldegree;
    822   else
    823     d=pFDeg;
    824   o = d(p,currRing);
    825   do
    826   {
    827     if (d(qp,currRing) != o) return FALSE;
    828     pIter(qp);
    829   }
    830   while (qp != NULL);
    831   return TRUE;
    832 }
    833 
    834 /*2
    835 *returns a re-ordered copy of a polynomial, with permutation of the variables
    836 */
    837 poly pPermPoly (poly p, int * perm, const ring oldRing, nMapFunc nMap,
    838    int *par_perm, int OldPar)
    839 {
    840   int OldpVariables = oldRing->N;
    841   poly result = NULL;
    842   poly result_last = NULL;
    843   poly aq=NULL; /* the map coefficient */
    844   poly qq; /* the mapped monomial */
    845 
    846   while (p != NULL)
    847   {
    848     if ((OldPar==0)||(rField_is_GF(oldRing)))
    849     {
    850       qq = pInit();
    851       number n=nMap(pGetCoeff(p));
    852       if ((currRing->minpoly!=NULL)
    853       && ((rField_is_Zp_a()) || (rField_is_Q_a())))
    854       {
    855         nNormalize(n);
    856       }
    857       pGetCoeff(qq)=n;
    858     // coef may be zero:  pTest(qq);
    859     }
    860     else
    861     {
    862       qq=pOne();
    863       aq=napPermNumber(pGetCoeff(p),par_perm,OldPar, oldRing);
    864       if ((aq!=NULL) && (currRing->minpoly!=NULL)
    865       && ((rField_is_Zp_a()) || (rField_is_Q_a())))
    866       {
    867         pNormalize(aq);
    868       }
    869       pTest(aq);
    870       if (aq==NULL)
    871         pSetCoeff(qq,nInit(0));
    872     }
    873     if (rRing_has_Comp(currRing)) pSetComp(qq, p_GetComp(p,oldRing));
    874     if (nIsZero(pGetCoeff(qq)))
    875     {
    876       pLmDelete(&qq);
    877     }
    878     else
    879     {
    880       int i;
    881       int mapped_to_par=0;
    882       for(i=1; i<=OldpVariables; i++)
    883       {
    884         int e=p_GetExp(p,i,oldRing);
    885         if (e!=0)
    886         {
    887           if (perm==NULL)
    888           {
    889             pSetExp(qq,i, e);
    890           }
    891           else if (perm[i]>0)
    892             pAddExp(qq,perm[i], e/*p_GetExp( p,i,oldRing)*/);
    893           else if (perm[i]<0)
    894           {
    895             if (rField_is_GF())
    896             {
    897               number c=pGetCoeff(qq);
    898               number ee=nfPar(1);
    899               number eee;nfPower(ee,e,&eee); //nfDelete(ee,currRing);
    900               ee=nfMult(c,eee);
    901               //nfDelete(c,currRing);nfDelete(eee,currRing);
    902               pSetCoeff0(qq,ee);
    903             }
    904             else
    905             {
    906               lnumber c=(lnumber)pGetCoeff(qq);
    907               if (c->z->next==NULL)
    908                 napAddExp(c->z,-perm[i],e/*p_GetExp( p,i,oldRing)*/);
    909               else /* more difficult: we have really to multiply: */
    910               {
    911                 lnumber mmc=(lnumber)naInit(1,currRing);
    912                 napSetExp(mmc->z,-perm[i],e/*p_GetExp( p,i,oldRing)*/);
    913                 napSetm(mmc->z);
    914                 pGetCoeff(qq)=naMult((number)c,(number)mmc);
    915                 nDelete((number *)&c);
    916                 nDelete((number *)&mmc);
    917               }
    918               mapped_to_par=1;
    919             }
    920           }
    921           else
    922           {
    923             /* this variable maps to 0 !*/
    924             pLmDelete(&qq);
    925             break;
    926           }
    927         }
    928       }
    929       if (mapped_to_par
    930       && (currRing->minpoly!=NULL))
    931       {
    932         number n=pGetCoeff(qq);
    933         nNormalize(n);
    934         pGetCoeff(qq)=n;
    935       }
    936     }
    937     pIter(p);
    938 #if 1
    939     if (qq!=NULL)
    940     {
    941       pSetm(qq);
    942       pTest(aq);
    943       pTest(qq);
    944       if (aq!=NULL) qq=pMult(aq,qq);
    945       aq = qq;
    946       while (pNext(aq) != NULL) pIter(aq);
    947       if (result_last==NULL)
    948       {
    949         result=qq;
    950       }
    951       else
    952       {
    953         pNext(result_last)=qq;
    954       }
    955       result_last=aq;
    956       aq = NULL;
    957     }
    958     else if (aq!=NULL)
    959     {
    960       pDelete(&aq);
    961     }
    962   }
    963   result=pSortAdd(result);
    964 #else
    965   //  if (qq!=NULL)
    966   //  {
    967   //    pSetm(qq);
    968   //    pTest(qq);
    969   //    pTest(aq);
    970   //    if (aq!=NULL) qq=pMult(aq,qq);
    971   //    aq = qq;
    972   //    while (pNext(aq) != NULL) pIter(aq);
    973   //    pNext(aq) = result;
    974   //    aq = NULL;
    975   //    result = qq;
    976   //  }
    977   //  else if (aq!=NULL)
    978   //  {
    979   //    pDelete(&aq);
    980   //  }
    981   //}
    982   //p = result;
    983   //result = NULL;
    984   //while (p != NULL)
    985   //{
    986   //  qq = p;
    987   //  pIter(p);
    988   //  qq->next = NULL;
    989   //  result = pAdd(result, qq);
    990   //}
    991 #endif
    992   pTest(result);
    993   return result;
    994 }
    995 
    996100poly ppJet(poly p, int m)
    997101{
Note: See TracChangeset for help on using the changeset viewer.