Changeset 71ba5b8 in git


Ignore:
Timestamp:
Mar 14, 2011, 2:17:59 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
f2c9d702b900671c1430c68b61f0cc0c5883a3fe
Parents:
6f43a604effeab2d302d92bcbe3e726674616371
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-03-14 14:17:59+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:01:05+01:00
Message:
removed polys.cc
Location:
libpolys/polys
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/Makefile.am

    r6f43a60 r71ba5b8  
    1313        pDebug.cc pInline0.cc \
    1414        operations/pShallowCopyDelete.cc operations/p_Mult_q.cc \
    15         templates/p_Procs_Lib.cc polys.cc \
     15        templates/p_Procs_Lib.cc \
    1616        polys0.cc polys1.cc prCopy.cc prCopyTemplate.cc \
    1717        kbuckets.cc sbuckets.cc templates/p_Procs.cc
  • libpolys/polys/configure.ac

    r6f43a60 r71ba5b8  
    66AC_CONFIG_AUX_DIR([.])
    77AM_INIT_AUTOMAKE
    8 AC_CONFIG_SRCDIR([polys.cc])
     8AC_CONFIG_SRCDIR([pDebug.cc])
    99AC_CONFIG_HEADERS([config.h])
    1010AC_CONFIG_MACRO_DIR([m4])
  • libpolys/polys/kbuckets.h

    r6f43a60 r71ba5b8  
    55****************************************/
    66/* $Id$ */
    7 #include <kernel/structs.h>
    8 #include <kernel/p_Procs.h>
    9 #include <kernel/pShallowCopyDelete.h>
     7#include <polys/templates/p_Procs.h>
     8#include <polys/operations/pShallowCopyDelete.h>
    109
    1110//#define HAVE_COEF_BUCKETS
     
    2120// Creation/Destruction of buckets
    2221//
    23 kBucket_pt kBucketCreate(ring r = currRing);
     22kBucket_pt kBucketCreate(ring r);
    2423// only free memory allocated for bucket
    2524void kBucketDestroy(kBucket_pt *bucket);
  • libpolys/polys/monomials/p_polys.cc

    r6f43a60 r71ba5b8  
    223223            }
    224224          }
    225            
    226225#ifndef NDEBUG
    227226          for( int i = 1; i <= r->N; i++ ) // No v[0] here!!!
     
    12311230    }
    12321231#endif
    1233    
     1232
    12341233    p_Setm(rc,r);
    12351234  }
    1236 finish: 
     1235finish:
    12371236  return s;
    12381237}
     
    23492348    }
    23502349    if (h!=NULL) n_Delete(&h,r->cf);
    2351  
     2350
    23522351    p_Content(ph,r);
    23532352#ifdef HAVE_RATGRING
     
    25512550  if (r->pLexOrder && (r->order[0]==ringorder_lp))
    25522551    d=p_Totaldegree;
    2553   else 
     2552  else
    25542553    d=pFDeg;
    25552554  o = d(p,r);
     
    29022901}
    29032902
     2903/*2
     2904*divides p1 by its leading coefficient
     2905*/
     2906void p_Norm(poly p1, const ring r)
     2907{
     2908#ifdef HAVE_RINGS
     2909  if (rField_is_Ring(r))
     2910  {
     2911    if (!nIsUnit(pGetCoeff(p1))) return;
     2912    // Werror("p_Norm not possible in the case of coefficient rings.");
     2913  }
     2914  else
     2915#endif
     2916  if (p1!=NULL)
     2917  {
     2918    if (pNext(p1)==NULL)
     2919    {
     2920      p_SetCoeff(p1,n_Init(1,r->cf),r);
     2921      return;
     2922    }
     2923    poly h;
     2924    if (!n_IsOne(pGetCoeff(p1),r->cf))
     2925    {
     2926      number k, c;
     2927      n_Normalize(pGetCoeff(p1),r->cf);
     2928      k = pGetCoeff(p1);
     2929      c = n_Init(1,r->cf);
     2930      pSetCoeff0(p1,c);
     2931      h = pNext(p1);
     2932      while (h!=NULL)
     2933      {
     2934        c=n_Div(pGetCoeff(h),k,r->cf);
     2935        // no need to normalize: Z/p, R
     2936        // normalize already in nDiv: Q_a, Z/p_a
     2937        // remains: Q
     2938        if (rField_is_Q(r) && (!n_IsOne(c,r->cf))) n_Normalize(c,r->cf);
     2939        p_SetCoeff(h,c,r);
     2940        pIter(h);
     2941      }
     2942      n_Delete(&k,r->cf);
     2943    }
     2944    else
     2945    {
     2946      //if (r->cf->cfNormalize != nDummy2) //TODO: OPTIMIZE
     2947      {
     2948        h = pNext(p1);
     2949        while (h!=NULL)
     2950        {
     2951          n_Normalize(pGetCoeff(h),r->cf);
     2952          pIter(h);
     2953        }
     2954      }
     2955    }
     2956  }
     2957}
     2958
     2959/*2
     2960*normalize all coefficients
     2961*/
     2962void p_Normalize(poly p,const ring r)
     2963{
     2964  if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
     2965  while (p!=NULL)
     2966  {
     2967#ifdef LDEBUG
     2968    if (currRing==r) {nTest(pGetCoeff(p));}
     2969#endif
     2970    n_Normalize(pGetCoeff(p),r->cf);
     2971    pIter(p);
     2972  }
     2973}
     2974
     2975// splits p into polys with Exp(n) == 0 and Exp(n) != 0
     2976// Poly with Exp(n) != 0 is reversed
     2977static void p_SplitAndReversePoly(poly p, int n, poly *non_zero, poly *zero, const ring r)
     2978{
     2979  if (p == NULL)
     2980  {
     2981    *non_zero = NULL;
     2982    *zero = NULL;
     2983    return;
     2984  }
     2985  spolyrec sz;
     2986  poly z, n_z, next;
     2987  z = &sz;
     2988  n_z = NULL;
     2989
     2990  while(p != NULL)
     2991  {
     2992    next = pNext(p);
     2993    if (p_GetExp(p, n,r) == 0)
     2994    {
     2995      pNext(z) = p;
     2996      pIter(z);
     2997    }
     2998    else
     2999    {
     3000      pNext(p) = n_z;
     3001      n_z = p;
     3002    }
     3003    p = next;
     3004  }
     3005  pNext(z) = NULL;
     3006  *zero = pNext(&sz);
     3007  *non_zero = n_z;
     3008}
     3009/*3
     3010* substitute the n-th variable by 1 in p
     3011* destroy p
     3012*/
     3013static poly p_Subst1 (poly p,int n, const ring r)
     3014{
     3015  poly qq=NULL, result = NULL;
     3016  poly zero=NULL, non_zero=NULL;
     3017
     3018  // reverse, so that add is likely to be linear
     3019  p_SplitAndReversePoly(p, n, &non_zero, &zero,r);
     3020
     3021  while (non_zero != NULL)
     3022  {
     3023    assume(p_GetExp(non_zero, n,r) != 0);
     3024    qq = non_zero;
     3025    pIter(non_zero);
     3026    qq->next = NULL;
     3027    p_SetExp(qq,n,0,r);
     3028    p_Setm(qq,r);
     3029    result = p_Add_q(result,qq,r);
     3030  }
     3031  p = p_Add_q(result, zero,r);
     3032  p_Test(p,r);
     3033  return p;
     3034}
     3035
     3036/*3
     3037* substitute the n-th variable by number e in p
     3038* destroy p
     3039*/
     3040static poly p_Subst2 (poly p,int n, number e, const ring r)
     3041{
     3042  assume( ! n_IsZero(e,r->cf) );
     3043  poly qq,result = NULL;
     3044  number nn, nm;
     3045  poly zero, non_zero;
     3046
     3047  // reverse, so that add is likely to be linear
     3048  p_SplitAndReversePoly(p, n, &non_zero, &zero,r);
     3049
     3050  while (non_zero != NULL)
     3051  {
     3052    assume(p_GetExp(non_zero, nm,r) != 0);
     3053    qq = non_zero;
     3054    pIter(non_zero);
     3055    qq->next = NULL;
     3056    n_Power(e, p_GetExp(qq, n, r), &nn,r->cf);
     3057    nm = n_Mult(nn, pGetCoeff(qq),r->cf);
     3058#ifdef HAVE_RINGS
     3059    if (n_IsZero(nm,r->cf))
     3060    {
     3061      p_LmFree(&qq,r);
     3062      n_Delete(&nm,r->cf);
     3063    }
     3064    else
     3065#endif
     3066    {
     3067      p_SetCoeff(qq, nm,r);
     3068      p_SetExp(qq, n, 0,r);
     3069      p_Setm(qq,r);
     3070      result = p_Add_q(result,qq,r);
     3071    }
     3072    n_Delete(&nn,r->cf);
     3073  }
     3074  p = p_Add_q(result, zero,r);
     3075  p_Test(p,r);
     3076  return p;
     3077}
     3078
     3079
     3080/* delete monoms whose n-th exponent is different from zero */
     3081static poly p_Subst0(poly p, int n, const ring r)
     3082{
     3083  spolyrec res;
     3084  poly h = &res;
     3085  pNext(h) = p;
     3086
     3087  while (pNext(h)!=NULL)
     3088  {
     3089    if (p_GetExp(pNext(h),n,r)!=0)
     3090    {
     3091      p_LmDelete(&pNext(h),r);
     3092    }
     3093    else
     3094    {
     3095      pIter(h);
     3096    }
     3097  }
     3098  p_Test(pNext(&res),r);
     3099  return pNext(&res);
     3100}
     3101
     3102/*2
     3103* substitute the n-th variable by e in p
     3104* destroy p
     3105*/
     3106poly p_Subst(poly p, int n, poly e, const ring r)
     3107{
     3108  if (e == NULL) return p_Subst0(p, n,r);
     3109
     3110  if (p_IsConstant(e,r))
     3111  {
     3112    if (n_IsOne(pGetCoeff(e),r->cf)) return p_Subst1(p,n,r);
     3113    else return p_Subst2(p, n, pGetCoeff(e),r);
     3114  }
     3115
     3116#ifdef HAVE_PLURAL
     3117  if (rIsPluralRing(r))
     3118  {
     3119    return nc_pSubst(p,n,e,r);
     3120  }
     3121#endif
     3122
     3123  int exponent,i;
     3124  poly h, res, m;
     3125  int *me,*ee;
     3126  number nu,nu1;
     3127
     3128  me=(int *)omAlloc((rVar(r)+1)*sizeof(int));
     3129  ee=(int *)omAlloc((rVar(r)+1)*sizeof(int));
     3130  if (e!=NULL) p_GetExpV(e,ee,r);
     3131  res=NULL;
     3132  h=p;
     3133  while (h!=NULL)
     3134  {
     3135    if ((e!=NULL) || (p_GetExp(h,n,r)==0))
     3136    {
     3137      m=p_Head(h,r);
     3138      p_GetExpV(m,me,r);
     3139      exponent=me[n];
     3140      me[n]=0;
     3141      for(i=rVar(r);i>0;i--)
     3142        me[i]+=exponent*ee[i];
     3143      p_SetExpV(m,me,r);
     3144      if (e!=NULL)
     3145      {
     3146        n_Power(pGetCoeff(e),exponent,&nu,r->cf);
     3147        nu1=n_Mult(pGetCoeff(m),nu,r->cf);
     3148        n_Delete(&nu,r->cf);
     3149        p_SetCoeff(m,nu1,r);
     3150      }
     3151      res=p_Add_q(res,m,r);
     3152    }
     3153    p_LmDelete(&h,r);
     3154  }
     3155  omFreeSize((ADDRESS)me,(rVar(r)+1)*sizeof(int));
     3156  omFreeSize((ADDRESS)ee,(rVar(r)+1)*sizeof(int));
     3157  return res;
     3158}
    29043159/*2
    29053160*returns a re-ordered copy of a polynomial, with permutation of the variables
     
    29823237            else
    29833238            {
    2984               WerrorS("longalg missing");
    2985               #if 0
     3239              WerrorS("longalg missing");
     3240              #if 0
    29863241              lnumber c=(lnumber)pGetCoeff(qq);
    29873242              if (c->z->next==NULL)
     
    29943249                pGetCoeff(qq)=n_Mult((number)c,(number)mmc,dst->cf);
    29953250                n_Delete((number *)&c,dst->cf);
    2996                 n_Delete((number *)&mmc,dst->cf); 
     3251                n_Delete((number *)&mmc,dst->cf);
    29973252              }
    29983253              mapped_to_par=1;
    2999               #endif
     3254              #endif
    30003255            }
    30013256          }
     
    30893344#include <polys/templates/p_Delete__T.cc>
    30903345
     3346#ifdef HAVE_RINGS
     3347/* TRUE iff LT(f) | LT(g) */
     3348BOOLEAN p_DivisibleByRingCase(poly f, poly g, const ring r)
     3349{
     3350  int exponent;
     3351  for(int i = (int)r->N; i; i--)
     3352  {
     3353    exponent = p_GetExp(g, i, r) - p_GetExp(f, i, r);
     3354    if (exponent < 0) return FALSE;
     3355  }
     3356  return n_DivBy(p_GetCoeff(g,r), p_GetCoeff(f,r),r->cf);
     3357}
     3358#endif
  • libpolys/polys/monomials/p_polys.h

    r6f43a60 r71ba5b8  
    300300 *
    301301 ***************************************************************/
     302void      p_Norm(poly p1, const ring r);
    302303void      p_Normalize(poly p,const ring r);
    303304
     
    318319static inline void p_Setm(poly p, const ring r);
    319320p_SetmProc p_GetSetmProc(ring r);
     321
     322poly      p_Subst(poly p, int n, poly e, const ring r);
    320323
    321324// TODO:
  • libpolys/polys/operations/p_Mult_q.cc

    r6f43a60 r71ba5b8  
    2121#include <polys/templates/p_Procs.h>
    2222#include <polys/templates/p_Numbers.h>
    23 // #include <???/kbuckets.h>
     23#include <polys/kbuckets.h>
    2424
    2525#include <polys/operations/p_Mult_q.h>
  • libpolys/polys/polys.h

    r6f43a60 r71ba5b8  
    315315void      pSetPolyComp(poly p, int comp);
    316316#define   pDeleteComp(p,k) p_DeleteComp(p,k,currRing)
    317 void      pNorm(poly p);
    318 poly      pSubst(poly p, int n, poly e);
     317#define   pNorm(p) p_Norm(p,currRing)
     318#define   pSubst(p,n,e) p_Subst(p,n.e,currRing)
    319319poly      ppJet(poly p, int m);
    320320poly      pJet(poly p, int m);
  • libpolys/polys/templates/p_Procs_Lib.cc

    r6f43a60 r71ba5b8  
    1212#include <misc/auxiliary.h>
    1313// #include <polys/structs.h>
    14 #include <polys/p_polys.h>
     14#include <polys/monomials/p_polys.h>
    1515#include <polys/monomials/ring.h>
    16 #include <polys/p_Procs.h>
    17 #include <polys/p_Numbers.h>
    18 #include <polys/p_MemCmp.h>
    19 #include <polys/p_MemAdd.h>
    20 #include <polys/p_MemCopy.h>
     16#include <polys/templates/p_Procs.h>
     17#include <polys/templates/p_Numbers.h>
     18#include <polys/templates/p_MemCmp.h>
     19#include <polys/templates/p_MemAdd.h>
     20#include <polys/templates/p_MemCopy.h>
    2121//#include <polys/kbuckets.h>
    2222
Note: See TracChangeset for help on using the changeset viewer.