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, bigintmat *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{
48 bigintmat *newhilb;
49 int deg,l,ln,mw;
50 pFDegProc degp;
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 {
67 omFree((ADDRESS)used_comp);
68 return;
69 }
70 }
71 omFree((ADDRESS)used_comp);
72 }
73 degp=currRing->pFDeg;
74 // if weights for variables were given to std computations,
75 // then pFDeg == degp == kHomModDeg (see kStd)
76 if ((degp!=kModDeg) && (degp!=kHomModDeg)) degp=p_Totaldegree;
77 // degp = pWDegree;
78 l = hilb->cols();
79 mw = n_Int(BIMATELEM(*hilb,1,l),coeffs_BIGINT);
80 newhilb =hFirstSeries0b(strat->Shdl,Q,strat->kHomW,w,currRing,coeffs_BIGINT);
81 ln = newhilb->cols();
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 {
89 number s=n_Sub(BIMATELEM(*newhilb,1,deg+1),
90 BIMATELEM(*hilb,1,deg+1),coeffs_BIGINT);
91 eledeg = n_Int(s,coeffs_BIGINT);
92 }
93 else
94 eledeg = n_Int(BIMATELEM(*newhilb,1,deg+1),coeffs_BIGINT);
95 }
96 else
97 {
98 if (deg < l)
99 eledeg = -n_Int(BIMATELEM(*hilb,1,deg+1),coeffs_BIGINT);
100 else // we have newhilb = hilb
101 {
102 while (strat->Ll>=0)
103 {
104 count++;
105 if(TEST_OPT_PROT)
106 {
107 PrintS("h");
108 mflush();
109 }
110 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
111 }
112 delete newhilb;
113 return;
114 }
115 }
116 if (eledeg > 0) // elements to delete
117 break;
118 else if (eledeg <0) // strange....see bug_43
119 return;
120 deg++;
121 } /* loop */
122 delete newhilb;
123 while ((strat->Ll>=0) && (degp(strat->L[strat->Ll].p,currRing)-mw < deg)) // the essential step
124 {
125 count++;
126 if(TEST_OPT_PROT)
127 {
128 PrintS("h");
129 mflush();
130 }
131 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
132 }
133 }
134}
135
136#if 0
137/*2
138* compare the given hilbert series with the current one,
139* delete not needed pairs (if possible)
140*/
141void khCheck( ideal Q, intvec *w, poly hilb, const ring Qt, int &eledeg, int &count,
142 kStrategy strat)
143 /* ideal S=strat->Shdl, poly p=strat->P.p */
144/*
145* compute the number eledeg of elements with a degree >= deg(p) going into kStd,
146* p is already in S and for all further q going into S yields deg(q) >= deg(p),
147* the real computation is only done if the degree has changed,
148* then we have eledeg == 0 on this degree and we make:
149* - compute the Hilbert series newhilb from S
150* (hilb is the final Hilbert series)
151* - in module case: check that all comp up to strat->ak are used
152* - compute the eledeg from newhilb-hilb for the first degree deg with
153* newhilb-hilb != 0
154* (Remark: consider the Hilbert series with coeff. up to infinity)
155* - clear the set L for degree < deg
156* the number count is only for statistics (in the caller initialise count = 0),
157* in order to get a first computation, initialise eledeg = 1 in the caller.
158* The weights w are needed in the module case, otherwise NULL.
159*/
160{
161 poly newhilb;
162 int deg,l,ln;
163 mpz_t mw;
164 pFDegProc degp;
165
166 eledeg--;
167 if (eledeg == 0)
168 {
169 if (strat->ak>0)
170 {
171 char *used_comp=(char*)omAlloc0(strat->ak+1);
172 int i;
173 for(i=strat->sl;i>0;i--)
174 {
175 used_comp[pGetComp(strat->S[i])]='\1';
176 }
177 for(i=strat->ak;i>0;i--)
178 {
179 if(used_comp[i]=='\0')
180 {
181 omFree((ADDRESS)used_comp);
182 return;
183 }
184 }
185 omFree((ADDRESS)used_comp);
186 }
187 degp=currRing->pFDeg;
188 // if weights for variables were given to std computations,
189 // then pFDeg == degp == kHomModDeg (see kStd)
190 if ((degp!=kModDeg) && (degp!=kHomModDeg)) degp=p_Totaldegree;
191 // degp = pWDegree;
192 l = p_FDeg(hilb,Qt);
193 number lt=pGetcoeff(hilb);
194 n_MPZ(mw,&lt,Qt->cf);
195 newhilb =hFirstSeries0m(strat->Shdl,Q,w,strat->kHomW,currRing,Qt);
196 ln = p_FDeg(newhilb);
197 deg = degp(strat->P.p,currRing);
198 loop // compare the series in degree deg, try to increase deg -----------
199 {
200 if (deg < ln) // deg may be out of range
201 {
202 if (deg < l)
203 eledeg = (*newhilb)[deg]-(*hilb)[deg];
204 else
205 eledeg = (*newhilb)[deg];
206 }
207 else
208 {
209 if (deg < l)
210 eledeg = -(*hilb)[deg];
211 else // we have newhilb = hilb
212 {
213 while (strat->Ll>=0)
214 {
215 count++;
216 if(TEST_OPT_PROT)
217 {
218 PrintS("h");
219 mflush();
220 }
221 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
222 }
223 delete newhilb;
224 return;
225 }
226 }
227 if (eledeg > 0) // elements to delete
228 break;
229 else if (eledeg <0) // strange....see bug_43
230 return;
231 deg++;
232 } /* loop */
233 delete newhilb;
234 while ((strat->Ll>=0) && (degp(strat->L[strat->Ll].p,currRing)-mw < deg)) // the essential step
235 {
236 count++;
237 if(TEST_OPT_PROT)
238 {
239 PrintS("h");
240 mflush();
241 }
242 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
243 }
244 }
245}
246#endif
247
248void khCheckLocInhom(ideal Q, intvec *w, bigintmat *hilb, int &count,
249 kStrategy strat)
250
251/*
252This will be used for the local orderings in the case of the inhomogeneous ideals.
253Assume f1,...,fs are already in the standard basis. Test if hilb(LM(f1),...,LM(fs),1)
254is equal to the inputted one.
255If no, do nothing.
256If Yes, we know that all polys that we need are already in the standard basis
257so delete all the remaining pairs
258*/
259{
260 ideal Lm;
261 bigintmat *newhilb;
262
263 Lm = id_Head(strat->Shdl,currRing);
264
265 newhilb =hFirstSeries0b(strat->Shdl,Q,strat->kHomW,w,currRing,coeffs_BIGINT);
266
267 if(newhilb->compare(hilb) == 0)
268 {
269 while (strat->Ll>=0)
270 {
271 count++;
272 if(TEST_OPT_PROT)
273 {
274 PrintS("h");
275 mflush();
276 }
277 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
278 }
279 delete newhilb;
280 return;
281 }
282 id_Delete(&Lm,currRing);
283}
void * ADDRESS
Definition auxiliary.h:120
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
int l
Definition cfEzgcd.cc:100
int i
Definition cfEzgcd.cc:132
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
int compare(const bigintmat *op) const
Definition bigintmat.cc:360
int Ll
Definition kutil.h:352
polyset S
Definition kutil.h:307
int ak
Definition kutil.h:354
intvec * kHomW
Definition kutil.h:337
ideal Shdl
Definition kutil.h:304
LObject P
Definition kutil.h:303
LSet L
Definition kutil.h:328
int sl
Definition kutil.h:349
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:548
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
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:656
const CanonicalForm int s
Definition facAbsFact.cc:51
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:2063
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2655
void khCheck(ideal Q, intvec *w, bigintmat *hilb, int &eledeg, int &count, kStrategy strat)
Definition khstd.cc:28
void khCheckLocInhom(ideal Q, intvec *w, bigintmat *hilb, int &count, kStrategy strat)
Definition khstd.cc:248
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2417
long kModDeg(poly p, const ring r)
Definition kstd1.cc:2407
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1215
#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:382
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1523
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
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:38
void PrintS(const char *s)
Definition reporter.cc:284
#define mflush()
Definition reporter.h:58
long(* pFDegProc)(poly p, ring r)
Definition ring.h:39
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
skStrategy * kStrategy
Definition structs.h:54
#define loop
Definition structs.h:71