Changeset deca086 in git


Ignore:
Timestamp:
Nov 24, 2010, 10:08:24 AM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
97b5d578e13d4df61dceefad1a56f00844cad0ac
Parents:
9634a6736659317223c0fc1209744322e56f824b
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2010-11-24 10:08:24+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:55:42+01:00
Message:
p_PermPoly
Location:
polys
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • polys/monomials/p_polys.cc

    r9634a6 rdeca086  
    29742974}
    29752975
     2976/*2
     2977*returns a re-ordered copy of a polynomial, with permutation of the variables
     2978*/
     2979poly p_PermPoly (poly p, int * perm, const ring oldRing, const ring dst,
     2980       nMapFunc nMap, int *par_perm, int OldPar)
     2981{
     2982  int OldpVariables = oldRing->N;
     2983  poly result = NULL;
     2984  poly result_last = NULL;
     2985  poly aq=NULL; /* the map coefficient */
     2986  poly qq; /* the mapped monomial */
     2987
     2988  while (p != NULL)
     2989  {
     2990    if ((OldPar==0)||(rField_is_GF(oldRing)))
     2991    {
     2992      qq = p_Init(dst);
     2993      number n=nMap(pGetCoeff(p));
     2994      if ((dst->minpoly!=NULL)
     2995      && ((rField_is_Zp_a(dst)) || (rField_is_Q_a(dst))))
     2996      {
     2997        n_Normalize(n,dst->cf);
     2998      }
     2999      pGetCoeff(qq)=n;
     3000    // coef may be zero:  pTest(qq);
     3001    }
     3002    else
     3003    {
     3004      qq=p_One(dst);
     3005      aq=naPermNumber(pGetCoeff(p),par_perm,OldPar, oldRing);
     3006      if ((dst->minpoly!=NULL)
     3007      && ((rField_is_Zp_a(dst)) || (rField_is_Q_a(dst))))
     3008      {
     3009        poly tmp=aq;
     3010        while (tmp!=NULL)
     3011        {
     3012          number n=pGetCoeff(tmp);
     3013          n_Normalize(n,dst->cf);
     3014          pGetCoeff(tmp)=n;
     3015          pIter(tmp);
     3016        }
     3017      }
     3018      pTest(aq);
     3019    }
     3020    if (rRing_has_Comp(dst)) p_SetComp(qq, p_GetComp(p,oldRing),dst);
     3021    if (n_IsZero(pGetCoeff(qq),dst->cf))
     3022    {
     3023      p_LmDelete(&qq,dst);
     3024    }
     3025    else
     3026    {
     3027      int i;
     3028      int mapped_to_par=0;
     3029      for(i=1; i<=OldpVariables; i++)
     3030      {
     3031        int e=p_GetExp(p,i,oldRing);
     3032        if (e!=0)
     3033        {
     3034          if (perm==NULL)
     3035          {
     3036            p_SetExp(qq,i, e, dst);
     3037          }
     3038          else if (perm[i]>0)
     3039            p_AddExp(qq,perm[i], e/*p_GetExp( p,i,oldRing)*/, dst);
     3040          else if (perm[i]<0)
     3041          {
     3042            if (rField_is_GF(dst))
     3043            {
     3044              number c=pGetCoeff(qq);
     3045              number ee=nfPar(1);
     3046              number eee;nfPower(ee,e,&eee); //nfDelete(ee,currRing);
     3047              ee=nfMult(c,eee);
     3048              //nfDelete(c,currRing);nfDelete(eee,currRing);
     3049              pSetCoeff0(qq,ee);
     3050            }
     3051            else
     3052            {
     3053              lnumber c=(lnumber)pGetCoeff(qq);
     3054              if (c->z->next==NULL)
     3055                napAddExp(c->z,-perm[i],e/*p_GetExp( p,i,oldRing)*/);
     3056              else /* more difficult: we have really to multiply: */
     3057              {
     3058                lnumber mmc=(lnumber)naInit(1,currRing);
     3059                napSetExp(mmc->z,-perm[i],e/*p_GetExp( p,i,oldRing)*/);
     3060                napSetm(mmc->z);
     3061                pGetCoeff(qq)=naMult((number)c,(number)mmc);
     3062                n_Delete((number *)&c,dst->cf);
     3063                n_Delete((number *)&mmc,dst->cf);
     3064              }
     3065              mapped_to_par=1;
     3066            }
     3067          }
     3068          else
     3069          {
     3070            /* this variable maps to 0 !*/
     3071            p_LmDelete(&qq,dst);
     3072            break;
     3073          }
     3074        }
     3075      }
     3076      if (mapped_to_par
     3077      && (dst->minpoly!=NULL))
     3078      {
     3079        number n=pGetCoeff(qq);
     3080        n_Normalize(n,dst->cf);
     3081        pGetCoeff(qq)=n;
     3082      }
     3083    }
     3084    pIter(p);
     3085#if 1
     3086    if (qq!=NULL)
     3087    {
     3088      p_Setm(qq,dst);
     3089      p_Test(aq,dst);
     3090      p_Test(qq,dst);
     3091      if (aq!=NULL) qq=p_Mult(aq,qq,dst);
     3092      aq = qq;
     3093      while (pNext(aq) != NULL) pIter(aq);
     3094      if (result_last==NULL)
     3095      {
     3096        result=qq;
     3097      }
     3098      else
     3099      {
     3100        pNext(result_last)=qq;
     3101      }
     3102      result_last=aq;
     3103      aq = NULL;
     3104    }
     3105    else if (aq!=NULL)
     3106    {
     3107      p_Delete(&aq,dst);
     3108    }
     3109  }
     3110  result=p_SortAdd(result,dst);
     3111#else
     3112  //  if (qq!=NULL)
     3113  //  {
     3114  //    pSetm(qq);
     3115  //    pTest(qq);
     3116  //    pTest(aq);
     3117  //    if (aq!=NULL) qq=pMult(aq,qq);
     3118  //    aq = qq;
     3119  //    while (pNext(aq) != NULL) pIter(aq);
     3120  //    pNext(aq) = result;
     3121  //    aq = NULL;
     3122  //    result = qq;
     3123  //  }
     3124  //  else if (aq!=NULL)
     3125  //  {
     3126  //    pDelete(&aq);
     3127  //  }
     3128  //}
     3129  //p = result;
     3130  //result = NULL;
     3131  //while (p != NULL)
     3132  //{
     3133  //  qq = p;
     3134  //  pIter(p);
     3135  //  qq->next = NULL;
     3136  //  result = pAdd(result, qq);
     3137  //}
     3138#endif
     3139  p_Test(result,dst);
     3140  return result;
     3141}
    29763142
    29773143/***************************************************************
  • polys/monomials/p_polys.h

    r9634a6 rdeca086  
    18181818void p_SetModDeg(intvec *w, ring r);
    18191819
     1820
     1821
     1822poly      p_PermPoly (poly p, int * perm,const ring OldRing, const ring dst,
     1823                     nMapFunc nMap, int *par_perm=NULL, int OldPar=0);
     1824
    18201825#endif // P_POLYS_H
    18211826
  • polys/polys.h

    r9634a6 rdeca086  
    262262#define   pMaxComp(p)   p_MaxComp(p, currRing)
    263263#define   pMinComp(p)   p_MinComp(p, currRing)
    264 int pMaxCompProc(poly p);
    265264
    266265#define   pOneComp(p)       p_OneComp(p, currRing)
     
    292291// #define   pDehomogen(p1,p2,n) p_Dehomgen(p1,p2,n,currRing)
    293292// #define   pIsHomogen(p)       p_IsHomggen(p,currRing)
    294 
    295 poly      pPermPoly (poly p, int * perm,const ring OldRing, nMapFunc nMap,
    296                      int *par_perm=NULL, int OldPar=0);
    297293
    298294/*BOOLEAN   pVectorHasUnitM(poly p, int * k);*/
  • polys/polys1.cc

    r9634a6 rdeca086  
    7878  }
    7979  omFreeSize((ADDRESS)bin, h*sizeof(number));
    80 }
    81 
    82 int pMaxCompProc(poly p)
    83 {
    84   return pMaxComp(p);
    8580}
    8681
Note: See TracChangeset for help on using the changeset viewer.