My Project
Loading...
Searching...
No Matches
khstd.cc
Go to the documentation of this file.
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
17
21
22#include "kernel/polys.h"
23
24/*2
25* compare the given hilbert series with the current one,
26* delete not needed pairs (if possible)
27*/
28void khCheck( ideal Q, intvec *w, intvec *hilb, int &eledeg, int &count,
29 kStrategy strat)
30 /* ideal S=strat->Shdl, poly p=strat->P.p */
31/*
32* compute the number eledeg of elements with a degree >= deg(p) going into kStd,
33* p is already in S and for all further q going into S yields deg(q) >= deg(p),
34* the real computation is only done if the degree has changed,
35* then we have eledeg == 0 on this degree and we make:
36* - compute the Hilbert series newhilb from S
37* (hilb is the final Hilbert series)
38* - in module case: check that all comp up to strat->ak are used
39* - compute the eledeg from newhilb-hilb for the first degree deg with
40* newhilb-hilb != 0
41* (Remark: consider the Hilbert series with coeff. up to infinity)
42* - clear the set L for degree < deg
43* the number count is only for statistics (in the caller initialise count = 0),
44* in order to get a first computation, initialise eledeg = 1 in the caller.
45* The weights w are needed in the module case, otherwise NULL.
46*/
47{
49 int deg,l,ln,mw;
51
52 eledeg--;
53 if (eledeg == 0)
54 {
55 if (strat->ak>0)
56 {
57 char *used_comp=(char*)omAlloc0(strat->ak+1);
58 int i;
59 for(i=strat->sl;i>0;i--)
60 {
61 used_comp[pGetComp(strat->S[i])]='\1';
62 }
63 for(i=strat->ak;i>0;i--)
64 {
65 if(used_comp[i]=='\0')
66 {
68 return;
69 }
70 }
72 }
73 degp=currRing->pFDeg;
74 // if weights for variables were given to std computations,
75 // then pFDeg == degp == kHomModDeg (see kStd)
77 // degp = pWDegree;
78 l = hilb->length()-1;
79 mw = (*hilb)[l];
80 newhilb =hFirstSeries(strat->Shdl,w,Q,strat->kHomW);
81 ln = newhilb->length()-1;
82 deg = degp(strat->P.p,currRing);
83 loop // compare the series in degree deg, try to increase deg -----------
84 {
85 if (deg < ln) // deg may be out of range
86 {
87 if (deg < l)
88 eledeg = (*newhilb)[deg]-(*hilb)[deg];
89 else
90 eledeg = (*newhilb)[deg];
91 }
92 else
93 {
94 if (deg < l)
95 eledeg = -(*hilb)[deg];
96 else // we have newhilb = hilb
97 {
98 while (strat->Ll>=0)
99 {
100 count++;
101 if(TEST_OPT_PROT)
102 {
103 PrintS("h");
104 mflush();
105 }
106 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
107 }
108 delete newhilb;
109 return;
110 }
111 }
112 if (eledeg > 0) // elements to delete
113 break;
114 else if (eledeg <0) // strange....see bug_43
115 return;
116 deg++;
117 } /* loop */
118 delete newhilb;
119 while ((strat->Ll>=0) && (degp(strat->L[strat->Ll].p,currRing)-mw < deg)) // the essential step
120 {
121 count++;
122 if(TEST_OPT_PROT)
123 {
124 PrintS("h");
125 mflush();
126 }
127 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
128 }
129 }
130}
131
132#if 0
133/*2
134* compare the given hilbert series with the current one,
135* delete not needed pairs (if possible)
136*/
137void khCheck( ideal Q, intvec *w, poly hilb, const ring Qt, int &eledeg, int &count,
138 kStrategy strat)
139 /* ideal S=strat->Shdl, poly p=strat->P.p */
140/*
141* compute the number eledeg of elements with a degree >= deg(p) going into kStd,
142* p is already in S and for all further q going into S yields deg(q) >= deg(p),
143* the real computation is only done if the degree has changed,
144* then we have eledeg == 0 on this degree and we make:
145* - compute the Hilbert series newhilb from S
146* (hilb is the final Hilbert series)
147* - in module case: check that all comp up to strat->ak are used
148* - compute the eledeg from newhilb-hilb for the first degree deg with
149* newhilb-hilb != 0
150* (Remark: consider the Hilbert series with coeff. up to infinity)
151* - clear the set L for degree < deg
152* the number count is only for statistics (in the caller initialise count = 0),
153* in order to get a first computation, initialise eledeg = 1 in the caller.
154* The weights w are needed in the module case, otherwise NULL.
155*/
156{
157 poly newhilb;
158 int deg,l,ln;
159 mpz_t mw;
161
162 eledeg--;
163 if (eledeg == 0)
164 {
165 if (strat->ak>0)
166 {
167 char *used_comp=(char*)omAlloc0(strat->ak+1);
168 int i;
169 for(i=strat->sl;i>0;i--)
170 {
171 used_comp[pGetComp(strat->S[i])]='\1';
172 }
173 for(i=strat->ak;i>0;i--)
174 {
175 if(used_comp[i]=='\0')
176 {
178 return;
179 }
180 }
182 }
183 degp=currRing->pFDeg;
184 // if weights for variables were given to std computations,
185 // then pFDeg == degp == kHomModDeg (see kStd)
187 // degp = pWDegree;
188 l = p_FDeg(hilb,Qt);
190 n_MPZ(mw,&lt,Qt->cf);
191 newhilb =hFirstSeries0m(strat->Shdl,Q,w,strat->kHomW,currRing,Qt);
192 ln = p_FDeg(newhilb);
193 deg = degp(strat->P.p,currRing);
194 loop // compare the series in degree deg, try to increase deg -----------
195 {
196 if (deg < ln) // deg may be out of range
197 {
198 if (deg < l)
199 eledeg = (*newhilb)[deg]-(*hilb)[deg];
200 else
201 eledeg = (*newhilb)[deg];
202 }
203 else
204 {
205 if (deg < l)
206 eledeg = -(*hilb)[deg];
207 else // we have newhilb = hilb
208 {
209 while (strat->Ll>=0)
210 {
211 count++;
212 if(TEST_OPT_PROT)
213 {
214 PrintS("h");
215 mflush();
216 }
217 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
218 }
219 delete newhilb;
220 return;
221 }
222 }
223 if (eledeg > 0) // elements to delete
224 break;
225 else if (eledeg <0) // strange....see bug_43
226 return;
227 deg++;
228 } /* loop */
229 delete newhilb;
230 while ((strat->Ll>=0) && (degp(strat->L[strat->Ll].p,currRing)-mw < deg)) // the essential step
231 {
232 count++;
233 if(TEST_OPT_PROT)
234 {
235 PrintS("h");
236 mflush();
237 }
238 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
239 }
240 }
241}
242#endif
243
245 kStrategy strat)
246
247/*
248This will be used for the local orderings in the case of the inhomogeneous ideals.
249Assume f1,...,fs are already in the standard basis. Test if hilb(LM(f1),...,LM(fs),1)
250is equal to the inputted one.
251If no, do nothing.
252If Yes, we know that all polys that we need are already in the standard basis
253so delete all the remaining pairs
254*/
255{
256 ideal Lm;
258
259 Lm = id_Head(strat->Shdl,currRing);
260
261 newhilb =hFirstSeries(Lm,w,Q,strat->kHomW);
262
263 if(newhilb->compare(hilb) == 0)
264 {
265 while (strat->Ll>=0)
266 {
267 count++;
268 if(TEST_OPT_PROT)
269 {
270 PrintS("h");
271 mflush();
272 }
273 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
274 }
275 delete newhilb;
276 return;
277 }
279}
int l
Definition cfEzgcd.cc:100
int i
Definition cfEzgcd.cc:132
int length() const
int Ll
Definition kutil.h:351
polyset S
Definition kutil.h:306
int ak
Definition kutil.h:353
intvec * kHomW
Definition kutil.h:336
ideal Shdl
Definition kutil.h:303
LObject P
Definition kutil.h:302
LSet L
Definition kutil.h:327
int sl
Definition kutil.h:348
static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
conversion of n to a GMP integer; 0 if not possible
Definition coeffs.h:552
const CanonicalForm & w
Definition facAbsFact.cc:51
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:2080
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition hilb.cc:2167
void khCheckLocInhom(ideal Q, intvec *w, intvec *hilb, int &count, kStrategy strat)
Definition khstd.cc:244
void khCheck(ideal Q, intvec *w, intvec *hilb, int &eledeg, int &count, kStrategy strat)
Definition khstd.cc:28
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2419
long kModDeg(poly p, const ring r)
Definition kstd1.cc:2409
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1213
#define omFree(addr)
#define omAlloc0(size)
#define TEST_OPT_PROT
Definition options.h:105
static long p_FDeg(const poly p, const ring r)
Definition p_polys.h:380
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1521
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
Compatibility layer for legacy polynomial operations (over currRing)
#define pGetComp(p)
Component.
Definition polys.h:37
void PrintS(const char *s)
Definition reporter.cc:284
#define mflush()
Definition reporter.h:58
long(* pFDegProc)(poly p, ring r)
Definition ring.h:38
int status int void size_t count
Definition si_signals.h:69
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
#define Q
Definition sirandom.c:26
#define loop
Definition structs.h:75