Changeset 0758b5 in git for kernel/kspoly.cc


Ignore:
Timestamp:
Jul 2, 2012, 2:03:47 PM (11 years ago)
Author:
Christian Eder
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
c78bdede4a03cf59fc377dd13948c2c482c883fa
Parents:
fee33eddc902b0ad109daba1a48c0d83f7329667
git-author:
Christian Eder <ederc@mathematik.uni-kl.de>2012-07-02 14:03:47+02:00
git-committer:
Christian Eder <ederc@mathematik.uni-kl.de>2012-07-05 16:12:50+02:00
Message:
spielwiese compiles with sba
Todo: Add sba() call
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/kspoly.cc

    rfee33e r0758b5  
    155155#endif
    156156 
     157#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
     158  if (TEST_OPT_DEBUG)
     159  {
     160    Print(" to: "); PR->wrp(); Print("\n");
     161  }
     162#endif
     163  return ret;
     164}
     165
     166/***************************************************************
     167 *
     168 * Reduces PR with PW
     169 * Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
     170 *
     171 ***************************************************************/
     172int ksReducePolySig(LObject* PR,
     173                 TObject* PW,
     174                 long idx,
     175                 poly spNoether,
     176                 number *coef,
     177                 kStrategy strat)
     178{
     179#ifdef KDEBUG
     180  red_count++;
     181#ifdef TEST_OPT_DEBUG_RED
     182  if (TEST_OPT_DEBUG)
     183  {
     184    Print("Red %d:", red_count); PR->wrp(); Print(" with:");
     185    PW->wrp();
     186  }
     187#endif
     188#endif
     189  int ret = 0;
     190  ring tailRing = PR->tailRing;
     191  kTest_L(PR);
     192  kTest_T(PW);
     193
     194  // signature-based stuff:
     195  // checking for sig-safeness first
     196  // NOTE: This has to be done in the current ring
     197  //
     198  /**********************************************
     199   *
     200   * TODO:
     201   * --------------------------------------------
     202   * if strat->incremental
     203   * Since we are subdividing lower index and
     204   * current index reductions it is enough to
     205   * look at the polynomial part of the signature
     206   * for a check. This should speed-up checking
     207   * a lot!
     208   * if !strat->incremental
     209   * We are not subdividing lower and current index
     210   * due to the fact that we are using the induced
     211   * Schreyer order
     212   *
     213   * nevertheless, this different behaviour is
     214   * taken care of by is_sigsafe
     215   * => one reduction procedure can be used for
     216   * both, the incremental and the non-incremental
     217   * attempt!
     218   * --------------------------------------------
     219   *
     220   *********************************************/
     221  //printf("COMPARE IDX: %ld -- %ld\n",idx,strat->currIdx);
     222  if (!PW->is_sigsafe)
     223  {
     224    poly f1 = p_Copy(PR->GetLmCurrRing(),currRing);
     225    poly f2 = PW->GetLmCurrRing();
     226    poly sigMult = pCopy(PW->sig);   // copy signature of reducer
     227    p_ExpVectorSub(f1, f2, currRing); // Calculate the Monomial we must multiply to p2
     228//#if 1
     229#ifdef DEBUGF5
     230    printf("IN KSREDUCEPOLYSIG: \n");
     231    pWrite(pHead(f1));
     232    pWrite(pHead(f2));
     233    pWrite(sigMult);
     234    printf("--------------\n");
     235#endif
     236    sigMult = pp_Mult_qq(f1,sigMult,currRing);
     237//#if 1
     238#ifdef DEBUGF5
     239    printf("------------------- IN KSREDUCEPOLYSIG: --------------------\n");
     240    pWrite(pHead(f1));
     241    pWrite(pHead(f2));
     242    pWrite(sigMult);
     243    pWrite(PR->sig);
     244    printf("--------------\n");
     245#endif
     246    int sigSafe = p_LmCmp(PR->sig,sigMult,currRing);
     247    // now we can delete the copied polynomial data used for checking for
     248    // sig-safeness of the reduction step
     249//#if 1
     250#ifdef DEBUGF5
     251    printf("%d -- %d sig\n",sigSafe,PW->is_sigsafe);
     252
     253#endif
     254    pDelete(&f1);
     255    pDelete(&sigMult);
     256    // go on with the computations only if the signature of p2 is greater than the
     257    // signature of fm*p1
     258    if(sigSafe != 1)
     259    {
     260      PR->is_redundant = TRUE;
     261      return 3;
     262    }
     263    PW->is_sigsafe  = TRUE;
     264  }
     265  PR->is_redundant = FALSE;
     266  poly p1 = PR->GetLmTailRing();   // p2 | p1
     267  poly p2 = PW->GetLmTailRing();   // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
     268  poly t2 = pNext(p2), lm = p1;    // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
     269  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
     270  p_CheckPolyRing(p1, tailRing);
     271  p_CheckPolyRing(p2, tailRing);
     272
     273  pAssume1(p2 != NULL && p1 != NULL &&
     274      p_DivisibleBy(p2,  p1, tailRing));
     275
     276  pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
     277      (p_GetComp(p2, tailRing) == 0 &&
     278       p_MaxComp(pNext(p2),tailRing) == 0));
     279
     280#ifdef HAVE_PLURAL
     281  if (rIsPluralRing(currRing))
     282  {
     283    // for the time being: we know currRing==strat->tailRing
     284    // no exp-bound checking needed
     285    // (only needed if exp-bound(tailring)<exp-b(currRing))
     286    if (PR->bucket!=NULL)  nc_kBucketPolyRed(PR->bucket, p2,coef);
     287    else
     288    {
     289      poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
     290      assume(_p != NULL);
     291      nc_PolyPolyRed(_p, p2, coef, currRing);
     292      if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
     293      PR->pLength=0; // usaully not used, GetpLength re-comoutes it if needed
     294    }
     295    return 0;
     296  }
     297#endif
     298
     299  if (t2==NULL)           // Divisor is just one term, therefore it will
     300  {                       // just cancel the leading term
     301    PR->LmDeleteAndIter();
     302    if (coef != NULL) *coef = n_Init(1, tailRing);
     303    return 0;
     304  }
     305
     306  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
     307
     308  if (tailRing != currRing)
     309  {
     310    // check that reduction does not violate exp bound
     311    while (PW->max != NULL && !p_LmExpVectorAddIsOk(lm, PW->max, tailRing))
     312    {
     313      // undo changes of lm
     314      p_ExpVectorAdd(lm, p2, tailRing);
     315      if (strat == NULL) return 2;
     316      if (! kStratChangeTailRing(strat, PR, PW)) return -1;
     317      tailRing = strat->tailRing;
     318      p1 = PR->GetLmTailRing();
     319      p2 = PW->GetLmTailRing();
     320      t2 = pNext(p2);
     321      lm = p1;
     322      p_ExpVectorSub(lm, p2, tailRing);
     323      ret = 1;
     324    }
     325  }
     326
     327  // take care of coef buisness
     328  if (! n_IsOne(pGetCoeff(p2), tailRing))
     329  {
     330    number bn = pGetCoeff(lm);
     331    number an = pGetCoeff(p2);
     332    int ct = ksCheckCoeff(&an, &bn, tailRing->cf);    // Calculate special LC
     333    p_SetCoeff(lm, bn, tailRing);
     334    if ((ct == 0) || (ct == 2))
     335      PR->Tail_Mult_nn(an);
     336    if (coef != NULL) *coef = an;
     337    else n_Delete(&an, tailRing);
     338  }
     339  else
     340  {
     341    if (coef != NULL) *coef = n_Init(1, tailRing);
     342  }
     343
     344
     345  // and finally,
     346  PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     347  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
     348  PR->LmDeleteAndIter();
     349
     350  // the following is commented out: shrinking
     351#ifdef HAVE_SHIFTBBA_NONEXISTENT
     352  if ( (currRing->isLPring) && (!strat->homog) )
     353  {
     354    // assume? h->p in currRing
     355    PR->GetP();
     356    poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
     357    PR->Clear(); // does the right things
     358    PR->p = qq;
     359    PR->t_p = NULL;
     360    PR->SetShortExpVector();
     361  }
     362#endif
     363
    157364#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
    158365  if (TEST_OPT_DEBUG)
Note: See TracChangeset for help on using the changeset viewer.