Changeset e77676 in git for libpolys/coeffs/modulop.cc


Ignore:
Timestamp:
Jan 6, 2012, 9:43:08 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
4b38e3cc9992129dd4ef044c1d2cc7e55f93b134
Parents:
40e88db63c509564c2b00b7142b39ef6b846f72e
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-01-06 21:43:08+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-01-06 21:59:37+01:00
Message:
Zp cleanup (no more coeffs::npPrimeM)

CHG: removed coeffs::npPrimeM in favour of coeffs::ch
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/modulop.cc

    r40e88db re77676  
    5757 
    5858  int h = (int)((long) k);
    59   return ((int)h !=0) && (h <= (r->npPrimeM>>1));
    60 }
    61 
    62 //unsigned long npMultMod(unsigned long a, unsigned long b)
     59  return ((int)h !=0) && (h <= (r->ch>>1));
     60}
     61
     62//unsigned long npMultMod(unsigned long a, unsigned long b, int npPrimeM)
    6363//{
    6464//  unsigned long c = a*b;
    6565//  c = c % npPrimeM;
    66 //  assume(c == (unsigned long) npMultM((number) a, (number) b));
     66//  assume(c == (unsigned long) npMultM((number) a, (number) b, npPrimeM));
    6767//  return c;
    6868//}
     
    167167
    168168#ifdef USE_NTL_XGCD
    169    XGCD(d, s, t, a, R->npPrimeM);
     169   XGCD(d, s, t, a, R->ch);
    170170   assume (d == 1);
    171171#else
     
    174174   assume(a>0);
    175175   u1=1; u2=0;
    176    u = a; v = R->npPrimeM;
     176   u = a; v = R->ch;
    177177
    178178   while (v != 0)
     
    191191#endif
    192192   if (s < 0)
    193       return s + R->npPrimeM;
     193      return s + R->ch;
    194194   else
    195195      return s;
     
    222222
    223223//#ifdef NV_OPS
    224 //  if (npPrimeM>NV_MAX_PRIME)
     224//  if (r->ch>NV_MAX_PRIME)
    225225//    return nvDiv(a,b);
    226226//#endif
     
    339339      ii *= 10;
    340340      ii += *s++ - '0';
    341       if (ii >= (MAX_INT_VAL / 10)) ii = ii % r->npPrimeM;
     341      if (ii >= (MAX_INT_VAL / 10)) ii = ii % r->ch;
    342342    }
    343343    while (((*s) >= '0') && ((*s) <= '9'));
    344     if (ii >= r->npPrimeM) ii = ii % r->npPrimeM;
     344    if (ii >= r->ch) ii = ii % r->ch;
    345345    *i=(int)ii;
    346346  }
     
    368368    {
    369369#ifdef NV_OPS
    370       if (r->npPrimeM>NV_MAX_PRIME)
     370      if (r->ch>NV_MAX_PRIME)
    371371        *a = nvDiv((number)z,(number)n,r);
    372372      else
     
    387387  #ifdef HAVE_DIV_MOD
    388388  if (r->npInvTable!=NULL)
    389   omFreeSize( (void *)r->npInvTable, r->npPrimeM*sizeof(unsigned short) );
     389  omFreeSize( (void *)r->npInvTable, r->ch*sizeof(unsigned short) );
    390390  r->npInvTable=NULL;
    391391  #else
    392392  if (r->npExpTable!=NULL)
    393393  {
    394     omFreeSize( (void *)r->npExpTable, r->npPrimeM*sizeof(unsigned short) );
    395     omFreeSize( (void *)r->npLogTable, r->npPrimeM*sizeof(unsigned short) );
     394    omFreeSize( (void *)r->npExpTable, r->ch*sizeof(unsigned short) );
     395    omFreeSize( (void *)r->npLogTable, r->ch*sizeof(unsigned short) );
    396396    r->npExpTable=NULL; r->npLogTable=NULL;
    397397  }
     
    407407CanonicalForm npConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
    408408{
    409   if (setChar) setCharacteristic( r->npPrimeM );
     409  if (setChar) setCharacteristic( r->ch );
    410410  CanonicalForm term(npInt( n,r ));
    411411  return term;
     
    436436  int i, w;
    437437
    438   r->npPrimeM = c;
    439   r->npPminus1M = c /*r->npPrimeM*/ - 1;
     438  r->ch = c;
     439  r->npPminus1M = c /*r->ch*/ - 1;
    440440
    441441  //r->cfInitChar=npInitChar;
     
    514514  // the tables
    515515#ifdef NV_OPS
    516   if (r->npPrimeM <=NV_MAX_PRIME)
     516  if (r->ch <=NV_MAX_PRIME)
    517517#endif
    518518  {
    519519#if !defined(HAVE_DIV_MOD) || !defined(HAVE_MULT_MOD)
    520     r->npExpTable=(unsigned short *)omAlloc( r->npPrimeM*sizeof(unsigned short) );
    521     r->npLogTable=(unsigned short *)omAlloc( r->npPrimeM*sizeof(unsigned short) );
     520    r->npExpTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
     521    r->npLogTable=(unsigned short *)omAlloc( r->ch*sizeof(unsigned short) );
    522522    r->npExpTable[0] = 1;
    523523    r->npLogTable[0] = 0;
    524     if (r->npPrimeM > 2)
     524    if (r->ch > 2)
    525525    {
    526526      w = 1;
     
    534534          i++;
    535535          r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1])
    536                                % r->npPrimeM);
     536                               % r->ch);
    537537          r->npLogTable[r->npExpTable[i]] = i;
    538           if (/*(i == npPrimeM - 1 ) ||*/ (r->npExpTable[i] == 1))
     538          if (/*(i == r->ch - 1 ) ||*/ (r->npExpTable[i] == 1))
    539539            break;
    540540        }
    541         if (i == r->npPrimeM - 1)
     541        if (i == r->ch - 1)
    542542          break;
    543543      }
     
    550550#endif
    551551#ifdef HAVE_DIV_MOD
    552     r->npInvTable=(unsigned short*)omAlloc0( r->npPrimeM*sizeof(unsigned short) );
     552    r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) );
    553553#endif
    554554  }
     
    559559BOOLEAN npDBTest (number a, const char *f, const int l, const coeffs r)
    560560{
    561   if (((long)a<0) || ((long)a>r->npPrimeM))
     561  if (((long)a<0) || ((long)a>r->ch))
    562562  {
    563563    Print("wrong mod p number %ld at %s,%d\n",(long)a,f,l);
     
    571571{
    572572  long i = (long)from;
    573   if (i>src->npPrimeM/2)
    574   {
    575     i-=src->npPrimeM;
    576     while (i < 0) i+=dst_r->npPrimeM;
    577   }
    578   i%=dst_r->npPrimeM;
     573  if (i>src->ch/2)
     574  {
     575    i-=src->ch;
     576    while (i < 0) i+=dst_r->ch;
     577  }
     578  i%=dst_r->ch;
    579579  return (number)i;
    580580}
     
    604604  }
    605605
    606   if(dst_r->npPrimeM>2)
     606  if(dst_r->ch>2)
    607607    e=(*f)[0]._mp_exp-size;
    608608  else
     
    629629    ndest->_mp_alloc = ndest->_mp_size = bl;
    630630    res->s = 0;
    631     in=mpz_fdiv_ui(ndest,dst_r->npPrimeM);
     631    in=mpz_fdiv_ui(ndest,dst_r->ch);
    632632    mpz_clear(ndest);
    633633  }
     
    644644  dest->_mp_d = dd;
    645645  dest->_mp_alloc = al;
    646   iz=mpz_fdiv_ui(dest,dst_r->npPrimeM);
     646  iz=mpz_fdiv_ui(dest,dst_r->ch);
    647647  mpz_clear(dest);
    648648  if(res->s==0)
     
    661661  mpz_init(erg);
    662662
    663   mpz_mod_ui(erg, (int_number) from, dst->npPrimeM);
     663  mpz_mod_ui(erg, (int_number) from, dst->ch);
    664664  number r = (number) mpz_get_si(erg);
    665665
     
    674674number npMapMachineInt(number from, const coeffs /*src*/,const coeffs dst)
    675675{
    676   long i = (long) (((unsigned long) from) % dst->npPrimeM);
     676  long i = (long) (((unsigned long) from) % dst->ch);
    677677  return (number) i;
    678678}
     
    682682number npMapCanonicalForm (number a, const coeffs /*src*/, const coeffs dst)
    683683{
    684   setCharacteristic (dst ->npPrimeM);
     684  setCharacteristic (dst ->ch);
    685685  CanonicalForm f= CanonicalForm ((InternalCF*)(a));
    686686  return (number) (f.intval());
     
    756756   u1=1; v1=0;
    757757   u2=0; v2=1;
    758    u = a; v = R->npPrimeM;
     758   u = a; v = R->ch;
    759759
    760760   while (v != 0)
     
    775775   //t = v1;
    776776   if (s < 0)
    777       return s + R->npPrimeM;
     777      return s + R->ch;
    778778   else
    779779      return s;
     
    831831void    npCoeffWrite  (const coeffs r, BOOLEAN /*details*/)
    832832{
    833   Print("//   characteristic : %d\n",r->npPrimeM);
    834 }
    835 
     833  Print("//   characteristic : %d\n",r->ch);
     834}
     835
Note: See TracChangeset for help on using the changeset viewer.