source: git/kernel/GBEngine/khstd.cc @ 24bc73

spielwiese
Last change on this file since 24bc73 was 89f4843, checked in by Hans Schoenemann <hannes@…>, 7 years ago
use include ".." for singular related .h, p10, register ->REGISTER
  • Property mode set to 100644
File size: 4.9 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/*
5* ABSTRACT:utils for hilbert driven kStd
6*/
7
8#include "kernel/mod2.h"
9
10#include "misc/options.h"
11#include "misc/intvec.h"
12
13#include "polys/simpleideals.h"
14
15#include "kernel/combinatorics/stairc.h"
16#include "kernel/combinatorics/hilb.h"
17
18#include "kernel/GBEngine/kutil.h"
19#include "kernel/GBEngine/kstd1.h"
20#include "kernel/GBEngine/khstd.h"
21
22#include "kernel/polys.h"
23
24#define ADIDEBUG 0
25
26
27/*2
28* compare the given hilbert series with the current one,
29* delete not needed pairs (if possible)
30*/
31void khCheck( ideal Q, intvec *w, intvec *hilb, int &eledeg, int &count,
32              kStrategy strat)
33  /* ideal S=strat->Shdl, poly p=strat->P.p */
34/*
35* compute the number eledeg of elements with a degree >= deg(p) going into kStd,
36* p is already in S and for all further q going into S yields deg(q) >= deg(p),
37* the real computation is only done if the degree has changed,
38* then we have eledeg == 0 on this degree and we make:
39*   - compute the Hilbert series newhilb from S
40*     (hilb is the final Hilbert series)
41*   - in module case: check that all comp up to strat->ak are used
42*   - compute the eledeg from newhilb-hilb for the first degree deg with
43*     newhilb-hilb != 0
44*     (Remark: consider the Hilbert series with coeff. up to infinity)
45*   - clear the set L for degree < deg
46* the number count is only for statistics (in the caller initialise count = 0),
47* in order to get a first computation, initialise eledeg = 1 in the caller.
48* The weights w are needed in the module case, otherwise NULL.
49*/
50{
51  intvec *newhilb;
52  int deg,l,ln,mw;
53  pFDegProc degp;
54
55  eledeg--;
56  if (eledeg == 0)
57  {
58    if (strat->ak>0)
59    {
60      char *used_comp=(char*)omAlloc0(strat->ak+1);
61      int i;
62      for(i=strat->sl;i>0;i--)
63      {
64        used_comp[pGetComp(strat->S[i])]='\1';
65      }
66      for(i=strat->ak;i>0;i--)
67      {
68        if(used_comp[i]=='\0')
69        {
70          omFree((ADDRESS)used_comp);
71          return;
72        }
73      }
74      omFree((ADDRESS)used_comp);
75    }
76    degp=currRing->pFDeg;
77    // if weights for variables were given to std computations,
78    // then pFDeg == degp == kHomModDeg (see kStd)
79    if ((degp!=kModDeg) && (degp!=kHomModDeg)) degp=p_Totaldegree;
80    // degp = pWDegree;
81    l = hilb->length()-1;
82    mw = (*hilb)[l];
83    newhilb = hHstdSeries(strat->Shdl,w,strat->kHomW,Q,strat->tailRing);
84    ln = newhilb->length()-1;
85    deg = degp(strat->P.p,currRing)-mw;
86    loop // compare the series in degree deg, try to increase deg -----------
87    {
88      if (deg < ln) // deg may be out of range
89      {
90        if (deg < l)
91          eledeg = (*newhilb)[deg]-(*hilb)[deg];
92        else
93          eledeg = (*newhilb)[deg];
94      }
95      else
96      {
97        if (deg < l)
98          eledeg = -(*hilb)[deg];
99        else // we have newhilb = hilb
100        {
101          while (strat->Ll>=0)
102          {
103            count++;
104            if(TEST_OPT_PROT)
105            {
106              PrintS("h");
107              mflush();
108            }
109            deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
110          }
111          delete newhilb;
112          return;
113        }
114      }
115      if (eledeg > 0) // elements to delete
116        break;
117      else if (eledeg <0) // strange....see bug_43
118        return;
119      deg++;
120    } /* loop */
121    delete newhilb;
122    while ((strat->Ll>=0) && (degp(strat->L[strat->Ll].p,currRing)-mw < deg)) // the essential step
123    {
124      count++;
125      if(TEST_OPT_PROT)
126      {
127        PrintS("h");
128        mflush();
129      }
130      deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
131    }
132  }
133}
134
135
136void khCheckLocInhom(ideal Q, intvec *w, intvec *hilb, int &count,
137             kStrategy strat)
138
139/*
140This will be used for the local orderings in the case of the inhomogenous ideals.
141Assume f1,...,fs are already in the standard basis. Test if hilb(LM(f1),...,LM(fs),1)
142is equal to the inputed one.
143If no, do nothing.
144If Yes, we know that all polys that we need are already in the standard basis
145so delete all the remaining pairs
146*/
147{
148  ideal Lm;
149  intvec *newhilb;
150
151  Lm = id_Head(strat->Shdl,currRing);
152
153  newhilb =hHstdSeries(Lm,w,strat->kHomW,Q,currRing); // ,strat->tailRing?
154
155#if ADIDEBUG
156PrintS("\nOriginal\n");
157int   i, j, l, k;
158  if (hilb == NULL)
159    return;
160  l = hilb->length()-1;
161  k = (*hilb)[l];
162  for (i = 0; i < l; i++)
163  {
164    j = (*hilb)[i];
165    if (j != 0)
166    {
167      Print("//  %8d t^%d\n", j, i+k);
168    }
169  }
170  PrintS("\nActual\n");
171  if (newhilb == NULL)
172    return;
173  l = newhilb->length()-1;
174  k = (*newhilb)[l];
175  for (i = 0; i < l; i++)
176  {
177    j = (*newhilb)[i];
178    if (j != 0)
179    {
180      Print("//  %8d t^%d\n", j, i+k);
181    }
182  }
183#endif
184
185  if(newhilb->compare(hilb) == 0)
186  {
187    while (strat->Ll>=0)
188    {
189      count++;
190      if(TEST_OPT_PROT)
191      {
192        PrintS("h");
193        mflush();
194      }
195      deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
196    }
197    delete newhilb;
198    return;
199  }
200  id_Delete(&Lm,currRing);
201}
Note: See TracBrowser for help on using the repository browser.