Changeset cea6f3 in git for kernel/kspoly.cc


Ignore:
Timestamp:
Jan 13, 2006, 7:10:06 PM (17 years ago)
Author:
Oliver Wienand <wienand@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
2e4de3d33d0bea3780e1932fdaf8a41c161f473e
Parents:
4cbb61ba5014a593b9bc6569b497e9a8151bc15f
Message:
RING2TOM Merger


git-svn-id: file:///usr/local/Singular/svn/trunk@8900 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/kspoly.cc

    r4cbb61 rcea6f3  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kspoly.cc,v 1.2 2005-11-27 15:28:44 wienand Exp $ */
     4/* $Id: kspoly.cc,v 1.3 2006-01-13 18:10:04 wienand Exp $ */
    55/*
    66*  ABSTRACT -  Routines for Spoly creation and reductions
     
    4949  kTest_T(PW);
    5050
    51   poly p1 = PR->GetLmTailRing();
    52   poly p2 = PW->GetLmTailRing();
    53   poly t2 = pNext(p2), lm = p1;
    54   assume(p1 != NULL && p2 != NULL);
     51  poly p1 = PR->GetLmTailRing();   // p2 | p1
     52  poly p2 = PW->GetLmTailRing();   // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
     53  poly t2 = pNext(p2), lm = p1;    // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
     54  assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
    5555  p_CheckPolyRing(p1, tailRing);
    5656  p_CheckPolyRing(p2, tailRing);
     
    8383  }
    8484
    85   if (t2==NULL)
    86   {
     85  if (t2==NULL)           // Divisor is just one term, therefore it will
     86  {                       // just cancel the leading term
    8787    PR->LmDeleteAndIter();
    8888    if (coef != NULL) *coef = n_Init(1, tailRing);
     
    9090  }
    9191
    92   p_ExpVectorSub(lm, p2, tailRing);
     92  p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
    9393
    9494  if (tailRing != currRing)
     
    116116    number bn = pGetCoeff(lm);
    117117    number an = pGetCoeff(p2);
    118 #ifdef HAVE_RING2TOM
    119     if (currRing->cring == 1) {
    120       while (((long) an)%2 == 0 && ((long) bn)%2 == 0) {
    121         an = (number) (((long) an) / 2);
    122         bn = (number) (((long) bn) / 2);
    123       }
    124     }
    125 #endif
    126     int ct = ksCheckCoeff(&an, &bn);
    127     p_SetCoeff(lm, bn,tailRing);
     118    int ct = ksCheckCoeff(&an, &bn);    // Calculate special LC
     119    p_SetCoeff(lm, bn, tailRing);
    128120    if ((ct == 0) || (ct == 2))
    129121      PR->Tail_Mult_nn(an);
     
    139131  // and finally,
    140132  PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
     133  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    141134  PR->LmDeleteAndIter();
    142135#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
     
    148141  return ret;
    149142}
    150 
    151 #ifdef HAVE_RING2TOM
    152 /***************************************************************
    153  *
    154  * Reduces PR with PW
    155  * Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
    156  * as above, just for rings
    157  *
    158  ***************************************************************/
    159 int ksRingReducePoly(LObject* PR,
    160                  TObject* PW,
    161                  poly spNoether,
    162                  number *coef,
    163                  kStrategy strat)
    164 {
    165 #ifdef KDEBUG
    166   red_count++;
    167 #ifdef TEST_OPT_DEBUG_RED
    168   if (TEST_OPT_DEBUG)
    169   {
    170     Print("Red %d:", red_count); PR->wrp(); Print(" with:");
    171     PW->wrp();
    172   }
    173 #endif
    174 #endif
    175   int ret = 0;
    176   ring tailRing = PR->tailRing;
    177   kTest_L(PR);
    178   kTest_T(PW);
    179 
    180   poly p1 = PR->GetLmTailRing();
    181   poly p2 = PW->GetLmTailRing();
    182   poly t2 = pNext(p2), lm = p1;
    183   assume(p1 != NULL && p2 != NULL);
    184   p_CheckPolyRing(p1, tailRing);
    185   p_CheckPolyRing(p2, tailRing);
    186 
    187   pAssume1(p2 != NULL && p1 != NULL &&
    188            p_RingDivisibleBy(p2,  p1, tailRing));
    189 
    190   pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
    191            (p_GetComp(p2, tailRing) == 0 &&
    192             p_MaxComp(pNext(p2),tailRing) == 0));
    193 
    194   if (t2==NULL)
    195   {
    196     PR->LmDeleteAndIter();
    197     if (coef != NULL) *coef = n_Init(1, tailRing);
    198     return 0;
    199   }
    200 
    201   p_ExpVectorSub(lm, p2, tailRing);
    202 
    203   if (tailRing != currRing)
    204   {
    205     // check that reduction does not violate exp bound
    206     while (PW->max != NULL && !p_LmExpVectorAddIsOk(lm, PW->max, tailRing))
    207     {
    208       // undo changes of lm
    209       p_ExpVectorAdd(lm, p2, tailRing);
    210       if (strat == NULL) return 2;
    211       if (! kStratChangeTailRing(strat, PR, PW)) return -1;
    212       tailRing = strat->tailRing;
    213       p1 = PR->GetLmTailRing();
    214       p2 = PW->GetLmTailRing();
    215       t2 = pNext(p2);
    216       lm = p1;
    217       p_ExpVectorSub(lm, p2, tailRing);
    218       ret = 1;
    219     }
    220   }
    221 
    222   // take care of coef buisness
    223   if (! n_IsOne(pGetCoeff(p2), tailRing))
    224   {
    225     number bn = pGetCoeff(lm);
    226     number an = pGetCoeff(p2);
    227     while (((long) an)%2 == 0 && ((long) bn)%2 == 0) {
    228       an = (number) (((long) an) / 2);
    229       bn = (number) (((long) bn) / 2);
    230     }
    231     int ct = ksCheckCoeff(&an, &bn);
    232     p_SetCoeff(lm, bn,tailRing);
    233     if ((ct == 0) || (ct == 2))
    234       PR->Tail_Mult_nn(an);
    235     if (coef != NULL) *coef = an;
    236     else n_Delete(&an, tailRing);
    237   }
    238   else
    239   {
    240     if (coef != NULL) *coef = n_Init(1, tailRing);
    241   }
    242 
    243 
    244   // and finally,
    245   PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
    246   PR->LmDeleteAndIter();
    247 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
    248   if (TEST_OPT_DEBUG)
    249   {
    250     Print(" to: "); PR->wrp(); Print("\n");
    251   }
    252 #endif
    253   return ret;
    254 }
    255 #endif
    256143
    257144/***************************************************************
     
    280167  poly a1 = pNext(p1), a2 = pNext(p2);
    281168  number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
    282 #ifdef HAVE_RING2TOM
    283   if (currRing->cring == 1) {
    284     while (((long) lc1)%2 == 0 && ((long) lc2)%2 == 0) {
    285       lc1 = (number) (((long) lc1) / 2);
    286       lc2 = (number) (((long) lc2) / 2);
    287     }
    288   }
    289 #endif 
    290   int co=0, ct = ksCheckCoeff(&lc1, &lc2);
     169  int co=0, ct = ksCheckCoeff(&lc1, &lc2); // gcd and zero divisors
    291170
    292171  int l1=0, l2=0;
     
    329208  else
    330209    a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing,last);
     210#ifdef HAVE_RING2TOM
     211  if (currRing->cring == 1) l2 = pLength(a2);
     212#endif
     213
    331214  Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing, last);
    332215
     
    429312    bn = nIntDiv(bn, cn);
    430313  }
     314#ifdef HAVE_RING2TOM
     315  if (currRing->cring == 1) {
     316    while (((long) an)%2 == 0 && ((long) bn)%2 == 0) {
     317      an = (number) (((long) an) / 2);
     318      bn = (number) (((long) bn) / 2);
     319    }
     320  }
     321#endif
    431322  nDelete(&cn);
    432323  if (nIsOne(an))
Note: See TracChangeset for help on using the changeset viewer.