Changeset edb60f in git


Ignore:
Timestamp:
Dec 2, 2013, 3:29:46 PM (10 years ago)
Author:
Yue Ren <ren@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
88c726094b0406a43f64b51105e892d707306874
Parents:
528fa78d82d2bc9d49f41d3dbb87afea0e1697e2
git-author:
Yue Ren <ren@mathematik.uni-kl.de>2013-12-02 15:29:46+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, poly g)
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/gfanlib/tropical.cc

    r528fa78 redb60f  
    974974  p->iiAddCproc("","reduceInitially0",FALSE,reduceInitially0);
    975975  p->iiAddCproc("","reduceInitially1",FALSE,reduceInitially1);
     976  p->iiAddCproc("","reduceInitially2",FALSE,reduceInitially2);
    976977#endif //NDEBUG
    977978  // p->iiAddCproc("","initialReduction",FALSE,initialReduction);
  • dyn_modules/callgfanlib/initialReduction.cc

    r528fa78 redb60f  
    9595
    9696/***
    97  * Returns, if it exists, a pointer to the first term in g
    98  * that is divisible by (the leading monomial of) m or, if it does not exist, the NULL pointer
    99  * If g is homogeneous in x with the same degree as m,
     97 * returns, if it exists, a pointer to the first term in g
     98 * that is divisible by (the leading monomial of) m or, if it does not exist, the NULL pointer.
     99 * if g is homogeneous in x with the same degree as m,
    100100 * then it returns the first term with the same monomial in x as m,
    101101 * if the t-degree of the term is higher than the t-degree of m, or NULL otherwise.
     
    196196/***
    197197 * reduces I initially with respect to itself and with respect to p-t.
     198 * also sorts the generators of I with respect to the leading monomials in descending order.
    198199 * assumes that I is generated by elements which are homogeneous in x of the same degree.
    199200 **/
    200201bool reduceInitially(ideal I, const number p)
    201202{
    202   sortByLeadmonom(I); int i,j;
     203  poly cache; int i,j,n=IDELEMS(I);
     204  do
     205  {
     206    j=0;
     207    for (i=1; i<n; i++)
     208    {
     209      if (pLmCmp(I->m[i-1],I->m[i])<0)
     210      {
     211        cache=I->m[i-1];
     212        I->m[i-1]=I->m[i];
     213        I->m[i]=cache;
     214        j = i;
     215      }
     216    }
     217    n=j;
     218  } while(n);
    203219  for (i=1; i<IDELEMS(I); i++)
    204220    if (pReduce(I->m[i],p)) return true;
     
    230246    if ((v != NULL) && (v->Typ() == NUMBER_CMD))
    231247    {
    232       ideal I = (ideal) u->CopyD();
    233       number p = (number) v->CopyD();
     248      ideal I; number p;
    234249      omUpdateInfo();
    235250      Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
     251      I = (ideal) u->CopyD();
     252      p = (number) v->CopyD();
    236253      (void) reduceInitially(I,p);
     254      id_Delete(&I,currRing);
     255      n_Delete(&p,currRing->cf);
    237256      omUpdateInfo();
    238257      Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);
     258      I = (ideal) u->CopyD();
     259      p = (number) v->CopyD();
     260      (void) reduceInitially(I,p);
    239261      n_Delete(&p,currRing->cf);
    240262      res->rtyp = IDEAL_CMD;
     
    246268}
    247269#endif //NDEBUG
     270
     271
     272/***
     273 * inserts g into I and reduces I with respect to itself and p-t
     274 * assumes that I was already sorted and initially reduced in the first place
     275 **/
     276bool reduceInitially(ideal I, const number p, poly g)
     277{
     278  pEnlargeSet(&(I->m),IDELEMS(I),1);
     279  IDELEMS(I)++; int i,j,k;
     280  for (j=IDELEMS(I)-1; j>0; j--)
     281  {
     282    if (pLmCmp(I->m[j-1],g)<0)
     283      I->m[j] = I->m[j-1];
     284    else
     285    {
     286      I->m[j] = g;
     287      break;
     288    }
     289  }
     290  if (j<1) I->m[0] = g;
     291
     292  /***
     293   * the first pass. removing terms with the same monomials in x as lt(g_i) out of g_j for i<j
     294   * removing terms with the same monomials in x as lt(g_j) out of g_k for j<k
     295   **/
     296  for (i=0; i<j; i++)
     297    if (reduceInitially(I->m[j], I->m[i]) && pReduce(I->m[j],p)) return true;
     298  for (k=j+1; k<IDELEMS(I); k++)
     299    if (reduceInitially(I->m[k], I->m[j]) && pReduce(I->m[k],p)) return true;
     300
     301  /***
     302   * the second pass. removing terms divisible by lt(g_j) and lt(g_k) out of g_i for i<j<k
     303   * removing terms divisible by lt(g_k) out of g_j for j<k
     304   **/
     305  for (i=0; i<j; i++)
     306    for (k=j; k<IDELEMS(I); k++)
     307      if (reduceInitially(I->m[i], I->m[k]) && pReduce(I->m[i],p)) return true;
     308  for (k=j+1; k<IDELEMS(I); k++)
     309    if (reduceInitially(I->m[j],I->m[k]) && pReduce(I->m[j],p)) return true;
     310
     311  return false;
     312}
     313
     314
     315#ifndef NDEBUG
     316BOOLEAN reduceInitially2(leftv res, leftv args)
     317{
     318  leftv u = args;
     319  if ((u != NULL) && (u->Typ() == IDEAL_CMD))
     320  {
     321    leftv v = u->next;
     322    if ((v != NULL) && (v->Typ() == NUMBER_CMD))
     323    {
     324      leftv w = v->next;
     325      if ((w != NULL) && (w->Typ() == POLY_CMD))
     326      {
     327        ideal I; number p; poly g;
     328        omUpdateInfo();
     329        Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
     330        I = (ideal) u->CopyD();
     331        p = (number) v->CopyD();
     332        g = (poly) w->CopyD();
     333        (void) reduceInitially(I,p,g);
     334        id_Delete(&I,currRing);
     335        n_Delete(&p,currRing->cf);
     336        omUpdateInfo();
     337        Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);
     338        I = (ideal) u->CopyD();
     339        p = (number) v->CopyD();
     340        g = (poly) w->CopyD();
     341        (void) reduceInitially(I,p,g);
     342        n_Delete(&p,currRing->cf);
     343        res->rtyp = IDEAL_CMD;
     344        res->data = (char*) I;
     345        return FALSE;
     346      }
     347    }
     348  }
     349  return TRUE;
     350}
     351#endif //NDEBUG
  • dyn_modules/callgfanlib/initialReduction.h

    r528fa78 redb60f  
    88BOOLEAN reduceInitially0(leftv res, leftv args);
    99BOOLEAN reduceInitially1(leftv res, leftv args);
     10BOOLEAN reduceInitially2(leftv res, leftv args);
    1011#endif
    1112
Note: See TracChangeset for help on using the changeset viewer.