Changeset dc0f002 in git


Ignore:
Timestamp:
Jun 1, 2018, 8:40:44 PM (6 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
6762a65369cd0f5360fcace6708a983889b21d71
Parents:
f5850b632ea8ec8eaa23aca3fefbf32685cac3be
Message:
Clean ups
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/kInline.h

    rf5850b rdc0f002  
    2626#include "kernel/polys.h"
    2727
     28#include "kernel/GBEngine/shiftgb.h"
    2829
    2930#define HAVE_TAIL_BIN
     
    591592//    tailRing->p_Procs->p_Minus_mm_Mult_qq(pNext(_p), m, q, shorter,spNoether, tailRing, last);
    592593//    pLength += lq - shorter;
    593   }
    594 }
    595 
    596 KINLINE void sLObject::Tail_Minus_mm1_Mult_qq_Mult_mm2(poly m1, poly q, poly m2, int lq, poly spNoether)
    597 {
    598   if (bucket != NULL)
    599   {
    600     kBucket_Minus_m1_Mult_p_Mult_m2(bucket, m1, q, m2, &lq, NULL); // check if we need noether
    601   }
    602   else
    603   {
    604     if (lq<=0) lq= ::pLength(q);
    605     poly _p = (t_p != NULL ? t_p : p);
    606     assume(_p != NULL);
    607 
    608     int lp=pLength-1;
    609     pNext(_p) = p_Minus_mm_Mult_qq( pNext(_p), m1, p_Mult_mm(q, m2, tailRing), lp, lq,
    610         spNoether, tailRing );
    611     pLength=lp+1;
    612     return;
    613594  }
    614595}
  • kernel/GBEngine/kspoly.cc

    rf5850b rdc0f002  
    2020#include "kernel/polys.h"
    2121#endif
     22#include "kernel/GBEngine/shiftgb.h"
    2223
    2324#ifdef KDEBUG
     
    123124  }
    124125
    125   int holeStart = tailRing->isLPring * p_mFirstVblock(p2, tailRing->isLPring, tailRing);
    126   // n1 and n2 is already set to 1
    127   poly n1 = p_GetExp_k_n(lm, holeStart, tailRing->N, tailRing);
    128   poly n2 = p_GetExp_k_n(lm, 1, holeStart, tailRing);
     126  poly lmRight;
     127  if (tailRing->isLPring) {
     128    k_SplitFrame(p2, lm, lmRight, tailRing);
     129  }
    129130
    130131  // take care of coef buisness
     
    135136    int ct = ksCheckCoeff(&an, &bn, tailRing->cf);    // Calculate special LC
    136137    p_SetCoeff(lm, bn, tailRing);
    137     p_SetCoeff(n1, bn, tailRing);
    138138    if ((ct == 0) || (ct == 2))
    139139      PR->Tail_Mult_nn(an);
     
    143143  else
    144144  {
    145     p_SetCoeff(n1, pGetCoeff(lm), tailRing);
    146145    if (coef != NULL) *coef = n_Init(1, tailRing->cf);
    147146  }
     147
    148148
    149149  // and finally,
    150150  if (tailRing->isLPring) {
    151     PR->Tail_Minus_mm1_Mult_qq_Mult_mm2(n1, t2, n2, pLength(t2), spNoether);
     151    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
    152152  } else {
    153153    PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     
    265265  }
    266266
     267  poly lmRight;
     268  if (tailRing->isLPring) {
     269    k_SplitFrame(p2, lm, lmRight, tailRing);
     270  }
     271
    267272  // take care of coef buisness
    268273  if (! n_IsOne(pGetCoeff(p2), tailRing))
     
    284289
    285290  // and finally,
    286   PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     291  if (tailRing->isLPring) {
     292    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
     293  } else {
     294    PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     295  }
    287296  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    288297  PR->LmDeleteAndIter();
     
    471480  }
    472481
     482  poly lmRight;
     483  if (tailRing->isLPring) {
     484    k_SplitFrame(p2, lm, lmRight, tailRing);
     485  }
     486
    473487  // take care of coef buisness
    474488  if (! n_IsOne(pGetCoeff(p2), tailRing->cf))
     
    490504
    491505  // and finally,
    492   PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     506  if (tailRing->isLPring) {
     507    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
     508  } else {
     509    PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     510  }
    493511  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    494512  PR->LmDeleteAndIter();
     
    709727    }
    710728  }
     729
     730  poly lmRight;
     731  if (tailRing->isLPring) {
     732    k_SplitFrame(p2, lm, lmRight, tailRing);
     733  }
     734
    711735  // take care of coef buisness
    712736  if(rField_is_Ring(currRing))
     
    735759
    736760  // and finally,
    737   PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     761  if (tailRing->isLPring) {
     762    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
     763  } else {
     764    PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     765  }
    738766  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    739767  PR->LmDeleteAndIter();
     
    812840    k_GetLeadTerms(p1, p2, currRing, m1, m2, tailRing);
    813841
     842  poly m12, m22;
     843  if (tailRing->isLPring)
     844  {
     845    k_SplitFrame(p1, m1, m12, tailRing);
     846    k_SplitFrame(p1, m2, m22, tailRing);
     847    // manually free the coeffs, because pSetCoeff0 is used in the next step
     848    n_Delete(&(m1->coef), tailRing->cf);
     849    n_Delete(&(m2->coef), tailRing->cf);
     850  }
     851
    814852  pSetCoeff0(m1, lc2);
    815853  pSetCoeff0(m2, lc1);  // and now, m1 * LT(p1) == m2 * LT(p2)
     
    843881  }
    844882  else
    845     a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
     883    if (tailRing->isLPring) {
     884      // m2*a2*m22
     885      a2 = tailRing->p_Procs->pp_Mult_mm(tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing), m22, tailRing);
     886    } else {
     887      a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
     888    }
    846889#ifdef HAVE_RINGS
    847890  if (!(rField_is_Domain(currRing))) l2 = pLength(a2);
     
    850893  Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
    851894
    852   // get m2*a2 - m1*a1
    853   Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
     895  if (tailRing->isLPring) {
     896    // get m2*a2*m22 - m1*a1*m12
     897    Pair->Tail_Minus_mm_Mult_qq(m1, tailRing->p_Procs->p_Mult_mm(a1, m12, tailRing), l1, spNoether);
     898  } else {
     899    // get m2*a2 - m1*a1
     900    Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
     901  }
    854902
    855903  // Clean-up time
    856904  Pair->LmDeleteAndIter();
    857905  p_LmDelete(m1, tailRing);
     906  if (tailRing->isLPring) {
     907    p_LmDelete(m12, tailRing);
     908    p_LmDelete(m22, tailRing);
     909  }
    858910
    859911  if (co != 0)
  • kernel/GBEngine/kutil.h

    rf5850b rdc0f002  
    212212                         int use_bucket, ring r);
    213213  KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether);
    214   KINLINE void Tail_Minus_mm1_Mult_qq_Mult_mm2(poly m1, poly qq, poly m2, int lq, poly spNoether);
    215214  KINLINE void Tail_Mult_nn(number n);
    216215  // deletes bucket, makes sure that p and t_p exists
  • kernel/GBEngine/shiftgb.cc

    rf5850b rdc0f002  
    9898  /* p is a monomial from the ring r */
    9999
    100   if (sh == 0 || p == NULL) return(p); /* the zero shift */
     100  if (sh == 0 || p == NULL || p_LmIsConstant(p,r)) return(p);
    101101
    102102  int L = p_mLastVblock(p,lV,r);
    103103  assume(L+sh>=1);
    104104  assume(L+sh<=uptodeg);
     105  if (!(L+sh<=uptodeg)){
     106    int i = 5;
     107  }
    105108
    106109  int *e=(int *)omAlloc0((r->N+1)*sizeof(int));
     
    465468
    466469#endif
     470
     471// splits a frame (e.g. x(1)*y(5)) m1 into m1 and m2 (e.g. m1=x(1) and m2=y(1)) according to p
     472void k_SplitFrame(const poly p, poly &m1, poly &m2, const ring r) {
     473  int lV = r->isLPring;
     474  int uptodeg = r->N/lV;
     475
     476  number m1Coeff = pGetCoeff(m1);
     477
     478  int hole = lV * p_mFirstVblock(p, lV, r);
     479  m2 = p_GetExp_k_n(m1, 1, hole, r);
     480  m1 = p_GetExp_k_n(m1, hole, r->N, r);
     481
     482  p_LPshift(m2, 1 - p_mFirstVblock(m2, lV, r), uptodeg, lV, r);
     483  p_SetCoeff(m1, m1Coeff, r);
     484}
  • kernel/GBEngine/shiftgb.h

    rf5850b rdc0f002  
    4646int itoInsert(poly p, int uptodeg, int lV, const ring r);
    4747
     48void k_SplitFrame(const poly p, poly &m1, poly &m2, const ring r);
    4849#endif
    4950#endif
  • libpolys/polys/kbuckets.cc

    rf5850b rdc0f002  
    724724  {
    725725    pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
    726     p1=pp_Mult_mm(p,m,r);
     726    p1=r->p_Procs->pp_mm_Mult(p,m,r);
    727727    pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
    728728    l1=pLength(p1);
     
    766766      else
    767767      {
    768         p1 = r->p_Procs->pp_Mult_mm(p1, m, r);
     768        p1 = r->p_Procs->pp_mm_Mult(p1, m, r);
    769769      }
    770770      pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
     
    791791#else // HAVE_PSEUDO_BUCKETS
    792792  bucket->p = p_Minus_mm_Mult_qq(bucket->p, m,  p,
    793                                bucket->l, l1,
    794                                spNoether, r);
    795 #endif
    796 }
    797 
    798 //////////////////////////////////////////////////////////////////////////
    799 ///
    800 /// Bpoly == Bpoly - m1*p*m2; where m1 and m2 are monoms
    801 /// Does not destroy p, m1 and m2
    802 /// assume (*l <= 0 || pLength(p) == *l)
    803 void kBucket_Minus_m1_Mult_p_Mult_m2(kBucket_pt bucket, poly m1, poly p, poly m2, int *l, poly spNoether)
    804 {
    805   assume(*l <= 0 || pLength(p) == *l);
    806   int i, l1;
    807   poly p1 = p;
    808   ring r = bucket->bucket_ring;
    809 
    810   if (*l <= 0)
    811   {
    812     l1 = pLength(p1);
    813     *l = l1;
    814   }
    815   else
    816     l1 = *l;
    817 
    818   if (m1 == NULL || m2 == NULL || p == NULL) return;
    819 
    820 #ifndef HAVE_PSEUDO_BUCKETS
    821   kBucketMergeLm(bucket);
    822   kbTest(bucket);
    823   i = pLogLength(l1);
    824 
    825 #if defined(HAVE_PLURAL)
    826   if ((rField_is_Ring(r) && !(rField_is_Domain(r)))
    827   ||(rIsPluralRing(r)))
    828   {
    829     pSetCoeff0(m1, n_InpNeg(pGetCoeff(m1),r->cf));
    830     p1=pp_Mult_mm(r->p_Procs->pp_mm_Mult(p, m1, r),m2,r);
    831     pSetCoeff0(m1, n_InpNeg(pGetCoeff(m1),r->cf));
    832     l1=pLength(p1);
    833     i = pLogLength(l1);
    834   }
    835   else
    836 #endif
    837   {
    838     if ((i <= bucket->buckets_used) && (bucket->buckets[i] != NULL))
    839     {
    840       assume(pLength(bucket->buckets[i])==(unsigned)bucket->buckets_length[i]);
    841 //#ifdef USE_COEF_BUCKETS
    842 //     if(bucket->coef[i]!=NULL)
    843 //     {
    844 //       poly mult=p_Mult_mm(bucket->coef[i],m,r);
    845 //       bucket->coef[i]=NULL;
    846 //       p1 = p_Minus_mm_Mult_qq(bucket->buckets[i], mult, p1,
    847 //                               bucket->buckets_length[i], l1,
    848 //                             spNoether, r);
    849 //     }
    850 //     else
    851 //#endif
    852       MULTIPLY_BUCKET(bucket,i);
    853       p1 = p_Minus_mm_Mult_qq(bucket->buckets[i], m1, p_Mult_mm(p1, m2, r),
    854                             bucket->buckets_length[i], l1,
    855                             spNoether, r);
    856       l1 = bucket->buckets_length[i];
    857       bucket->buckets[i] = NULL;
    858       bucket->buckets_length[i] = 0;
    859       i = pLogLength(l1);
    860     }
    861     else
    862     {
    863       pSetCoeff0(m1, n_InpNeg(pGetCoeff(m1),r->cf));
    864       if (spNoether != NULL)
    865       {
    866         l1 = -1;
    867         p1 = r->p_Procs->pp_Mult_mm_Noether(r->p_Procs->pp_mm_Mult(p1, m1, r), m2, spNoether, l1, r);
    868         i = pLogLength(l1);
    869       }
    870       else
    871       {
    872         p1 = r->p_Procs->pp_Mult_mm(r->p_Procs->pp_mm_Mult(p1, m1, r), m2, r);
    873       }
    874       pSetCoeff0(m1, n_InpNeg(pGetCoeff(m1),r->cf));
    875     }
    876   }
    877 
    878   while (bucket->buckets[i] != NULL)
    879   {
    880     //kbTest(bucket);
    881     MULTIPLY_BUCKET(bucket,i);
    882     p1 = p_Add_q(p1, bucket->buckets[i],
    883                  l1, bucket->buckets_length[i], r);
    884     bucket->buckets[i] = NULL;
    885     bucket->buckets_length[i] = 0;
    886     i = pLogLength(l1);
    887   }
    888 
    889   bucket->buckets[i] = p1;
    890   bucket->buckets_length[i]=l1;
    891   if (i >= bucket->buckets_used)
    892     bucket->buckets_used = i;
    893   else
    894     kBucketAdjustBucketsUsed(bucket);
    895 #else // HAVE_PSEUDO_BUCKETS
    896   bucket->p = p_Minus_mm_Mult_qq(bucket->p, m1, p_Mult_mm(p, m2, r),
    897793                               bucket->l, l1,
    898794                               spNoether, r);
  • libpolys/polys/kbuckets.h

    rf5850b rdc0f002  
    134134//////////////////////////////////////////////////////////////////////////
    135135///
    136 /// Bpoly == Bpoly - m1*p*m2; where m1 and m2 are monoms
    137 /// Does not destroy p, m1 and m2 (TODO: rename into kBucket_Minus_mm1_Mult_pp_Mult_mm2!?)
    138 /// assume (*l <= 0 || pLength(p) == *l)
    139 void kBucket_Minus_m1_Mult_p_Mult_m2(kBucket_pt bucket, poly m1, poly p, poly m2, int *l, poly spNother = NULL);
    140 
    141 //////////////////////////////////////////////////////////////////////////
    142 ///
    143136/// Bpoly == Bpoly + m*p; where m is a monom
    144137/// Does not destroy p and m
  • libpolys/polys/shiftop.cc

    rf5850b rdc0f002  
    11#include "shiftop.h"
    22
    3 #define SHIFT_MULT_DEBUG
     3/* #define SHIFT_MULT_DEBUG */
     4#define SHIFT_MULT_WARNINGS
    45
    56#ifdef SHIFT_MULT_DEBUG
     
    1415
    1516  int lV = ri->isLPring;
    16   if (p_mFirstVblock(m,lV,ri) < p_mFirstVblock(p,lV,ri)) {
    17     // TODO remove this
    18     PrintS("WARNING: auto switch to shift_pp_mm_Mult");
    19     return shift_pp_mm_Mult(p, m, ri);
    20   }
    2117
    2218  // we just shift m and then call the commutative multiplication
     
    2420  int pshift = p_LastVblock(p, lV, ri);
    2521  int mshift = p_mFirstVblock(m, lV, ri) - 1;
    26 #ifdef SHIFT_MULT_DEBUG
     22#ifdef SHIFT_MULT_WARNINGS
     23  // only needed because our examples still use x(1)*y(2) etc on the interface level
    2724  if (mshift > 0) {
    2825    PrintLn();
     
    5350
    5451  int lV = ri->isLPring;
    55   if (p_mFirstVblock(m,lV,ri) < p_mFirstVblock(p,lV,ri)) {
    56     // TODO remove this
    57     Print("WARNING: auto switch to shift_p_mm_Mult");
    58     return shift_p_mm_Mult(p, m, ri);
    59   }
    6052
    6153  // we just shift m and then call the commutative multiplication
     
    6355  int pshift = p_LastVblock(p, lV, ri);
    6456  int mshift = p_mFirstVblock(m, lV, ri) - 1;
    65 #ifdef SHIFT_MULT_DEBUG
     57#ifdef SHIFT_MULT_WARNINGS
     58  // only needed because our examples still use x(1)*y(2) etc on the interface level
    6659  if (mshift > 0) {
    6760    PrintLn(); Print("WARNING: m is already shifted"); PrintLn();
     
    9083
    9184  int lV = ri->isLPring;
    92   if (p_mFirstVblock(p,lV,ri) < p_mFirstVblock(m,lV,ri)) {
    93     // TODO remove this
    94     PrintS("WARNING: auto switch to shift_pp_Mult_mm");
    95     return shift_pp_Mult_mm(p, m, ri);
    96   }
    9785
    9886  // we just shift m and then call the commutative multiplication
     
    10088  int mshift = p_mLastVblock(m, lV, ri);
    10189  int pshift = p_FirstVblock(p, lV, ri) - 1;
    102 #ifdef SHIFT_MULT_DEBUG
     90#ifdef SHIFT_MULT_WARNINGS
     91  // only needed because our examples still use x(1)*y(2) etc on the interface level
    10392  if (pshift > 0) {
    10493    PrintLn(); PrintS("WARNING: p is already shifted"); PrintLn();
     
    128117
    129118  int lV = ri->isLPring;
    130   if (p_mFirstVblock(p,lV,ri) < p_mFirstVblock(m,lV,ri)) {
    131     // TODO remove this
    132     Print("WARNING: auto switch to shift_p_Mult_mm");
    133     return shift_p_Mult_mm(p, m, ri);
    134   }
    135119
    136120  // we just shift m and then call the commutative multiplication
     
    138122  int mshift = p_mLastVblock(m, lV, ri);
    139123  int pshift = p_FirstVblock(p, lV, ri) - 1;
    140 #ifdef SHIFT_MULT_DEBUG
     124#ifdef SHIFT_MULT_WARNINGS
     125  // only needed because our examples still use x(1)*y(2) etc on the interface level
    141126  if (pshift > 0) {
    142127    PrintLn(); PrintS("WARNING: p is already shifted"); PrintLn();
Note: See TracChangeset for help on using the changeset viewer.