Changeset 528fa78 in git


Ignore:
Timestamp:
Dec 2, 2013, 2:40:16 PM (9 years ago)
Author:
Yue Ren <ren@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '5bec8f88c9ee2573d328cf7c3aff2bcb301d2395')
Children:
edb60f7c79d1b2f53a09d2650752f01a8d8da321
Parents:
7a4e77045299daf5ac74ab3774c5e1b784ff4e94
git-author:
Yue Ren <ren@mathematik.uni-kl.de>2013-12-02 14:40:16+01:00
git-committer:
Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:02+01:00
Message:
new: reduceInitially(ideal I, const number p)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • dyn_modules/callgfanlib/initialReduction.cc

    r7a4e77 r528fa78  
    112112/***
    113113 * reduces h initially with respect to g,
    114  * returns NULL if h was initially reduced in the first place. if reductions have taken place,
    115  * returns a pointer to a term from which onwards changes have taken place.
     114 * returns false if h was initially reduced in the first place,
     115 * returns true if reductions have taken place.
    116116 * assumes that h and g are in pReduced form and homogeneous in x of the same degree
    117117 **/
    118 poly reduceInitially(poly &h, const poly g)
    119 {
    120   poly hCache=h;
    121   if (p_LeadmonomDivisibleBy(g,hCache,currRing))
     118bool reduceInitially(poly &h, const poly g)
     119{
     120  poly hCache;
     121  for (hCache=h; hCache; pIter(hCache))
     122    if (p_LeadmonomDivisibleBy(g,hCache,currRing)) break;
     123  if (hCache)
    122124  {
    123125    number gAlpha = p_GetCoeff(g,currRing);
     
    132134                currRing);
    133135    pTest(h);
    134     return(h);
    135   }
    136   for (; pNext(hCache); pIter(hCache))
    137     if (p_LeadmonomDivisibleBy(g,pNext(hCache),currRing)) break;
    138   if (pNext(hCache))
    139   {
    140     number gAlpha = p_GetCoeff(g,currRing);
    141     poly hAlphaT = p_Init(currRing);
    142     p_SetCoeff(hAlphaT,n_Copy(p_GetCoeff(pNext(hCache),currRing),currRing->cf),currRing);
    143     p_SetExp(hAlphaT,1,p_GetExp(pNext(hCache),1,currRing)-p_GetExp(g,1,currRing),currRing);
    144     for (int i=2; i<=currRing->N; i++)
    145       p_SetExp(hAlphaT,i,0,currRing);
    146     p_Setm(hAlphaT,currRing); pTest(hAlphaT);
    147     h = p_Add_q(p_Mult_nn(h,gAlpha,currRing),
    148                 p_Neg(p_Mult_q(p_Copy(g,currRing),hAlphaT,currRing),currRing),
    149                 currRing);
    150     pTest(h);
    151   }
    152   return pNext(hCache);
     136    return true;
     137  }
     138  return false;
    153139}
    154140
     
    221207   * the first pass. removing terms with the same monomials in x as lt(g_i) out of g_j for i<j
    222208   **/
    223   poly cache = NULL;
    224209  for (i=0; i<IDELEMS(I)-1; i++)
    225   {
    226210    for (j=i+1; j<IDELEMS(I); j++)
    227     {
    228       cache = reduceInitially(I->m[j], I->m[i]);
    229       if (cache)
    230       {
    231         if(pReduce(cache,p)) return true;
    232         cache = NULL;
    233       }
    234     }
    235   }
     211      if (reduceInitially(I->m[j], I->m[i]) && pReduce(I->m[j],p)) return true;
    236212
    237213  /***
     
    239215   **/
    240216  for (i=0; i<IDELEMS(I)-1; i++)
    241   {
    242217    for (j=i+1; j<IDELEMS(I); j++)
    243     {
    244       cache = reduceInitially(I->m[i], I->m[j]);
    245       if (cache)
    246       {
    247         if (pReduce(cache,p)) return true;
    248         cache = NULL;
    249       }
    250     }
    251   }
     218      if (reduceInitially(I->m[i], I->m[j]) && pReduce(I->m[i],p)) return true;
    252219  return false;
    253220}
Note: See TracChangeset for help on using the changeset viewer.