Ignore:
Timestamp:
Jul 17, 2014, 12:28:18 PM (9 years ago)
Author:
Yue Ren <ren@…>
Branches:
(u'spielwiese', 'ec94ef7a30b928574c0c3daf41f6804dff5f6b69')
Children:
eb836ceccfffe01622457439ed104bca800bc101
Parents:
3c0aa5079c417e92fdfaa03c1d87d73f5b365291
git-author:
Yue Ren <ren@mathematik.uni-kl.de>2014-07-17 12:28:18+02:00
git-committer:
Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:03+01:00
Message:
chg: status update 17.07.
File:
1 edited

Legend:

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

    r3c0aa5 re744d9  
    2323    d += p_GetExp(p,i+1,r)*w[i].toInt();
    2424  }
     25  return d;
     26}
     27
     28/***
     29 * Computes the weighted multidegree of the leading term of p with respect to W.
     30 * The weighted multidegree is a vector whose i-th entry is the weighted degree
     31 * with respect to the i-th row vector of W.
     32 **/
     33gfan::ZVector WDeg(const poly p, const ring r, const gfan::ZMatrix W)
     34{
     35  gfan::ZVector d = gfan::ZVector(W.getHeight());
     36  for (int i=0; i<W.getHeight(); i++)
     37    d[i] = wDeg(p,r,W[i]);
    2538  return d;
    2639}
     
    8194
    8295/***
    83  * Returns the first terms of p of same weighted degree under w,
    84  * this is not necessarily the initial form of p with respect to w!
     96 * Returns the initial form of p with respect to w
    8597 **/
    8698poly initial(const poly p, const ring r, const gfan::ZVector w)
    8799{
    88   int n = r->N;
    89   int* expv = (int*) omAlloc(n*sizeof(int));
    90100  poly q0 = p_Head(p,r);
    91101  poly q1 = q0;
     
    93103  for (poly currentTerm = p->next; currentTerm; pIter(currentTerm))
    94104  {
    95     if (wDeg(currentTerm,r,w)==d)
     105    long e = wDeg(currentTerm,r,w);
     106    if (e>d)
    96107    {
    97       pNext(q1) = p_Head(currentTerm,r);
    98       pIter(q1);
     108      p_Delete(&q0,r);
     109      q0 = p_Head(p,r);
     110      q1 = q0;
     111      d = e;
    99112    }
    100   }
    101   omFreeSize(expv,n*sizeof(int));
     113    else
     114      if (e==d)
     115      {
     116        pNext(q1) = p_Head(currentTerm,r);
     117        pIter(q1);
     118      }
     119  }
    102120  return q0;
    103121}
     
    105123/***
    106124 * Runs the above procedure over all generators of an ideal.
     125 * Returns the initial ideal if and only if the weight is in the maximal Groebner cone
     126 * of the current ordering.
    107127 **/
    108128ideal initial(const ideal I, const ring r, const gfan::ZVector w)
     
    113133  return inI;
    114134}
     135
     136
     137/***
     138 * Returns the initial form of p with respect to W,
     139 * i.e. the sum over all terms of p with highest multidegree with respect to W.
     140 **/
     141poly initial(const poly p, const ring r, const gfan::ZMatrix W)
     142{
     143  int n = rVar(r);
     144  poly q0 = p_Head(p,r);
     145  poly q1 = q0;
     146  gfan::ZVector d = WDeg(p,r,W);
     147  for (poly currentTerm = p->next; currentTerm; pIter(currentTerm))
     148  {
     149    gfan::ZVector e = WDeg(currentTerm,r,W);
     150    if (d<e)
     151    {
     152      p_Delete(&q0,r);
     153      q0 = p_Head(p,r);
     154      q1 = q0;
     155      d = e;
     156    }
     157    else
     158      if (d==e)
     159      {
     160        pNext(q1) = p_Head(currentTerm,r);
     161        pIter(q1);
     162      }
     163  }
     164  return q0;
     165}
     166
     167/***
     168 * Runs the above procedure over all generators of an ideal.
     169 * Returns the initial ideal if and only if the weight is in the maximal Groebner cone
     170 * of the current ordering.
     171 **/
     172ideal initial(const ideal I, const ring r, const gfan::ZMatrix W)
     173{
     174  int k = idSize(I); ideal inI = idInit(k);
     175  for (int i=0; i<k; i++)
     176    inI->m[i] = initial(I->m[i],r,W);
     177  return inI;
     178}
     179
    115180
    116181#ifndef NDEBUG
Note: See TracChangeset for help on using the changeset viewer.