# source:git/kernel/khstd.cc@99bdcf

jengelh-datetimespielwiese
Last change on this file since 99bdcf was 99bdcf, checked in by Hans Schoenemann <hannes@…>, 13 years ago
• Property mode set to `100644`
File size: 3.5 KB
Line
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* \$Id\$ */
5/*
6* ABSTRACT:utils for hilbert driven kStd
7*/
8
9#include <kernel/mod2.h>
10#include <kernel/febase.h>
11#include <kernel/options.h>
12#include <kernel/polys.h>
13#include <kernel/intvec.h>
14#include <kernel/kutil.h>
15#include <kernel/stairc.h>
16#include <kernel/kstd1.h>
17#include <kernel/khstd.h>
18
19
20/*2
21* compare the given hilbert series with the current one,
22* delete not needed pairs (if possible)
23*/
24void khCheck( ideal Q, intvec *w, intvec *hilb, int &eledeg, int &count,
25              kStrategy strat)
26  /* ideal S=strat->Shdl, poly p=strat->P.p */
27/*
28* compute the number eledeg of elements with a degree >= deg(p) going into kStd,
29* p is already in S and for all further q going into S yields deg(q) >= deg(p),
30* the real computation is only done if the degree has changed,
31* then we have eledeg == 0 on this degree and we make:
32*   - compute the Hilbert series newhilb from S
33*     (hilb is the final Hilbert series)
34*   - in module case: check that all comp up to strat->ak are used
35*   - compute the eledeg from newhilb-hilb for the first degree deg with
36*     newhilb-hilb != 0
37*     (Remark: consider the Hilbert series with coeff. up to infinity)
38*   - clear the set L for degree < deg
39* the number count is only for statistics (in the caller initialise count = 0),
40* in order to get a first computation, initialise eledeg = 1 in the caller.
41* The weights w are needed in the module case, otherwise NULL.
42*/
43{
44  intvec *newhilb;
45  int deg,l,ln,mw;
46  pFDegProc degp;
47
48  eledeg--;
49  if (eledeg == 0)
50  {
51    if (strat->ak>0)
52    {
53      char *used_comp=(char*)omAlloc0(strat->ak+1);
54      int i;
55      for(i=strat->sl;i>0;i--)
56      {
57        used_comp[pGetComp(strat->S[i])]='\1';
58      }
59      for(i=strat->ak;i>0;i--)
60      {
61        if(used_comp[i]=='\0')
62        {
64          return;
65        }
66      }
68    }
69    degp=pFDeg;
70    // if weights for variables were given to std computations,
71    // then pFDeg == degp == kHomModDeg (see kStd)
72    if ((degp!=kModDeg) && (degp!=kHomModDeg)) degp=p_Totaldegree;
73    // degp = pWDegree;
74    l = hilb->length()-1;
75    mw = (*hilb)[l];
76    newhilb = hHstdSeries(strat->Shdl,w,strat->kHomW,Q,strat->tailRing);
77    ln = newhilb->length()-1;
78    deg = degp(strat->P.p,currRing)-mw;
79    loop // compare the series in degree deg, try to increase deg -----------
80    {
81      if (deg < ln) // deg may be out of range
82      {
83        if (deg < l)
84          eledeg = (*newhilb)[deg]-(*hilb)[deg];
85        else
86          eledeg = (*newhilb)[deg];
87      }
88      else
89      {
90        if (deg < l)
91          eledeg = -(*hilb)[deg];
92        else // we have newhilb = hilb
93        {
94          while (strat->Ll>=0)
95          {
96            count++;
97            if(TEST_OPT_PROT)
98            {
99              PrintS("h");
100              mflush();
101            }
102            deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
103          }
104          delete newhilb;
105          return;
106        }
107      }
108      if (eledeg > 0) // elements to delete
109        break;
110      else if (eledeg <0) // strange....see bug_43
111        return;
112      deg++;
113    } /* loop */
114    delete newhilb;
115    while ((strat->Ll>=0) && (degp(strat->L[strat->Ll].p,currRing)-mw < deg)) // the essential step
116    {
117      count++;
118      if(TEST_OPT_PROT)
119      {
120        PrintS("h");
121        mflush();
122      }
123      deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
124    }
125  }
126}
Note: See TracBrowser for help on using the repository browser.