Changeset 24cabe in git


Ignore:
Timestamp:
Sep 26, 2013, 1:38:02 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
260c654e69c12b6deda08c5f3587eff3ac6ace1b
Parents:
9bfdcf268d8535fb2578d07c3ffb3aa4b438f30ecaf5880a642caa3f7049561818c3e0656b00b2d0
Message:
Merge pull request #375 from mmklee/slimgb

Slimgb
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • Tst/Short.lst

    r9bfdcf r24cabe  
    117117Short/bug_tr387.tst
    118118Short/bug_tr404.tst
     119Short/bug_tr485.tst
    119120Short/bug_x_i_j.tst
    120121Short/classify_s.tst
  • Tst/Short/ok_s.lst

    r9bfdcf r24cabe  
    119119bug_tr387
    120120bug_tr404
     121bug_tr485
    121122brnoeth_s
    122123countedref_s
  • kernel/tgb.cc

    r9bfdcf r24cabe  
    3737static const int bundle_size_noro = 10000;
    3838static const int delay_factor = 3;
    39 int QlogSize (number n);
    4039#define ADD_LATER_SIZE 500
    4140#if 1
     
    6463  if(rField_is_Q (r))
    6564  {
    66     return QlogSize (n);
     65    return nlQlogSize (n, r->cf);
    6766  }
    6867  else
     
    178177}
    179178#endif
    180 struct snumber_dummy
    181 {
    182   mpz_t z;
    183   mpz_t n;
    184   #if defined(LDEBUG)
    185   int debug;
    186   #endif
    187   BOOLEAN s;
    188 };
    189 typedef struct snumber_dummy  *number_dummy;
    190 
    191 
    192 int QlogSize (number n)
    193 {
    194   long nl=n_Size(n,currRing->cf);
    195   if (nl==0L) return 0;
    196   if (nl==1L)
    197   {
    198     long i = n_Int(n,currRing->cf);
    199     unsigned long v;
    200     v = (i >= 0) ? i : -i;
    201     int r = 0;
    202 
    203     while(v >>= 1)
    204     {
    205       r++;
    206     }
    207     return r + 1;
    208   }
    209   //assume denominator is 0
    210   number_dummy nn=(number_dummy)n;
    211   return mpz_sizeinbase (nn->z, 2);
    212 }
    213179
    214180#ifdef LEN_VAR3
     
    219185  if(rField_is_Q (currRing))
    220186  {
    221     c = QlogSize (coef);
     187    c = nlQlogSize (coef, currRing->cf);
    222188  }
    223189  else
     
    250216  if(rField_is_Q (currRing))
    251217  {
    252     c = QlogSize (coef);
     218    c = nlQlogSize (coef, currRing->cf);
    253219  }
    254220  else
     
    267233    if(rField_is_Q (currRing))
    268234    {
    269       int modifier = QlogSize (pGetCoeff (b->coef[0]));
     235      int modifier = nlQlogSize (pGetCoeff (b->coef[0]), currRing->cf);
    270236      c += modifier;
    271237    }
     
    297263  if(rField_is_Q (currRing))
    298264  {
    299     c = QlogSize (coef);
     265    c = nlQlogSize (coef, currRing->cf);
    300266  }
    301267  else
     
    323289  if(rField_is_Q (currRing))
    324290  {
    325     c = QlogSize (coef);
     291    c = nlQlogSize (coef, currRing->cf);
    326292  }
    327293  else
     
    340306    if(rField_is_Q (currRing))
    341307    {
    342       int modifier = QlogSize (pGetCoeff (b->coef[0]));
     308      int modifier = nlQlogSize (pGetCoeff (b->coef[0]), currRing->cf);
    343309      c += modifier;
    344310    }
     
    572538      if(rField_is_Q (currRing))
    573539      {
    574         cs = QlogSize (coef);
     540        cs = nlQlogSize (coef, currRing->cf);
    575541      }
    576542      else
     
    626592      if(rField_is_Q (currRing))
    627593      {
    628         cs = QlogSize (coef);
     594        cs = nlQlogSize (coef, currRing->cf);
    629595      }
    630596      else
     
    635601        if(rField_is_Q (currRing))
    636602        {
    637           int modifier = QlogSize (pGetCoeff (bucket->coef[0]));
     603          int modifier = nlQlogSize (pGetCoeff (bucket->coef[0]), currRing->cf);
    638604          cs += modifier;
    639605        }
  • kernel/tgb_internal.h

    r9bfdcf r24cabe  
    6464#include <kernel/kstd1.h>
    6565#include <polys/kbuckets.h>
     66#include <libpolys/coeffs/modulop.h>
    6667
    6768class PolySimple
     
    621622    //assume(impl.find(p_Copy(term,currRing))==impl.end());
    622623    //assume(len==pLength(nf));
    623     assume(n_IsOne(p_GetCoeff(term,currRing),currRing->cf));
     624    assume(npIsOne(p_GetCoeff(term,currRing),currRing->cf));
    624625    if (term==nf)
    625626    {
     
    789790    number coef_bak=p_GetCoeff(t,c->r);
    790791
    791     p_SetCoeff(t,n_Init(1,c->r->cf),c->r);
    792     assume(n_IsOne(p_GetCoeff(c->strat->S[i],c->r),c->r->cf));
     792    p_SetCoeff(t,npInit(1,c->r->cf),c->r);
     793    assume(npIsOne(p_GetCoeff(c->strat->S[i],c->r),c->r->cf));
    793794    number coefstrat=p_GetCoeff(c->strat->S[i],c->r);
    794795
     
    796797    poly exp_diff=cache->temp_term;
    797798    p_ExpVectorDiff(exp_diff,t,c->strat->S[i],c->r);
    798     p_SetCoeff(exp_diff,n_Neg(n_Invers(coefstrat,c->r->cf),c->r->cf),c->r);
     799    p_SetCoeff(exp_diff,npNeg(npInvers(coefstrat,c->r->cf),c->r->cf),c->r);
    799800    p_Setm(exp_diff,c->r);
    800801    assume(c->strat->S[i]!=NULL);
     
    816817  } else {
    817818    number coef_bak=p_GetCoeff(t,c->r);
    818     number one=n_Init(1, c->r->cf);
     819    number one=npInit(1, c->r->cf);
    819820    p_SetCoeff(t,one,c->r);
    820821
     
    933934  const tgb_uint32 prime=n_GetChar(currRing->cf);
    934935  const tgb_uint32 c=F4mat_to_number_type(coef);
    935   assume(!(n_IsZero(coef,currRing->cf)));
     936  assume(!(npIsZero(coef,currRing->cf)));
    936937  for(j=0;j<len;j=j+256)
    937938  {
     
    957958      int idx=idx_array[i];
    958959      assume(bpos<256);
    959       assume(!(n_IsZero((number)(long) buffer[bpos],currRing->cf)));
    960       temp_array[idx]=F4mat_to_number_type(n_Add((number)(long) temp_array[idx], (number)(long) buffer[bpos++],currRing->cf));
     960      assume(!(npIsZero((number)(long) buffer[bpos],currRing->cf)));
     961      temp_array[idx]=F4mat_to_number_type(npAddM((number)(long) temp_array[idx], (number)(long) buffer[bpos++],currRing->cf));
    961962      assume(idx<temp_size);
    962963    }
     
    979980  const tgb_uint32 prime=n_GetChar(currRing->cf);
    980981  const tgb_uint32 c=F4mat_to_number_type(coef);
    981   assume(!(n_IsZero(coef,currRing->cf)));
     982  assume(!(npIsZero(coef,currRing->cf)));
    982983  for(j=0;j<len;j=j+256)
    983984  {
     
    10041005      assume(bpos<256);
    10051006      //assume(!(npIsZero((number) buffer[bpos])));
    1006       temp_array[i]=F4mat_to_number_type(n_Add((number)(long) temp_array[i], (number)(long) buffer[bpos++],currRing->cf));
     1007      temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) buffer[bpos++],currRing->cf));
    10071008      assume(i<temp_size);
    10081009    }
     
    10291030  for(i=0;i<len;i++)
    10301031  {
    1031       temp_array[i]=F4mat_to_number_type(n_Add((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
     1032      temp_array[i]=F4mat_to_number_type(npAddM((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
    10321033      assume(i<temp_size);
    10331034  }
     
    10541055  {
    10551056
    1056       temp_array[i]=F4mat_to_number_type(n_Sub((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
     1057      temp_array[i]=F4mat_to_number_type(npSubM((number)(long) temp_array[i], (number)(long) row[i],currRing->cf));
    10571058      assume(i<temp_size);
    10581059  }
     
    10741075        {
    10751076          int idx=idx_array[j];
    1076           temp_array[idx]=F4mat_to_number_type(   (number_type)(long)n_Add((number) (long)temp_array[idx],(number)(long) coef_array[j],currRing->cf));
     1077          temp_array[idx]=F4mat_to_number_type(   (number_type)(long)npAddM((number) (long)temp_array[idx],(number)(long) coef_array[j],currRing->cf));
    10771078          assume(idx<temp_size);
    10781079        }
     
    10921093        {
    10931094          int idx=idx_array[j];
    1094           temp_array[idx]=F4mat_to_number_type(  (number_type)(long) n_Sub((number) (long)temp_array[idx],(number)(long) coef_array[j],currRing->cf));
     1095          temp_array[idx]=F4mat_to_number_type(  (number_type)(long) npSubM((number) (long)temp_array[idx],(number)(long) coef_array[j],currRing->cf));
    10951096          assume(idx<temp_size);
    10961097        }
     
    11041105   int temp_size=cache->nIrreducibleMonomials;
    11051106   memset(temp_array,0,temp_size_bytes);
    1106    number minus_one=n_Init(-1,currRing->cf);
     1107   number minus_one=npInit(-1,currRing->cf);
    11071108   int i;
    11081109   for(i=0;i<len;i++)
     
    11551156         if (red.ref->value_len==NoroCache<number_type>::backLinkCode)
    11561157         {
    1157            temp_array[red.ref->term_index]=F4mat_to_number_type( n_Add((number)(long) temp_array[red.ref->term_index],red.coef,currRing->cf));
     1158           temp_array[red.ref->term_index]=F4mat_to_number_type( npAddM((number)(long) temp_array[red.ref->term_index],red.coef,currRing->cf));
    11581159         }
    11591160         else
     
    12031204    assume(coef_array[j]!=0);
    12041205    CoefIdx<number_type> ci;
    1205     ci.coef=F4mat_to_number_type(n_Mult((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
     1206    ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
    12061207    ci.idx=idx_array[j];
    12071208    pairs[pos++]=ci;
     
    12181219      assume(coef_array[j]!=0);
    12191220      CoefIdx<number_type> ci;
    1220       ci.coef=F4mat_to_number_type(n_Mult((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
     1221      ci.coef=F4mat_to_number_type(npMultM((number)(long) coef,(number)(long) coef_array[j],currRing->cf));
    12211222      assume(ci.coef!=0);
    12221223      ci.idx=j;
     
    12531254      assume(coef_array[j]!=0);
    12541255      CoefIdx<number_type> ci;
    1255       ci.coef=F4mat_to_number_type(n_Neg((number)(long) coef_array[j],currRing->cf));
     1256      ci.coef=F4mat_to_number_type(npNegM((number)(long) coef_array[j],currRing->cf));
    12561257      assume(ci.coef!=0);
    12571258      ci.idx=j;
     
    12801281    assume(coef_array[j]!=0);
    12811282    CoefIdx<number_type> ci;
    1282     ci.coef=F4mat_to_number_type(n_Neg((number)coef_array[j],currRing->cf));
     1283    ci.coef=F4mat_to_number_type(npNegM((number)coef_array[j],currRing->cf));
    12831284    ci.idx=idx_array[j];
    12841285    pairs[pos++]=ci;
     
    13081309  CoefIdx<number_type>* pairs=(CoefIdx<number_type>*) cache->tempBuffer; //omalloc(together*sizeof(CoefIdx<number_type>));
    13091310  int pos=0;
    1310   const number one=n_Init(1, currRing->cf);
    1311   const number minus_one=n_Init(-1, currRing->cf);
     1311  const number one=npInit(1, currRing->cf);
     1312  const number minus_one=npInit(-1, currRing->cf);
    13121313  for(i=0;i<len;i++)
    13131314  {
     
    13881389    else
    13891390    {
    1390       pairs[act].coef=F4mat_to_number_type(n_Add((number)(long)pairs[act].coef,(number)(long)pairs[i].coef,currRing->cf));
     1391      pairs[act].coef=F4mat_to_number_type(npAddM((number)(long)pairs[act].coef,(number)(long)pairs[i].coef,currRing->cf));
    13911392    }
    13921393  }
     
    15551556    for(i=startIndices[row];i<ncols;i++)
    15561557    {
    1557       row_array[i]=F4mat_to_number_type(n_Mult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
     1558      row_array[i]=F4mat_to_number_type(npMult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
    15581559    }
    15591560  }
     
    15671568    assume(start<ncols);
    15681569    int other_row;
    1569     assume(!(n_IsZero((number)(long) row_array[start],currRing->cf)));
    1570     if (!(n_IsOne((number)(long) coef,currRing->cf)))
    1571       multiplyRow(r,F4mat_to_number_type(n_Invers((number)(long) coef,currRing->cf)));
    1572     assume(n_IsOne((number)(long) row_array[start],currRing->cf));
     1570    assume(!(npIsZero((number)(long) row_array[start],currRing->cf)));
     1571    if (!(npIsOne((number)(long) coef,currRing->cf)))
     1572      multiplyRow(r,F4mat_to_number_type(npInvers((number)(long) coef,currRing->cf)));
     1573    assume(npIsOne((number)(long) row_array[start],currRing->cf));
    15731574    int lastIndex=modP_lastIndexRow(row_array, ncols);
    1574     number minus_one=n_Init(-1, currRing->cf);
     1575    number minus_one=npInit(-1, currRing->cf);
    15751576    for (other_row=r+1;other_row<nrows;other_row++)
    15761577    {
     
    15801581        int i;
    15811582        number_type* other_row_array=rows[other_row];
    1582         number coef2=n_Neg((number)(long) other_row_array[start],currRing->cf);
     1583        number coef2=npNeg((number)(long) other_row_array[start],currRing->cf);
    15831584        if (coef2==minus_one)
    15841585        {
     
    15861587          {
    15871588            if (row_array[i]!=zero)
    1588               other_row_array[i]=F4mat_to_number_type(n_Sub((number)(long) other_row_array[i], (number)(long) row_array[i],currRing->cf));
     1589              other_row_array[i]=F4mat_to_number_type(npSubM((number)(long) other_row_array[i], (number)(long) row_array[i],currRing->cf));
    15891590          }
    15901591      }
     
    15951596          {
    15961597            if (row_array[i]!=zero)
    1597             other_row_array[i]=F4mat_to_number_type(n_Add(n_Mult(coef2,(number)(long) row_array[i],currRing->cf),(number)(long) other_row_array[i],currRing->cf));
     1598            other_row_array[i]=F4mat_to_number_type(npAddM(npMult(coef2,(number)(long) row_array[i],currRing->cf),(number)(long) other_row_array[i],currRing->cf));
    15981599          }
    15991600        }
    16001601        updateStartIndex(other_row,start);
    1601         assume(n_IsZero((number)(long) other_row_array[start],currRing->cf));
     1602        assume(npIsZero((number)(long) other_row_array[start],currRing->cf));
    16021603      }
    16031604    }
     
    16061607  {
    16071608    number_type* row_array=rows[row];
    1608     assume((lower_bound<0)||(n_IsZero((number)(long) row_array[lower_bound],currRing->cf)));
     1609    assume((lower_bound<0)||(npIsZero((number)(long) row_array[lower_bound],currRing->cf)));
    16091610    int i;
    16101611    //number_type zero=npInit(0);
     
    16611662    for(i=startIndices[row];i<ncols;i++)
    16621663    {
    1663       row_array[i]=F4mat_to_number_type(n_Mult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
     1664      row_array[i]=F4mat_to_number_type(npMult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
    16641665    }
    16651666  }
     
    16901691    {
    16911692      assume(startIndices[i]<ncols);
    1692       assume(!(n_IsZero((number)(long) rows[i][startIndices[i]],currRing->cf)));
     1693      assume(!(npIsZero((number)(long) rows[i][startIndices[i]],currRing->cf)));
    16931694      assume(startIndices[i]>=i);
    16941695      updateLastReducibleIndex(i,nonZeroUntil+1);
     
    17191720    number_type zero=0;//npInit(0);
    17201721    number_type* row_array=rows[r];
    1721     assume((!(n_IsZero((number)(long) row_array[start],currRing->cf))));
     1722    assume((!(npIsZero((number)(long) row_array[start],currRing->cf))));
    17221723    assume(start<ncols);
    17231724    int other_row;
    1724     if (!(n_IsOne((number)(long) row_array[r],currRing->cf)))
     1725    if (!(npIsOne((number)(long) row_array[r],currRing->cf)))
    17251726    {
    17261727      //it should be one, but this safety is not expensive
    1727       multiplyRow(r, F4mat_to_number_type(n_Invers((number)(long) row_array[start],currRing->cf)));
     1728      multiplyRow(r, F4mat_to_number_type(npInvers((number)(long) row_array[start],currRing->cf)));
    17281729    }
    17291730    int lastIndex=modP_lastIndexRow(row_array, ncols);
     
    17361737      {
    17371738        number_type* other_row_array=rows[other_row];
    1738         number coef=n_Neg((number)(long) other_row_array[start],currRing->cf);
    1739         assume(!(n_IsZero(coef,currRing->cf)));
     1739        number coef=npNeg((number)(long) other_row_array[start],currRing->cf);
     1740        assume(!(npIsZero(coef,currRing->cf)));
    17401741        int i;
    17411742        assume(start>startIndices[other_row]);
     
    17431744        {
    17441745          if (row_array[i]!=zero)
    1745             other_row_array[i]=F4mat_to_number_type(n_Add(n_Mult(coef,(number)(long)row_array[i],currRing->cf),(number)(long)other_row_array[i],currRing->cf));
     1746            other_row_array[i]=F4mat_to_number_type(npAddM(npMult(coef,(number)(long)row_array[i],currRing->cf),(number)(long)other_row_array[i],currRing->cf));
    17461747        }
    17471748        updateLastReducibleIndex(other_row,r);
  • libpolys/coeffs/longrat.h

    r9bfdcf r24cabe  
    131131
    132132int      nlSize(number n, const coeffs r);
     133
     134static inline int nlQlogSize (number n, const coeffs r)
     135{
     136  assume( rField_is_Q (r) );
     137
     138  long nl=nlSize(n,r);
     139  if (nl==0L) return 0;
     140  if (nl==1L)
     141  {
     142    long i = SR_TO_INT (n);
     143    unsigned long v;
     144    v = (i >= 0) ? i : -i;
     145    int r = 0;
     146
     147    while(v >>= 1)
     148    {
     149      r++;
     150    }
     151    return r + 1;
     152  }
     153  //assume denominator is 0
     154  number nn=(number) n;
     155  return mpz_sizeinbase (nn->z, 2);
     156}
     157
    133158number   nlGetDenom(number &n, const coeffs r);
    134159number   nlGetNumerator(number &n, const coeffs r);
Note: See TracChangeset for help on using the changeset viewer.