kInline.h
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /***************************************************************
5  * File: kInline.h
6  * Purpose: implementation of std related inline routines
7  * Author: obachman (Olaf Bachmann)
8  * Created: 8/00
9  *******************************************************************/
10 #ifndef KINLINE_H
11 #define KINLINE_H
12 
13 #if !defined(NO_KINLINE) || defined(KUTIL_CC)
14 /* this file is a header file with inline routines,
15  * if NO_KINLINE is not defined (AND ONLY THEN!)
16  * otherwise it is an part of kutil.cc and a source file!
17  * (remark: NO_KINLINE is defined by KDEBUG, i.e. in the debug version)
18  */
19 
20 #include <omalloc/omalloc.h>
21 #include <misc/options.h>
22 
24 #include <polys/kbuckets.h>
25 
26 #include <kernel/polys.h>
27 
28 
29 #define HAVE_TAIL_BIN
30 // This doesn't really work, fixme, if necessary
31 // #define HAVE_LM_BIN
32 
33 
34 
36 {
37  assume(i>= 0 && i<=sl);
38  assume(S_2_R[i] >= 0 && S_2_R[i] <= tl);
39  TObject* TT = R[S_2_R[i]];
40  assume(TT != NULL && TT->p == S[i]);
41  return TT;
42 }
43 
45 {
46  if (i >= 0 && i <= sl)
47  {
48  int sri= S_2_R[i];
49  if ((sri >= 0) && (sri <= tl))
50  {
51  TObject* t = R[sri];
52  if ((t != NULL) && (t->p == S[i]))
53  return t;
54  }
55  // last but not least, try kFindInT
56  sri = kFindInT(S[i], T, tl);
57  if (sri >= 0)
58  return &(T[sri]);
59  }
60  return NULL;
61 }
62 
64 {
65  if (tailRing == currRing)
66  return kNoether;
67  else
68  {
69  assume((kNoether == NULL && t_kNoether == NULL) ||
70  (kNoether != NULL && t_kNoether != NULL));
71  return t_kNoether;
72  }
73 }
74 
75 /***************************************************************
76  *
77  * Operation on TObjects
78  *
79  ***************************************************************/
80 
82 {
83  TSet T = (TSet)omAlloc0(setmaxT*sizeof(TObject));
84  for (int i=setmaxT-1; i>=0; i--)
85  {
86  T[i].tailRing = currRing;
87  T[i].i_r = -1;
88  }
89  return T;
90 }
91 
93 {
94  return (TObject**) omAlloc0(setmaxT*sizeof(TObject*));
95 }
96 
97 KINLINE unsigned long* initsevT()
98 {
99  return (unsigned long*) omAlloc0(setmaxT*sizeof(unsigned long));
100 }
101 
102 // initialization
104 {
105  tailRing = r;
106 }
108 {
109  memset(this, 0, sizeof(sTObject));
110  i_r = -1;
111  Set(r);
112 }
114 {
115  Init(r);
116 }
117 KINLINE void sTObject::Set(poly p_in, ring r)
118 {
119  if (r != currRing)
120  {
121  assume(r == tailRing);
122  p_Test(p_in, r);
123  t_p = p_in;
124  }
125  else
126  {
127  pp_Test(p_in, currRing, tailRing);
128  p = p_in;
129  }
130 }
131 
133 {
134  Init(r);
135  Set(p_in, r);
136 }
137 
138 KINLINE void sTObject::Set(poly p_in, ring c_r, ring t_r)
139 {
140  if (c_r != t_r)
141  {
142  assume(c_r == currRing && t_r == tailRing);
143  pp_Test(p_in, currRing, t_r);
144  p = p_in;
145  }
146  else
147  {
148  Set(p_in, c_r);
149  }
150 }
151 
152 KINLINE sTObject::sTObject(poly p_in, ring c_r, ring t_r)
153 {
154  Init(t_r);
155  Set(p_in, c_r, t_r);
156 }
157 
159 {
160  *this = *T;
161  if (copy)
162  {
163  if (t_p != NULL)
164  {
165  t_p = p_Copy(t_p, tailRing);
167  }
168  else
169  {
170  p = p_Copy(p, currRing, tailRing);
171  }
172  }
173 }
174 
176 {
177  if (t_p != NULL)
178  {
179  p_Delete(&t_p, tailRing);
180  if (p != NULL)
181  p_LmFree(p, currRing);
182  }
183  else
184  {
186  }
187 }
188 
190 {
191  p = NULL;
192  t_p = NULL;
193  ecart = 0;
194  length = 0;
195  pLength = 0;
196  FDeg = 0;
197  is_normalized = FALSE;
198 }
199 
201 {
202  if (t_p != NULL)
203  {
204  t_p = p_Copy(t_p, tailRing);
205  if (p != NULL)
206  {
207  p = p_Head(p, currRing);
208  if (pNext(t_p) != NULL) pNext(p) = pNext(t_p);
209  }
210  }
211  else
212  {
213  p = p_Copy(p, currRing, tailRing);
214  }
215 }
216 
218 {
219  if (p == NULL && t_p != NULL)
221 
222  return p;
223 }
225 {
226  if (t_p == NULL)
227  {
228  if (p != NULL && tailRing != currRing)
229  {
231  return t_p;
232  }
233  return p;
234  }
235  return t_p;
236 }
238 {
239  assume(r == tailRing || r == currRing);
240  if (r == currRing)
241  return GetLmCurrRing();
242 
243  if (t_p == NULL && p != NULL)
245 
246  return t_p;
247 }
248 
249 KINLINE void sTObject::GetLm(poly &p_r, ring &r_r) const
250 {
251  if (t_p != NULL)
252  {
253  p_r = t_p;
254  r_r = tailRing;
255  }
256  else
257  {
258  p_r = p;
259  r_r = currRing;
260  }
261 }
262 
264 {
265  return (p == NULL && t_p == NULL);
266 }
267 
269 {
270  if (pLength <= 0) pLength = ::pLength(p != NULL ? p : t_p);
271  return pLength;
272 }
273 
275 {
276  if (p == NULL && t_p != NULL)
278 }
279 
281 {
282  assume(p != NULL || t_p != NULL);
283  if (t_p != NULL) return pNext(t_p);
284  return pNext(p);
285 }
286 
287 // Iterations
289 {
290  assume(p != NULL || t_p != NULL);
291  if (t_p != NULL)
292  {
293  t_p = p_LmDeleteAndNext(t_p, tailRing);
294  if (p != NULL)
295  {
296  p_LmFree(p, currRing);
297  p = NULL;
298  }
299  }
300  else
301  {
303  }
304  is_normalized = FALSE;
305 }
306 
307 
308 // arithmetic
310 {
311  if (t_p != NULL)
312  { t_p = p_Mult_nn(t_p, n, tailRing);
313  if (p != NULL) pSetCoeff0(p, pGetCoeff(t_p));
314  }
315  else
316  {
317  p = p_Mult_nn(p, n, currRing, tailRing);
318  }
319 }
320 
322 {
323  if (t_p != NULL)
324  {
325  pNormalize(t_p);
326  if (p != NULL) pSetCoeff0(p, pGetCoeff(t_p));
327  }
328  else
329  {
330  pNormalize(p);
331  }
332 }
333 
335 {
336  if (t_p != NULL)
337  {
338  nNormalize(pGetCoeff(t_p));
339  if (p != NULL) pSetCoeff0(p, pGetCoeff(t_p));
340  }
341  else
342  {
344  }
345 }
346 
347 KINLINE void
348 sTObject::ShallowCopyDelete(ring new_tailRing, omBin new_tailBin,
350  BOOLEAN set_max)
351 {
352  if (new_tailBin == NULL) new_tailBin = new_tailRing->PolyBin;
353  if (t_p != NULL)
354  {
355  t_p = p_shallow_copy_delete(t_p, tailRing, new_tailRing, new_tailBin);
356  if (p != NULL)
357  pNext(p) = pNext(t_p);
358  if (new_tailRing == currRing)
359  {
360  if (p == NULL) p = t_p;
361  else p_LmFree(t_p, tailRing);
362  t_p = NULL;
363  }
364  }
365  else if (p != NULL)
366  {
367  if (pNext(p) != NULL)
368  {
370  tailRing, new_tailRing, new_tailBin);
371  }
372  if (new_tailRing != currRing)
373  {
374  t_p = k_LmInit_currRing_2_tailRing(p, new_tailRing);
375  pNext(t_p) = pNext(p);
376  }
377  }
378  if (max_exp != NULL)
379  {
380  max_exp = p_shallow_copy_delete(max_exp,tailRing,new_tailRing,new_tailBin);
381  }
382  else if (set_max && pNext(t_p) != NULL)
383  {
384  max_exp = p_GetMaxExpP(pNext(t_p), new_tailRing);
385  }
386  tailRing = new_tailRing;
387 }
388 
390 {
391  if (p != NULL) return p_FDeg(p, currRing);
392  return tailRing->pFDeg(t_p, tailRing);
393 }
395 {
396  if (p != NULL) return p_Totaldegree(p, currRing);
397  return p_Totaldegree(t_p,tailRing);
398 }
400 {
401  FDeg = this->pFDeg();
402  return FDeg;
403 }
405 {
406  assume(FDeg == this->pFDeg());
407  return FDeg;
408 }
410 {
411  return tailRing->pLDeg(GetLmTailRing(), &length, tailRing);
412 }
414 {
415  FDeg = this->pFDeg();
416  long d = this->pLDeg();
417  ecart = d - FDeg;
418  return d;
419 }
420 
421 //extern void pCleardenom(poly p);
422 // extern void pNorm(poly p);
423 
424 // manipulations
426 {
427  assume(p != NULL);
428  if (TEST_OPT_CONTENTSB)
429  {
430  number n;
431  if (t_p != NULL)
432  {
433  p_Cleardenom_n(t_p, tailRing, n);
434  pSetCoeff0(p, pGetCoeff(t_p));
435  }
436  else
437  {
439  }
440  if (!nIsOne(n))
441  {
443  denom->n=nInvers(n);
444  denom->next=DENOMINATOR_LIST;
445  DENOMINATOR_LIST=denom;
446  }
447  nDelete(&n);
448  }
449  else
450  {
451  if (t_p != NULL)
452  {
454  pSetCoeff0(p, pGetCoeff(t_p));
455  }
456  else
457  {
459  }
460  }
461 }
462 
463 KINLINE void sTObject::pNorm() // pNorm seems to be a _bad_ method name...
464 {
465  assume(p != NULL);
466  if (! is_normalized)
467  {
468  p_Norm(p, currRing);
469  if (t_p != NULL)
470  pSetCoeff0(t_p, pGetCoeff(p));
471  is_normalized = TRUE;
472  }
473 }
474 
475 
476 
477 /***************************************************************
478  *
479  * Operation on LObjects
480  *
481  ***************************************************************/
482 // Initialization
484 {
485  sTObject::Clear();
486  sev = 0;
487 }
488 // Initialization
490 {
492  if (bucket != NULL)
494 }
495 
497 {
498  memset(this, 0, sizeof(sLObject));
499  i_r1 = -1;
500  i_r2 = -1;
501  i_r = -1;
502  Set(r);
503 }
505 {
506  Init(r);
507 }
509 {
510  Init(r);
511  Set(p_in, r);
512 }
513 
514 KINLINE sLObject::sLObject(poly p_in, ring c_r, ring t_r)
515 {
516  Init(t_r);
517  Set(p_in, c_r, t_r);
518 }
519 
521 {
522  if (bucket == NULL)
523  {
524  int l = GetpLength();
525  if (use_bucket && (l > 1))
526  {
527  poly tp = GetLmTailRing();
528  assume(l == ::pLength(tp));
530  kBucketInit(bucket, pNext(tp), l-1);
531  pNext(tp) = NULL;
532  if (p != NULL) pNext(p) = NULL;
533  pLength = 0;
534  }
535  }
536 }
537 
538 KINLINE void sLObject::SetLmTail(poly lm, poly p_tail, int p_Length, int use_bucket, ring _tailRing)
539 {
540 
541  Set(lm, _tailRing);
542  if (use_bucket)
543  {
544  bucket = kBucketCreate(_tailRing);
545  kBucketInit(bucket, p_tail, p_Length);
546  pNext(lm) = NULL;
547  pLength = 0;
548  }
549  else
550  {
551  pNext(lm) = p_tail;
552  pLength = p_Length + 1;
553  }
554 }
555 
557 {
558  if (bucket != NULL)
559  {
561  }
562  else
563  {
564  poly _p = (t_p != NULL ? t_p : p);
565  assume(_p != NULL);
566  pNext(_p) = p_Mult_nn(pNext(_p), n, tailRing);
567  }
568 }
569 
571  poly spNoether)
572 {
573  if (bucket != NULL)
574  {
575  kBucket_Minus_m_Mult_p(bucket, m, q, &lq, spNoether);
576  }
577  else
578  {
579  if (lq<=0) lq= ::pLength(q);
580  poly _p = (t_p != NULL ? t_p : p);
581  assume(_p != NULL);
582 
583  int lp=pLength-1;
584  pNext(_p) = p_Minus_mm_Mult_qq( pNext(_p), m, q, lp, lq,
585  spNoether, tailRing );
586  pLength=lp+1;
587 // tailRing->p_Procs->p_Minus_mm_Mult_qq(pNext(_p), m, q, shorter,spNoether, tailRing, last);
588 // pLength += lq - shorter;
589  }
590 }
591 
593 {
595  if (bucket != NULL)
596  {
598  if (_p == NULL)
599  {
601  p = t_p = NULL;
602  return;
603  }
604  Set(_p, tailRing);
605  }
606  else
607  {
608  pLength--;
609  }
610 }
611 
613 {
614  poly ret = GetLmTailRing();
615  poly pn;
616 
617  assume(p != NULL || t_p != NULL);
618 
619  if (bucket != NULL)
620  {
621  pn = kBucketExtractLm(bucket);
622  if (pn == NULL)
624  }
625  else
626  {
627  pn = pNext(ret);
628  }
629  pLength--;
630  pNext(ret) = NULL;
631  if (p != NULL && t_p != NULL)
632  p_LmFree(p, currRing);
633 
634  Set(pn, tailRing);
635  return ret;
636 }
637 
639 {
640  //kTest_L(this);
641  int i = -1;
642 
643  if (bucket != NULL)
645 
646  if (p == NULL)
648 
649  if (i >= 0) pNext(p) = bucket->buckets[i];
650  return p;
651 }
652 
654 {
655  //kTest_L(this);
656  poly tp = GetLmTailRing();
657  assume(tp != NULL);
658 
659  if (bucket != NULL)
660  {
661  kBucketClear(bucket, &pNext(tp), &pLength);
663  pLength++;
664  }
665  return tp;
666 }
667 
668 
670 {
671  //kTest_L(this);
672  if (p == NULL)
673  {
675  (lmBin!=NULL?lmBin:currRing->PolyBin));
676  FDeg = pFDeg();
677  }
678  else if (lmBin != NULL && lmBin != currRing->PolyBin)
679  {
681  FDeg = pFDeg();
682  }
683 
684  if (bucket != NULL)
685  {
688  pLength++;
689  if (t_p != NULL) pNext(t_p) = pNext(p);
690  }
691  //kTest_L(this);
692  return p;
693 }
694 
695 KINLINE void
696 sLObject::ShallowCopyDelete(ring new_tailRing,
698 {
699  if (bucket != NULL)
700  kBucketShallowCopyDelete(bucket, new_tailRing, new_tailRing->PolyBin,
701  p_shallow_copy_delete);
702  sTObject::ShallowCopyDelete(new_tailRing,
703  new_tailRing->PolyBin,p_shallow_copy_delete,
704  FALSE);
705 }
706 
708 {
709  if (t_p != NULL)
710  {
711  sev = p_GetShortExpVector(t_p, tailRing);
712  }
713  else
714  {
716  }
717 }
718 
720 {
721  if (bucket != NULL)
722  {
724  kBucket_pt new_bucket = kBucketCreate(tailRing);
725  kBucketInit(new_bucket,
726  p_Copy(bucket->buckets[i], tailRing),
727  bucket->buckets_length[i]);
728  bucket = new_bucket;
729  if (t_p != NULL) pNext(t_p) = NULL;
730  if (p != NULL) pNext(p) = NULL;
731  }
732  TObject::Copy();
733 }
734 
736 {
737  poly tp = GetLmTailRing();
738  assume(tp != NULL);
739  if (bucket != NULL)
740  {
742  pNext(tp) = bucket->buckets[i];
743  long ldeg = tailRing->pLDeg(tp, &length, tailRing);
744  pNext(tp) = NULL;
745  return ldeg;
746  }
747  else
748  return tailRing->pLDeg(tp, &length, tailRing);
749 }
751 {
752  if (! deg_last || bucket != NULL) return sLObject::pLDeg();
753 
754  long ldeg;
755  ldeg = tailRing->pLDeg(GetLmTailRing(), &length, tailRing);
756 #ifdef HAVE_ASSUME
757  if ( pLength == 0)
758  p_Last(GetLmTailRing(), pLength, tailRing);
759  assume ( pLength == length || rIsSyzIndexRing(currRing));
760 #else
761  pLength=length;
762 #endif
763  return ldeg;
764 }
765 
767 {
768  FDeg = this->pFDeg();
769  long d = this->pLDeg();
770  ecart = d - FDeg;
771  return d;
772 }
774 {
775  FDeg = this->pFDeg();
776  long d = this->pLDeg(use_last);
777  ecart = d - FDeg;
778  return d;
779 }
781 {
782  if (bucket == NULL)
783  return sTObject::GetpLength();
785  return bucket->buckets_length[i] + 1;
786 }
788 {
789  if (length_pLength)
790  {
791  length = this->GetpLength();
792  }
793  else
794  this->pLDeg();
795  return length;
796 }
798 {
799  poly tp = GetLmTailRing();
800  assume(tp != NULL);
801  if (bucket != NULL)
802  {
804  pNext(tp) = bucket->buckets[i];
805  long m = p_MinComp(tp, tailRing);
806  pNext(tp) = NULL;
807  return m;
808  }
809  else
810  return p_MinComp(tp, tailRing);
811 }
813 {
814  poly pp;
815  ring r;
816  GetLm(pp, r);
817  assume(pp != NULL);
818  return p_GetComp(pp, r);
819 }
820 
822 {
823  memset(this, 0, sizeof(*this));
824  memcpy(this, &t, sizeof(sTObject));
825  return *this;
826 }
827 
829 {
830  if (p1 == NULL) return NULL;
831  if (i_r1 == -1) i_r1 = kFindInT(p1, s->T, s->tl);
832  assume(i_r1 >= 0 && i_r1 <= s->tl);
833  TObject* T = s->R[i_r1];
834  assume(T->p == p1);
835  return T;
836 }
837 
839 {
840  if (p1 == NULL) return NULL;
841  assume(p2 != NULL);
842  if (i_r2 == -1) i_r2 = kFindInT(p2, strat->T, strat->tl);
843  assume(i_r2 >= 0 && i_r2 <= strat->tl);
844  TObject* T = strat->R[i_r2];
845  assume(T->p == p2);
846  return T;
847 }
848 
850  TObject* &T_1, TObject* &T_2)
851 {
852  if (p1 == NULL)
853  {
854  T_1 = NULL;
855  T_2 = NULL;
856  return;
857  }
858  assume(p1 != NULL && p2 != NULL);
859  if (i_r1 == -1) i_r1 = kFindInT(p1, strat->T, strat->tl);
860  if (i_r2 == -1) i_r2 = kFindInT(p2, strat->T, strat->tl);
861  assume(i_r1 >= 0 && i_r1 <= strat->tl);
862  assume(i_r2 >= 0 && i_r2 <= strat->tl);
863  T_1 = strat->R[i_r1];
864  T_2 = strat->R[i_r2];
865  assume(T_1->p == p1);
866  assume(T_2->p == p2);
867  return;
868 }
869 
870 /***************************************************************
871  *
872  * Conversion of polys
873  *
874  ***************************************************************/
875 
877 {
878 
879  poly np = p_LmInit(p, currRing, tailRing, tailBin);
880  pNext(np) = pNext(p);
881  pSetCoeff0(np, pGetCoeff(p));
882  return np;
883 }
884 
886 {
887  poly np = p_LmInit(p, tailRing, currRing, lmBin);
888  pNext(np) = pNext(p);
889  pSetCoeff0(np, pGetCoeff(p));
890  return np;
891 }
892 
893 // this should be made more efficient
895 {
896  poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
897  p_LmFree(p, currRing);
898  return np;
899 }
900 
902 {
903  poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
904  p_LmFree(p, tailRing);
905  return np;
906 }
907 
909 {
910  return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
911 }
912 
914 {
915  return k_LmInit_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
916 }
917 
919 {
920  return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
921 }
922 
924 {
925  return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
926 }
927 
928 /***************************************************************
929  *
930  * Lcm business
931  *
932  ***************************************************************/
933 // get m1 = LCM(LM(p1), LM(p2))/LM(p1)
934 // m2 = LCM(LM(p1), LM(p2))/LM(p2)
935 KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r,
936  poly &m1, poly &m2, const ring m_r)
937 {
938  p_LmCheckPolyRing(p1, p_r);
939  p_LmCheckPolyRing(p2, p_r);
940 
941  int i;
942  long x;
943  m1 = p_Init(m_r);
944  m2 = p_Init(m_r);
945 
946  for (i = p_r->N; i; i--)
947  {
948  x = p_GetExpDiff(p1, p2, i, p_r);
949  if (x > 0)
950  {
951  if (x > (long) m_r->bitmask) goto false_return;
952  p_SetExp(m2,i,x, m_r);
953  p_SetExp(m1,i,0, m_r);
954  }
955  else
956  {
957  if (-x > (long) m_r->bitmask) goto false_return;
958  p_SetExp(m1,i,-x, m_r);
959  p_SetExp(m2,i,0, m_r);
960  }
961  }
962 
963  p_Setm(m1, m_r);
964  p_Setm(m2, m_r);
965  return TRUE;
966 
967  false_return:
968  p_LmFree(m1, m_r);
969  p_LmFree(m2, m_r);
970  m1 = m2 = NULL;
971  return FALSE;
972 }
973 
974 #ifdef HAVE_RINGS
975 // get m1 = LCM(LM(p1), LM(p2))/LM(p1)
976 // m2 = LCM(LM(p1), LM(p2))/LM(p2) in tailRing
977 // lcm = LCM(LM(p1), LM(p2)) in leadRing
978 KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing,
979  poly &m1, poly &m2, poly &lcm, const ring tailRing)
980 {
981  p_LmCheckPolyRing(p1, leadRing);
982  p_LmCheckPolyRing(p2, leadRing);
983 
984  int i;
985  int x;
986  int e1;
987  int e2;
988  int s;
989  m1 = p_Init(tailRing);
990  m2 = p_Init(tailRing);
991  lcm = p_Init(leadRing);
992 
993  for (i = leadRing->N; i>=0; i--)
994  {
995  e1 = p_GetExp(p1,i,leadRing);
996  e2 = p_GetExp(p2,i,leadRing);
997  x = e1 - e2;
998  if (x > 0)
999  {
1000  p_SetExp(m2,i,x, tailRing);
1001  //p_SetExp(m1,i,0, tailRing); // done by p_Init
1002  s = e1;
1003  }
1004  else if (x<0)
1005  {
1006  p_SetExp(m1,i,-x, tailRing);
1007  //p_SetExp(m2,i,0, tailRing); // done by p_Init
1008  s = e2;
1009  }
1010  else
1011  s = e1; // e1==e2
1012  p_SetExp(lcm,i,s, leadRing);
1013  }
1014 
1015  p_Setm(m1, tailRing);
1016  p_Setm(m2, tailRing);
1017  p_Setm(lcm, leadRing);
1018 }
1019 #endif
1020 
1021 /***************************************************************
1022  *
1023  * Misc things
1024  *
1025  ***************************************************************/
1027 {
1028  BOOLEAN ret;
1029  number coef;
1030 
1031  assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1032  Red->HeadNormalize();
1033  ret = ksReducePoly(Red, PW, NULL, &coef);
1034 
1035  if (!ret)
1036  {
1037  if (! n_IsOne(coef, currRing->cf))
1038  {
1039  PR->Mult_nn(coef);
1040  // HANNES: mark for Normalize
1041  }
1042  n_Delete(&coef, currRing->cf);
1043  }
1044  return ret;
1045 }
1046 
1047 /***************************************************************
1048  *
1049  * Routines for backwards-Compatibility
1050  *
1051  *
1052  ***************************************************************/
1054 {
1055  LObject L(p2);
1056  TObject T(p1);
1057 
1058  ksReducePoly(&L, &T, spNoether);
1059 
1060  return L.GetLmCurrRing();
1061 }
1062 
1064 {
1065  LObject L(p_Copy(p2, currRing));
1066  TObject T(p1);
1067 
1068  ksReducePoly(&L, &T, spNoether);
1069 
1070  return L.GetLmCurrRing();
1071 }
1072 
1074 {
1075  LObject L(r);
1076  L.p1 = p1;
1077  L.p2 = p2;
1078 
1079  ksCreateSpoly(&L, spNoether);
1080  return L.GetLmCurrRing();
1081 }
1082 
1083 void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r)
1084 {
1085  LObject L(q, currRing, r);
1086  TObject T(p1, currRing, r);
1087 
1088  ksReducePolyTail(&L, &T, q2, spNoether);
1089 }
1090 
1092 {
1093  LObject L(p);
1094  return redtailBba(&L, pos, strat,FALSE, normalize);
1095 }
1096 
1098 {
1099  LObject L(p, currRing, strat->tailRing); // ? L(p); ??
1100  return redtailBbaBound(&L, pos, strat,bound, FALSE, normalize);
1101 }
1102 
1103 #ifdef HAVE_RINGS
1105 {
1106  LObject L(p, currRing, strat->tailRing);
1107  return redtailBba_Z(&L, pos, strat);
1108 }
1109 #endif
1110 
1112 {
1113  LObject L;
1114  L = *T;
1115  poly p = redtailBba(&L, pos, strat, FALSE);
1116  *T = L;
1117  //kTest_T(T);
1118  assume( p == T->p);
1119  return p;
1120 }
1121 
1122 KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
1123  kStrategy strat)
1124 {
1125  assume(p_sev == pGetShortExpVector(p));
1126  if (strat->noClearS) return;
1127  #ifdef HAVE_RINGS
1129  {
1130  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1131  return;
1132  if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing->cf))
1133  return;
1134  }
1135  else
1136  #endif
1137  {
1138  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1139  }
1140  deleteInS((*at),strat);
1141  (*at)--;
1142  (*k)--;
1143 }
1144 
1145 // dummy function for function pointer strat->rewCrit being usable in all
1146 // possible choices for criteria
1147 KINLINE BOOLEAN arriRewDummy(poly /*sig*/, unsigned long /*not_sevSig*/, poly /*lm*/, kStrategy /*strat*/, int /*start=0*/)
1148 {
1149  return FALSE;
1150 }
1151 
1152 #endif // defined(KINLINE) || defined(KUTIL_CC)
1153 #endif // KINLINE_H
KINLINE void Init(ring tailRing=currRing)
Definition: kInline.h:496
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:495
KINLINE int GetpLength()
Definition: kInline.h:780
KINLINE poly GetP(omBin lmBin=NULL)
Definition: kInline.h:669
denominator_list_s * denominator_list
Definition: kutil.h:65
static number Copy(number a, const coeffs r)
Definition: flintcf_Q.cc:229
KINLINE TObject ** initR()
Definition: kInline.h:92
const CanonicalForm int s
Definition: facAbsFact.cc:55
CFArray copy(const CFList &list)
write elements of list into an array
KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
Definition: kInline.h:935
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition: syz3.cc:1027
void kBucketShallowCopyDelete(kBucket_pt bucket, ring new_tailRing, omBin new_tailBin, pShallowCopyDeleteProc p_shallow_copy_delete)
For changing the ring of the Bpoly to new_tailBin.
Definition: kbuckets.cc:509
KINLINE void SetShortExpVector()
Definition: kInline.h:707
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:711
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:467
omBin_t * omBin
Definition: omStructs.h:12
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:720
KINLINE unsigned long * initsevT()
Definition: kInline.h:97
KINLINE poly redtailBba_Z(poly p, int pos, kStrategy strat)
Definition: kInline.h:1104
KINLINE void Set(ring r=currRing)
Definition: kInline.h:103
class sLObject LObject
Definition: kutil.h:60
#define nNormalize(n)
Definition: numbers.h:30
BOOLEAN length_pLength
Definition: kutil.h:384
TObject * TSet
Definition: kutil.h:61
KINLINE TSet initT()
Definition: kInline.h:81
KINLINE sLObject & operator=(const sTObject &)
Definition: kInline.h:821
KINLINE poly Next()
Definition: kInline.h:280
#define FALSE
Definition: auxiliary.h:94
Compatiblity layer for legacy polynomial operations (over currRing)
int * S_2_R
Definition: kutil.h:338
return P p
Definition: myNF.cc:203
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1026
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:711
#define p_GetComp(p, r)
Definition: monomials.h:72
KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition: kInline.h:885
#define TEST_OPT_CONTENTSB
Definition: options.h:121
int kFindInT(poly p, TSet T, int tlength)
returns index of p in TSet, or -1 if not found
Definition: kutil.cc:717
KINLINE sLObject(ring tailRing=currRing)
Definition: kInline.h:504
KINLINE void Init(ring r=currRing)
Definition: kInline.h:107
poly kNoether
Definition: kutil.h:324
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
Definition: kInline.h:1073
int tl
Definition: kutil.h:346
KINLINE void HeadNormalize()
Definition: kInline.h:334
static poly p_LmShallowCopyDelete(poly p, const ring r)
Definition: p_polys.h:1316
char noClearS
Definition: kutil.h:399
#define TRUE
Definition: auxiliary.h:98
#define nIsOne(n)
Definition: numbers.h:25
denominator_list DENOMINATOR_LIST
Definition: kutil.cc:89
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:45
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1430
void deleteInS(int i, kStrategy strat)
Definition: kutil.cc:1058
pShallowCopyDeleteProc p_shallow_copy_delete
Definition: kutil.h:334
int k
Definition: cfEzgcd.cc:93
KINLINE void pNorm()
Definition: kInline.h:463
void p_Norm(poly p1, const ring r)
Definition: p_polys.cc:3619
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
void kBucket_Mult_n(kBucket_pt bucket, number n)
Multiply Bucket by number ,i.e. Bpoly == n*Bpoly.
Definition: kbuckets.cc:572
KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether)
Definition: kInline.h:570
#define omAlloc(size)
Definition: omAllocDecl.h:210
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition: kInline.h:1091
#define KINLINE
Definition: kutil.h:51
static void p_LmFree(poly p, ring)
Definition: p_polys.h:678
poly kBucketExtractLm(kBucket_pt bucket)
Definition: kbuckets.cc:485
KINLINE void PrepareRed(BOOLEAN use_bucket)
Definition: kInline.h:520
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly pp
Definition: myNF.cc:296
KINLINE void Tail_Mult_nn(number n)
Definition: kInline.h:556
KINLINE void LmDeleteAndIter()
Definition: kInline.h:288
KINLINE void Copy()
Definition: kInline.h:719
KINLINE void SetLmTail(poly lm, poly new_p, int length, int use_bucket, ring r)
Definition: kInline.h:538
p_Length
Definition: p_Procs_Impl.h:122
KINLINE sTObject(ring tailRing=currRing)
Definition: kInline.h:113
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition: p_polys.cc:2875
KINLINE int GetpLength()
Definition: kInline.h:268
KINLINE poly redtailBbaBound(poly p, int pos, kStrategy strat, int bound, BOOLEAN normalize)
Definition: kInline.h:1097
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:630
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
KINLINE void Copy()
Definition: kInline.h:200
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:812
const ring r
Definition: syzextra.cc:208
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:876
KINLINE TObject * S_2_T(int i)
Definition: kInline.h:35
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:200
KINLINE long pLDeg()
Definition: kInline.h:735
#define setmaxT
Definition: kutil.h:32
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:464
KINLINE void Clear()
Definition: kInline.h:189
KINLINE void LmDeleteAndIter()
Definition: kInline.h:592
#define assume(x)
Definition: mod2.h:394
KINLINE BOOLEAN IsNull() const
Definition: kInline.h:263
KINLINE TObject * T_2(const skStrategy *strat)
Definition: kInline.h:838
KINLINE poly CanonicalizeP()
Definition: kInline.h:638
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl.cc )
Definition: polys.h:152
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether &#39;a&#39; is divisible &#39;b&#39;; for r encoding a field: TRUE iff &#39;b&#39; does not represent zero in Z:...
Definition: coeffs.h:787
void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r)
Definition: kInline.h:1083
#define pLmShortDivisibleBy(a, sev_a, b, not_sev_b)
Divisibility tests based on Short Exponent vectors sev_a == pGetShortExpVector(a) not_sev_b == ~ pGet...
Definition: polys.h:146
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:162
pNormalize(P.p)
KINLINE void ShallowCopyDelete(ring new_tailRing, omBin new_tailBin, pShallowCopyDeleteProc p_shallow_copy_delete, BOOLEAN set_max=TRUE)
Definition: kInline.h:348
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
Definition: kspoly.cc:774
P bucket
Definition: myNF.cc:79
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:375
KINLINE void SetLmCurrRing()
Definition: kInline.h:274
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:895
KINLINE void Normalize()
Definition: kInline.h:321
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:308
TObject ** R
Definition: kutil.h:336
static unsigned pLength(poly a)
Definition: p_polys.h:189
void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, poly spNoether)
Bpoly == Bpoly - m*p; where m is a monom Does not destroy p and m assume (*l <= 0 || pLength(p) == *l...
Definition: kbuckets.cc:690
KINLINE long Comp()
Definition: kInline.h:812
polyset S
Definition: kutil.h:300
#define nDelete(n)
Definition: numbers.h:16
#define p_Test(p, r)
Definition: p_polys.h:160
KINLINE void pCleardenom()
Definition: kInline.h:425
KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether)
Definition: kInline.h:1063
int int kStrategy strat
Definition: myNF.cc:68
#define nInvers(a)
Definition: numbers.h:33
Definition: kutil.h:70
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:894
static number Init(long i, const coeffs r)
Definition: flintcf_Q.cc:145
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4627
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
poly(* pShallowCopyDeleteProc)(poly s_p, ring source_r, ring dest_r, omBin dest_bin)
returns a poly from dest_r which is a ShallowCopy of s_p from source_r assumes that source_r->N == de...
Definition: ring.h:52
KINLINE poly GetLmCurrRing()
Definition: kInline.h:217
KINLINE long pTotalDeg() const
Definition: kInline.h:394
LSet L
Definition: kutil.h:321
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
KINLINE void Mult_nn(number n)
Definition: kInline.h:309
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:119
ring tailRing
Definition: kutil.h:339
poly p_Last(const poly p, int &l, const ring r)
Definition: p_polys.cc:4468
KINLINE poly GetLmTailRing()
Definition: kInline.h:224
KINLINE long pLDeg()
Definition: kInline.h:409
KINLINE poly GetTP()
Definition: kInline.h:653
denominator_list next
Definition: kutil.h:67
poly t_kNoether
Definition: kutil.h:327
omBin tailBin
Definition: kutil.h:341
KINLINE int SetLength(BOOLEAN lengt_pLength=FALSE)
Definition: kInline.h:787
unsigned long * sevS
Definition: kutil.h:316
KINLINE long SetDegStuffReturnLDeg()
Definition: kInline.h:413
Variable x
Definition: cfModGcd.cc:4023
#define pNext(p)
Definition: monomials.h:43
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1258
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
KINLINE void Delete()
Definition: kInline.h:489
#define pSetCoeff0(p, n)
Definition: monomials.h:67
KINLINE void clearS(poly p, unsigned long p_sev, int *at, int *k, kStrategy strat)
Definition: kInline.h:1122
KINLINE TObject * s_2_t(int i)
Definition: kInline.h:44
static poly p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, int lq, const poly spNoether, const ring r)
Definition: p_polys.h:976
KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing, poly &m1, poly &m2, poly &lcm, const ring tailRing)
Definition: kInline.h:978
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
Definition: kInline.h:1053
int sl
Definition: kutil.h:344
TSet T
Definition: kutil.h:320
omBin lmBin
Definition: kutil.h:340
KINLINE poly LmExtractAndIter()
Definition: kInline.h:612
END_NAMESPACE const void * p2
Definition: syzextra.cc:202
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
KINLINE poly GetLm(ring r)
Definition: kInline.h:237
KINLINE void Clear()
Definition: kInline.h:483
polyrec * poly
Definition: hilb.h:10
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition: kbuckets.cc:193
int BOOLEAN
Definition: auxiliary.h:85
int kBucketCanonicalize(kBucket_pt bucket)
KINLINE long SetpFDeg()
Definition: kInline.h:399
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1243
KINLINE poly kNoetherTail()
Definition: kInline.h:63
KINLINE BOOLEAN arriRewDummy(poly, unsigned long, poly, kStrategy, int)
Definition: kInline.h:1147
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition: kInline.h:901
void kBucketDeleteAndDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:207
KINLINE void T_1_2(const skStrategy *strat, TObject *&T_1, TObject *&T_2)
Definition: kInline.h:849
void p_ProjectiveUnique(poly ph, const ring r)
Definition: p_polys.cc:3064
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
KINLINE long SetDegStuffReturnLDeg()
Definition: kInline.h:766
class sTObject TObject
Definition: kutil.h:59
KINLINE void Delete()
Definition: kInline.h:175
KINLINE long MinComp()
Definition: kInline.h:797
poly p_GetMaxExpP(poly p, const ring r)
return monomial r such that GetExp(r,i) is maximum of all monomials in p; coeff == 0...
Definition: p_polys.cc:1137
KINLINE long pFDeg() const
Definition: kInline.h:389
KINLINE TObject * T_1(const skStrategy *strat)
Definition: kInline.h:828
KINLINE void ShallowCopyDelete(ring new_tailRing, pShallowCopyDeleteProc p_shallow_copy_delete)
Definition: kInline.h:696
KINLINE long GetpFDeg() const
Definition: kInline.h:404