source: git/kernel/khstd.cc @ a82c308

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