My Project
Loading...
Searching...
No Matches
ppinitialReduction.cc
Go to the documentation of this file.
2#include "Singular/ipid.h"
3
4#include "singularWishlist.h"
6
7#ifndef NDEBUG
8bool isOrderingLocalInT(const ring r)
9{
10 poly one = p_One(r);
11 poly t = p_One(r);
12 p_SetExp(t,1,1,r);
13 p_Setm(t,r);
14 int s = p_LmCmp(one,t,r);
15 p_Delete(&one,r);
16 p_Delete(&t,r);
17 return (s==1);
18}
19#endif
20
21void divideByCommonGcd(poly &g, const ring r)
22{
23 number commonGcd = n_Copy(p_GetCoeff(g,r),r->cf);
24 for (poly gCache=pNext(g); gCache; pIter(gCache))
25 {
26 number commonGcdCache = n_Gcd(commonGcd,p_GetCoeff(gCache,r),r->cf);
27 n_Delete(&commonGcd,r->cf);
28 commonGcd = commonGcdCache;
29 if (n_IsOne(commonGcd,r->cf))
30 {
31 n_Delete(&commonGcd,r->cf);
32 return;
33 }
34 }
35 for (poly gCache=g; gCache; pIter(gCache))
36 {
37 number oldCoeff = p_GetCoeff(gCache,r);
38 number newCoeff = n_Div(oldCoeff,commonGcd,r->cf);
39 p_SetCoeff(gCache,newCoeff,r);
40 }
41 p_Test(g,r);
42 n_Delete(&commonGcd,r->cf);
43 return;
44}
45
46/***
47 * changes a polynomial g with the help p-t such that
48 * 1) each term of g has a distinct monomial in x
49 * 2) no term of g has a coefficient divisible by p
50 * in particular, this means that all g_\alpha can be obtained
51 * by reading the coefficients and that g is initially reduced
52 * with respect to p-t
53 **/
54void pReduce(poly &g, const number p, const ring r)
55{
56 if (g==NULL)
57 return;
58 p_Test(g,r);
59
60 poly toBeChecked = pNext(g);
61 pNext(g) = NULL; poly gEnd = g;
62 poly gCache;
63
64 number coeff, pPower; int power; poly subst;
65 while(toBeChecked)
66 {
67 for (gCache = g; gCache; pIter(gCache))
68 if (p_LeadmonomDivisibleBy(gCache,toBeChecked,r)) break;
69 if (gCache)
70 {
71 n_Power(p,p_GetExp(toBeChecked,1,r)-p_GetExp(gCache,1,r),&pPower,r->cf);
72 coeff = n_Mult(p_GetCoeff(toBeChecked,r),pPower,r->cf);
73 p_SetCoeff(gCache,n_Add(p_GetCoeff(gCache,r),coeff,r->cf),r);
74 n_Delete(&pPower,r->cf); n_Delete(&coeff,r->cf);
75 toBeChecked=p_LmDeleteAndNext(toBeChecked,r);
76 }
77 else
78 {
79 if (n_DivBy(p_GetCoeff(toBeChecked,r),p,r->cf))
80 {
81 power=1;
82 coeff=n_Div(p_GetCoeff(toBeChecked,r),p,r->cf);
83 while (n_DivBy(coeff,p,r->cf))
84 {
85 power++;
86 number coeff0 = n_Div(coeff,p,r->cf);
87 n_Delete(&coeff,r->cf);
88 coeff = coeff0;
89 coeff0 = NULL;
90 if (power<1)
91 {
92 WerrorS("pReduce: overflow in exponent");
93 throw 0;
94 }
95 }
96 subst=p_LmInit(toBeChecked,r);
97 p_AddExp(subst,1,power,r);
98 p_SetCoeff(subst,coeff,r);
99 p_Setm(subst,r); p_Test(subst,r);
100 toBeChecked=p_LmDeleteAndNext(toBeChecked,r);
101 toBeChecked=p_Add_q(toBeChecked,subst,r);
102 p_Test(toBeChecked,r);
103 }
104 else
105 {
106 pNext(gEnd)=toBeChecked;
107 pIter(gEnd); pIter(toBeChecked);
108 pNext(gEnd)=NULL;
109 p_Test(g,r);
110 }
111 }
112 }
113 p_Test(g,r);
115 return;
116}
117
118bool p_xLeadmonomDivisibleBy(const poly g, const poly f, const ring r)
119{
120 poly gx = p_Head(g,r);
121 poly fx = p_Head(f,r);
122 p_SetExp(gx,1,0,r);
123 p_SetExp(fx,1,0,r);
124 p_Setm(gx,r);
125 p_Setm(fx,r);
126 bool b = p_LeadmonomDivisibleBy(gx,fx,r);
127 p_Delete(&gx,r);
128 p_Delete(&fx,r);
129 return b;
130}
131
132void pReduceInhomogeneous(poly &g, const number p, const ring r)
133{
134 if (g==NULL)
135 return;
136 p_Test(g,r);
137
138 poly toBeChecked = pNext(g);
139 pNext(g) = NULL; poly gEnd = g;
140 poly gCache;
141
142 number coeff, pPower; int power; poly subst;
143 while(toBeChecked)
144 {
145 for (gCache = g; gCache; pIter(gCache))
146 if (p_xLeadmonomDivisibleBy(gCache,toBeChecked,r)) break;
147 if (gCache)
148 {
149 n_Power(p,p_GetExp(toBeChecked,1,r)-p_GetExp(gCache,1,r),&pPower,r->cf);
150 coeff = n_Mult(p_GetCoeff(toBeChecked,r),pPower,r->cf);
151 p_SetCoeff(gCache,n_Add(p_GetCoeff(gCache,r),coeff,r->cf),r);
152 n_Delete(&pPower,r->cf); n_Delete(&coeff,r->cf);
153 toBeChecked=p_LmDeleteAndNext(toBeChecked,r);
154 }
155 else
156 {
157 if (n_DivBy(p_GetCoeff(toBeChecked,r),p,r->cf))
158 {
159 power=1;
160 coeff=n_Div(p_GetCoeff(toBeChecked,r),p,r->cf);
161 while (n_DivBy(coeff,p,r->cf))
162 {
163 power++;
164 number coeff0 = n_Div(coeff,p,r->cf);
165 n_Delete(&coeff,r->cf);
166 coeff = coeff0;
167 coeff0 = NULL;
168 if (power<1)
169 {
170 WerrorS("pReduce: overflow in exponent");
171 throw 0;
172 }
173 }
174 subst=p_LmInit(toBeChecked,r);
175 p_AddExp(subst,1,power,r);
176 p_SetCoeff(subst,coeff,r);
177 p_Setm(subst,r); p_Test(subst,r);
178 toBeChecked=p_LmDeleteAndNext(toBeChecked,r);
179 toBeChecked=p_Add_q(toBeChecked,subst,r);
180 p_Test(toBeChecked,r);
181 }
182 else
183 {
184 pNext(gEnd)=toBeChecked;
185 pIter(gEnd); pIter(toBeChecked);
186 pNext(gEnd)=NULL;
187 p_Test(g,r);
188 }
189 }
190 }
191 p_Test(g,r);
193 return;
194}
195
196void ptNormalize(poly* gStar, const number p, const ring r)
197{
198 poly g = *gStar;
199 if (g==NULL || n_DivBy(p_GetCoeff(g,r),p,r->cf))
200 return;
201 p_Test(g,r);
202
203 // create p-t
204 poly pt = p_Init(r);
205 p_SetCoeff(pt,n_Copy(p,r->cf),r);
206
207 pNext(pt) = p_Init(r);
208 p_SetExp(pNext(pt),1,1,r);
209 p_Setm(pNext(pt),r);
210 p_SetCoeff(pNext(pt),n_Init(-1,r->cf),r);
211
212 // make g monic with the help of p-t
213 number a,b;
214 number gcd = n_ExtGcd(p_GetCoeff(g,r),p,&a,&b,r->cf);
215 assume(n_IsUnit(gcd,r->cf));
216 // now a*leadcoef(g)+b*p = gcd with gcd being a unit
217 // so a*g+b*(p-t)*leadmonom(g) should have a unit as leading coefficient
218 poly m = p_Head(g,r);
219 p_SetCoeff(m,n_Init(1,r->cf),r);
220 g = p_Add_q(p_Mult_nn(g,a,r),p_Mult_nn(p_Mult_mm(pt,m,r),b,r),r);
221 n_Delete(&a,r->cf);
222 n_Delete(&b,r->cf);
223 n_Delete(&gcd,r->cf);
224 p_Delete(&m,r);
225
226 p_Test(g,r);
227 return;
228}
229
230void ptNormalize(ideal I, const number p, const ring r)
231{
232 for (int i=0; i<IDELEMS(I); i++)
233 ptNormalize(&(I->m[i]),p,r);
234 return;
235}
236
237#ifndef NDEBUG
239{
240 leftv u = args;
241 if ((u != NULL) && (u->Typ() == IDEAL_CMD))
242 {
243 leftv v = u->next;
244 if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
245 {
246 #ifdef HAVE_OMALLOC
247 omUpdateInfo();
248 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
249 #endif
250 ideal I = (ideal) u->CopyD();
251 number p = (number) v->CopyD();
253 n_Delete(&p,currRing->cf);
254 res->rtyp = IDEAL_CMD;
255 res->data = (char*) I;
256 return FALSE;
257 }
258 }
259 return TRUE;
260}
261#endif //NDEBUG
262
263void pReduce(ideal &I, const number p, const ring r)
264{
265 int k = IDELEMS(I);
266 for (int i=0; i<k; i++)
267 {
268 if (I->m[i]!=NULL)
269 {
270 number c = p_GetCoeff(I->m[i],r);
271 if (!n_DivBy(p,c,r->cf))
272 pReduce(I->m[i],p,r);
273 }
274 }
275}
276
277
278/**
279 * reduces h initially with respect to g,
280 * returns false if h was initially reduced in the first place,
281 * returns true if reductions have taken place.
282 * assumes that h and g are in pReduced form and homogeneous in x of the same degree
283 */
284bool ppreduceInitially(poly* hStar, const poly g, const ring r)
285{
286 poly h = *hStar;
287 if (h==NULL || g==NULL)
288 return false;
289 p_Test(h,r);
290 p_Test(g,r);
291 poly hCache;
292 for (hCache=h; hCache; pIter(hCache))
293 if (p_LeadmonomDivisibleBy(g,hCache,r)) break;
294 if (hCache)
295 {
296 number gAlpha = p_GetCoeff(g,r);
297 poly hAlphaT = p_Init(r);
298 p_SetCoeff(hAlphaT,n_Copy(p_GetCoeff(hCache,r),r->cf),r);
299 p_SetExp(hAlphaT,1,p_GetExp(hCache,1,r)-p_GetExp(g,1,r),r);
300 for (int i=2; i<=r->N; i++)
301 p_SetExp(hAlphaT,i,0,r);
302 p_Setm(hAlphaT,r); p_Test(hAlphaT,r);
303 poly q1 = p_Mult_nn(h,gAlpha,r); p_Test(q1,r);
304 poly q2 = p_Mult_q(p_Copy(g,r),hAlphaT,r); p_Test(q2,r);
305 q2 = p_Neg(q2,r); p_Test(q2,r);
306 h = p_Add_q(q1,q2,r);
307 p_Test(h,r);
308 p_Test(g,r);
309 *hStar = h;
310 return true;
311 }
312 p_Test(h,r);
313 p_Test(g,r);
314 return false;
315}
316
317
318/***
319 * reduces I initially with respect to itself and with respect to p-t.
320 * also sorts the generators of I with respect to the leading monomials in descending order.
321 * assumes that I is generated by elements which are homogeneous in x of the same degree.
322 **/
323bool ppreduceInitially(ideal I, const number p, const ring r)
324{
325 idSkipZeroes(I);
326 int m=IDELEMS(I),n=m; poly cache;
327 do
328 {
329 int j=0;
330 for (int i=1; i<n; i++)
331 {
332 if (p_LmCmp(I->m[i-1],I->m[i],r)<0) /*p_LmCmp(p,q): requires: p,q!=NULL*/
333 {
334 cache=I->m[i-1];
335 I->m[i-1]=I->m[i];
336 I->m[i]=cache;
337 j = i;
338 }
339 }
340 n=j;
341 } while(n);
342 for (int i=0; i<m; i++)
343 pReduce(I->m[i],p,r);
344
345 /***
346 * the first pass. removing terms with the same monomials in x as lt(g_i) out of g_j for i<j
347 **/
348 for (int i=0; i<m-1; i++)
349 for (int j=i+1; j<m; j++)
350 if (ppreduceInitially(&I->m[j], I->m[i], r))
351 pReduce(I->m[j],p,r);
352
353 /***
354 * the second pass. removing terms divisible by lt(g_j) out of g_i for i<j
355 **/
356 for (int i=0; i<m-1; i++)
357 for (int j=i+1; j<m; j++)
358 if (ppreduceInitially(&I->m[i], I->m[j],r))
359 pReduce(I->m[i],p,r);
360
361 /***
362 * removes the elements of I which have been reduced to 0 in the previous two passes
363 **/
364 idSkipZeroes(I);
365 return false;
366}
367
368
369/***
370 * inserts g into I and reduces I with respect to itself and p-t
371 * returns the position in I in which g was inserted
372 * assumes that I was already sorted and initially reduced in the first place
373 **/
374int ppreduceInitially(ideal I, const number p, const poly g, const ring r)
375{
376 id_Test(I,r);
377 p_Test(g,r);
378 idInsertPoly(I,g);
379 idSkipZeroes(I);
380 int n=IDELEMS(I);
381 int j;
382 for (j=n-1; j>0; j--)
383 {
384 if (p_LmCmp(I->m[j], I->m[j-1],r)>0) /*p_LmCmp(p,q) requires: p,q!=NULL */
385 {
386 poly cache = I->m[j];
387 I->m[j] = I->m[j-1];
388 I->m[j-1] = cache;
389 }
390 else
391 break;
392 }
393
394 /***
395 * the first pass. removing terms with the same monomials in x as lt(g_i) out of g_j for i<j
396 * removing terms with the same monomials in x as lt(g_j) out of g_k for j<k
397 **/
398 for (int i=0; i<j; i++)
399 if (ppreduceInitially(&I->m[j], I->m[i], r))
400 pReduce(I->m[j],p,r);
401 for (int k=j+1; k<n; k++)
402 if (ppreduceInitially(&I->m[k], I->m[j], r))
403 {
404 pReduce(I->m[k],p,r);
405 for (int l=j+1; l<k; l++)
406 if (ppreduceInitially(&I->m[k], I->m[l], r))
407 pReduce(I->m[k],p,r);
408 }
409
410 /***
411 * the second pass. removing terms divisible by lt(g_j) and lt(g_k) out of g_i for i<j<k
412 * removing terms divisible by lt(g_k) out of g_j for j<k
413 **/
414 for (int i=0; i<j; i++)
415 for (int k=j; k<n; k++)
416 if (ppreduceInitially(&I->m[i], I->m[k], r))
417 pReduce(I->m[i],p,r);
418 for (int k=j; k<n-1; k++)
419 for (int l=k+1; l<n; l++)
420 if (ppreduceInitially(&I->m[k], I->m[l], r))
421 pReduce(I->m[k],p,r);
422
423 /***
424 * removes the elements of I which have been reduced to 0 in the previous two passes
425 **/
426 idSkipZeroes(I);
427 id_Test(I,r);
428 return j;
429}
430
431
432static poly ppNext(poly p, int l)
433{
434 poly q = p;
435 for (int i=0; i<l; i++)
436 {
437 if (q==NULL)
438 break;
439 pIter(q);
440 }
441 return q;
442}
443
444
445static void sortMarks(const ideal H, const ring r, std::vector<mark> &T)
446{
447 std::pair<int,int> pointerToTerm;
448 int k=T.size();
449 do
450 {
451 int j=0;
452 for (int i=1; i<k-1; i++)
453 {
454 int generatorA = T[i-1].first;
455 int termA = T[i-1].second;
456 int generatorB = T[i].first;
457 int termB = T[i].second;
458 if (p_LmCmp(ppNext(H->m[generatorA],termA),ppNext(H->m[generatorB],termB),r)<0)
459 {
460 mark cache=T[i-1];
461 T[i-1]=T[i];
462 T[i]=cache;
463 j = i;
464 }
465 }
466 k=j;
467 } while(k);
468 return;
469}
470
471
472static poly getTerm(const ideal H, const mark ab)
473{
474 int a = ab.first;
475 int b = ab.second;
476 return ppNext(H->m[a],b);
477}
478
479
480static void adjustMarks(std::vector<mark> &T, const int newEntry)
481{
482 for (unsigned i=0; i<T.size(); i++)
483 {
484 if (T[i].first>=newEntry)
485 T[i].first = T[i].first+1;
486 }
487 return;
488}
489
490
491static void cleanupMarks(const ideal H, std::vector<mark> &T)
492{
493 for (unsigned i=0; i<T.size();)
494 {
495 if (getTerm(H,T[i])==NULL)
496 T.erase(T.begin()+i);
497 else
498 i++;
499 }
500 return;
501}
502
503
504/***
505 * reduces H initially with respect to itself, with respect to p-t,
506 * and with respect to G.
507 * assumes that the generators of H are homogeneous in x of the same degree,
508 * assumes that the generators of G are homogeneous in x of lesser degree.
509 **/
510bool ppreduceInitially(ideal &H, const number p, const ideal G, const ring r)
511{
512 /***
513 * Step 1: reduce H initially with respect to itself and with respect to p-t
514 **/
515 if (ppreduceInitially(H,p,r)) return true;
516
517 /***
518 * Step 2: initialize an ideal I in which the reductions will take place-
519 * along the reduction it will be enlarged with elements that will be discarded at the end
520 * initialize a working list T which keeps track.
521 * the working list T is a vector of pairs of integer.
522 * if T contains a pair (i,j) then that means that in the i-th element of H
523 * term j and subsequent terms need to be checked for reduction.
524 * T is sorted by the ordering on the temrs the pairs correspond to.
525 **/
526 int m=IDELEMS(H);
527 ideal I = idInit(m);
528 std::vector<mark> T;
529 for (int i=0; i<m; i++)
530 {
531 if(H->m[i]!=NULL)
532 {
533 I->m[i]=H->m[i];
534 if (pNext(I->m[i])!=NULL)
535 T.push_back(std::pair<int,int>(i,1));
536 }
537 }
538
539 /***
540 * Step 3: as long as the working list is not empty, successively reduce terms in it
541 * by adding suitable elements to I and reducing it initially with respect to itself
542 **/
543 int k=IDELEMS(G);
544 while (T.size()>0)
545 {
546 sortMarks(I,r,T);
547 int i=0;
548 for (; i<k; i++)
549 {
550 if(G->m[i]!=NULL)
551 {
552 if (p_LeadmonomDivisibleBy(G->m[i],getTerm(I,T[0]),r)) break;
553 }
554 }
555 if (i<k)
556 {
557 poly g = p_One(r); poly h0 = getTerm(I,T[0]);
558 assume(h0!=NULL);
559 for (int j=2; j<=r->N; j++)
560 p_SetExp(g,j,p_GetExp(h0,j,r)-p_GetExp(G->m[i],j,r),r);
561 p_Setm(g,r);
562 g = p_Mult_q(g,p_Copy(G->m[i],r),r);
563 int newEntry = ppreduceInitially(I,p,g,r);
564 adjustMarks(T,newEntry);
565 }
566 else
567 T[0].second = T[0].second+1;
568 cleanupMarks(I,T);
569 }
570
571 /***
572 * Step 4: cleanup, delete all polynomials in I which have been added in Step 3
573 **/
574 k=IDELEMS(I);
575 for (int i=0; i<k; i++)
576 {
577 if(I->m[i]!=NULL)
578 {
579 for (int j=0; j<m; j++)
580 {
581 if ((H->m[j]!=NULL)
582 && (p_LeadmonomDivisibleBy(H->m[j],I->m[i],r)))
583 {
584 I->m[i]=NULL;
585 break;
586 }
587 }
588 }
589 }
590 id_Delete(&I,r);
591 return false;
592}
593
594
595/**
596 * reduces I initially with respect to itself.
597 * assumes that the generators of I are homogeneous in x and that p-t is in I.
598 */
599bool ppreduceInitially(ideal I, const ring r, const number p)
600{
601 assume(!n_IsUnit(p,r->cf));
602
603 /***
604 * Step 1: split up I into components of same degree in x
605 * the lowest component should only contain p-t
606 **/
607 std::map<long,ideal> H; int n = IDELEMS(I);
608 for (int i=0; i<n; i++)
609 {
610 if(I->m[i]!=NULL)
611 {
612 I->m[i] = p_Cleardenom(I->m[i],r);
613 long d = 0;
614 for (int j=2; j<=r->N; j++)
615 d += p_GetExp(I->m[i],j,r);
616 std::map<long,ideal>::iterator it = H.find(d);
617 if (it != H.end())
618 idInsertPoly(it->second,I->m[i]);
619 else
620 {
621 std::pair<long,ideal> Hd(d,idInit(1));
622 Hd.second->m[0] = I->m[i];
623 H.insert(Hd);
624 }
625 }
626 }
627
628 std::map<long,ideal>::iterator it=H.begin();
629 ideal Hi = it->second;
630 idShallowDelete(&Hi);
631 it++;
632 Hi = it->second;
633
634 /***
635 * Step 2: reduce each component initially with respect to itself
636 * and all lower components
637 **/
638 if (ppreduceInitially(Hi,p,r)) return true;
639 idSkipZeroes(Hi);
640 id_Test(Hi,r);
641 id_Test(I,r);
642
643 ideal G = idInit(n); int m=0;
644 ideal GG = (ideal) omAllocBin(sip_sideal_bin);
645 GG->nrows = 1; GG->rank = 1; GG->m=NULL;
646
647 for (it++; it!=H.end(); it++)
648 {
649 int l=IDELEMS(Hi); int k=l; poly cache;
650 /**
651 * sorts Hi according to degree in t in descending order
652 * (lowest first, highest last)
653 */
654 do
655 {
656 int j=0;
657 for (int i=1; i<k; i++)
658 {
659 if (p_GetExp(Hi->m[i-1],1,r)<p_GetExp(Hi->m[i],1,r))
660 {
661 cache=Hi->m[i-1];
662 Hi->m[i-1]=Hi->m[i];
663 Hi->m[i]=cache;
664 j = i;
665 }
666 }
667 k=j;
668 } while(k);
669 int kG=n-m, kH=0;
670 for (int i=n-m-l; i<n; i++)
671 {
672 if (kG==n)
673 {
674 memcpy(&(G->m[i]),&(Hi->m[kH]),(n-i)*sizeof(poly));
675 break;
676 }
677 if (kH==l)
678 break;
679 if (p_GetExp(G->m[kG],1,r)>p_GetExp(Hi->m[kH],1,r))
680 G->m[i] = G->m[kG++];
681 else
682 G->m[i] = Hi->m[kH++];
683 }
684 m += l; IDELEMS(GG) = m; GG->m = &G->m[n-m];
685 id_Test(it->second,r);
686 id_Test(GG,r);
687 if (ppreduceInitially(it->second,p,GG,r)) return true;
688 id_Test(it->second,r);
689 id_Test(GG,r);
690 idShallowDelete(&Hi); Hi = it->second;
691 }
692 idShallowDelete(&Hi);
693
694 ptNormalize(I,p,r);
697 return false;
698}
699
700
701// BOOLEAN ppreduceInitially(leftv res, leftv args)
702// {
703// leftv u = args;
704// if ((u != NULL) && (u->Typ() == IDEAL_CMD))
705// {
706// ideal I = (ideal) u->CopyD();
707// (void) ppreduceInitially(I,currRing);
708// res->rtyp = IDEAL_CMD;
709// res->data = (char*) I;
710// return FALSE;
711// }
712// return TRUE;
713// }
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
void * ADDRESS
Definition auxiliary.h:120
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
int p
Definition cfModGcd.cc:4086
g
Definition cfModGcd.cc:4098
const CanonicalForm & GG
Definition cfModGcd.cc:4084
CanonicalForm b
Definition cfModGcd.cc:4111
FILE * f
Definition checklibs.c:9
void * CopyD(int t)
Definition subexpr.cc:714
int Typ()
Definition subexpr.cc:1048
leftv next
Definition subexpr.h:86
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:639
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:457
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition coeffs.h:653
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:667
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition coeffs.h:521
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition coeffs.h:635
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:618
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition coeffs.h:674
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:541
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether 'a' is divisible 'b'; for r encoding a field: TRUE iff 'b' does not represent zero in Z:...
Definition coeffs.h:747
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition coeffs.h:474
#define Print
Definition emacs.cc:80
const CanonicalForm int s
Definition facAbsFact.cc:51
CanonicalForm res
Definition facAbsFact.cc:60
CanonicalForm H
Definition facAbsFact.cc:60
CanonicalForm subst(const CanonicalForm &f, const CFList &a, const CFList &b, const CanonicalForm &Rstar, bool isFunctionField)
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
int j
Definition facHensel.cc:110
void WerrorS(const char *s)
Definition feFopen.cc:24
@ IDEAL_CMD
Definition grammar.cc:285
@ NUMBER_CMD
Definition grammar.cc:289
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
STATIC_VAR jList * T
Definition janet.cc:30
STATIC_VAR TreeM * G
Definition janet.cc:31
STATIC_VAR Poly * h
Definition janet.cc:971
VAR idhdl h0
Definition libparse.cc:1143
#define assume(x)
Definition mod2.h:389
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
#define p_GetCoeff(p, r)
Definition monomials.h:50
#define omAllocBin(bin)
#define omFreeBin(addr, bin)
#define NULL
Definition omList.c:12
omInfo_t om_Info
Definition omStats.c:16
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2893
poly p_One(const ring r)
Definition p_polys.cc:1314
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
static long p_AddExp(poly p, int v, long ee, ring r)
Definition p_polys.h:608
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1356
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
static int p_LmCmp(poly p, poly q, const ring r)
Definition p_polys.h:1601
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471
static poly p_Mult_nn(poly p, number n, const ring r)
Definition p_polys.h:960
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1053
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1341
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition p_polys.h:757
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
#define p_Test(p, r)
Definition p_polys.h:161
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pPower(p, q)
Definition polys.h:205
void pReduceInhomogeneous(poly &g, const number p, const ring r)
void ptNormalize(poly *gStar, const number p, const ring r)
static poly ppNext(poly p, int l)
static void cleanupMarks(const ideal H, std::vector< mark > &T)
bool isOrderingLocalInT(const ring r)
void pReduce(poly &g, const number p, const ring r)
static poly getTerm(const ideal H, const mark ab)
void divideByCommonGcd(poly &g, const ring r)
static void adjustMarks(std::vector< mark > &T, const int newEntry)
static void sortMarks(const ideal H, const ring r, std::vector< mark > &T)
bool ppreduceInitially(poly *hStar, const poly g, const ring r)
reduces h initially with respect to g, returns false if h was initially reduced in the first place,...
bool p_xLeadmonomDivisibleBy(const poly g, const poly f, const ring r)
std::pair< int, int > mark
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
VAR omBin sip_sideal_bin
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define IDELEMS(i)
#define id_Test(A, lR)
static void idShallowDelete(ideal *h)
id_ShallowDelete deletes the monomials of the polynomials stored inside of it
static BOOLEAN p_LeadmonomDivisibleBy(poly a, poly b, const ring r)
p_LmDivisibleBy checks also the divisibility of coefficients
sleftv * leftv
Definition structs.h:53
int gcd(int a, int b)
#define omUpdateInfo()
Definition xalloc.h:230