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 != NULL)
379  {
380  if (new_tailRing == currRing)
381  {
383  max = NULL;
384  }
385  else
386  max = p_shallow_copy_delete(max,tailRing,new_tailRing,new_tailBin);
387  }
388  else if (set_max && new_tailRing != currRing && pNext(t_p) != NULL)
389  {
390  max = p_GetMaxExpP(pNext(t_p), new_tailRing);
391  }
392  tailRing = new_tailRing;
393 }
394 
396 {
397  if (p != NULL) return p_FDeg(p, currRing);
398  return tailRing->pFDeg(t_p, tailRing);
399 }
401 {
402  if (p != NULL) return p_Totaldegree(p, currRing);
403  return p_Totaldegree(t_p,tailRing);
404 }
406 {
407  FDeg = this->pFDeg();
408  return FDeg;
409 }
411 {
412  assume(FDeg == this->pFDeg());
413  return FDeg;
414 }
416 {
417  return tailRing->pLDeg(GetLmTailRing(), &length, tailRing);
418 }
420 {
421  FDeg = this->pFDeg();
422  long d = this->pLDeg();
423  ecart = d - FDeg;
424  return d;
425 }
426 
427 //extern void pCleardenom(poly p);
428 // extern void pNorm(poly p);
429 
430 // manipulations
432 {
433  assume(p != NULL);
434  if (TEST_OPT_CONTENTSB)
435  {
436  number n;
437  if (t_p != NULL)
438  {
439  p_Cleardenom_n(t_p, tailRing, n);
440  pSetCoeff0(p, pGetCoeff(t_p));
441  }
442  else
443  {
445  }
446  if (!nIsOne(n))
447  {
449  denom->n=nInvers(n);
450  denom->next=DENOMINATOR_LIST;
451  DENOMINATOR_LIST=denom;
452  }
453  nDelete(&n);
454  }
455  else
456  {
457  if (t_p != NULL)
458  {
460  pSetCoeff0(p, pGetCoeff(t_p));
461  }
462  else
463  {
465  }
466  }
467 }
468 
469 KINLINE void sTObject::pNorm() // pNorm seems to be a _bad_ method name...
470 {
471  assume(p != NULL);
472  if (! is_normalized)
473  {
474  p_Norm(p, currRing);
475  if (t_p != NULL)
476  pSetCoeff0(t_p, pGetCoeff(p));
477  is_normalized = TRUE;
478  }
479 }
480 
481 
482 
483 /***************************************************************
484  *
485  * Operation on LObjects
486  *
487  ***************************************************************/
488 // Initialization
490 {
491  sTObject::Clear();
492  sev = 0;
493 }
494 // Initialization
496 {
498  if (bucket != NULL)
500 }
501 
503 {
504  memset(this, 0, sizeof(sLObject));
505  i_r1 = -1;
506  i_r2 = -1;
507  i_r = -1;
508  Set(r);
509 }
511 {
512  Init(r);
513 }
515 {
516  Init(r);
517  Set(p_in, r);
518 }
519 
520 KINLINE sLObject::sLObject(poly p_in, ring c_r, ring t_r)
521 {
522  Init(t_r);
523  Set(p_in, c_r, t_r);
524 }
525 
527 {
528  if (bucket == NULL)
529  {
530  int l = GetpLength();
531  if (use_bucket && (l > 1))
532  {
533  poly tp = GetLmTailRing();
534  assume(l == ::pLength(tp));
536  kBucketInit(bucket, pNext(tp), l-1);
537  pNext(tp) = NULL;
538  if (p != NULL) pNext(p) = NULL;
539  pLength = 0;
540  }
541  }
542 }
543 
544 KINLINE void sLObject::SetLmTail(poly lm, poly p_tail, int p_Length, int use_bucket, ring _tailRing)
545 {
546 
547  Set(lm, _tailRing);
548  if (use_bucket)
549  {
550  bucket = kBucketCreate(_tailRing);
551  kBucketInit(bucket, p_tail, p_Length);
552  pNext(lm) = NULL;
553  pLength = 0;
554  }
555  else
556  {
557  pNext(lm) = p_tail;
558  pLength = p_Length + 1;
559  }
560 }
561 
563 {
564  if (bucket != NULL)
565  {
567  }
568  else
569  {
570  poly _p = (t_p != NULL ? t_p : p);
571  assume(_p != NULL);
572  pNext(_p) = p_Mult_nn(pNext(_p), n, tailRing);
573  }
574 }
575 
577  poly spNoether)
578 {
579  if (bucket != NULL)
580  {
581  kBucket_Minus_m_Mult_p(bucket, m, q, &lq, spNoether);
582  }
583  else
584  {
585  if (lq<=0) lq= ::pLength(q);
586  poly _p = (t_p != NULL ? t_p : p);
587  assume(_p != NULL);
588 
589  int lp=pLength-1;
590  pNext(_p) = p_Minus_mm_Mult_qq( pNext(_p), m, q, lp, lq,
591  spNoether, tailRing );
592  pLength=lp+1;
593 // tailRing->p_Procs->p_Minus_mm_Mult_qq(pNext(_p), m, q, shorter,spNoether, tailRing, last);
594 // pLength += lq - shorter;
595  }
596 }
597 
599 {
601  if (bucket != NULL)
602  {
604  if (_p == NULL)
605  {
607  p = t_p = NULL;
608  return;
609  }
610  Set(_p, tailRing);
611  }
612  else
613  {
614  pLength--;
615  }
616 }
617 
619 {
620  poly ret = GetLmTailRing();
621  poly pn;
622 
623  assume(p != NULL || t_p != NULL);
624 
625  if (bucket != NULL)
626  {
627  pn = kBucketExtractLm(bucket);
628  if (pn == NULL)
630  }
631  else
632  {
633  pn = pNext(ret);
634  }
635  pLength--;
636  pNext(ret) = NULL;
637  if (p != NULL && t_p != NULL)
638  p_LmFree(p, currRing);
639 
640  Set(pn, tailRing);
641  return ret;
642 }
643 
645 {
646  //kTest_L(this);
647  int i = -1;
648 
649  if (bucket != NULL)
651 
652  if (p == NULL)
654 
655  if (i >= 0) pNext(p) = bucket->buckets[i];
656  return p;
657 }
658 
660 {
661  //kTest_L(this);
662  poly tp = GetLmTailRing();
663  assume(tp != NULL);
664 
665  if (bucket != NULL)
666  {
667  kBucketClear(bucket, &pNext(tp), &pLength);
669  pLength++;
670  }
671  return tp;
672 }
673 
674 
676 {
677  //kTest_L(this);
678  if (p == NULL)
679  {
681  (lmBin!=NULL?lmBin:currRing->PolyBin));
682  FDeg = pFDeg();
683  }
684  else if (lmBin != NULL && lmBin != currRing->PolyBin)
685  {
687  FDeg = pFDeg();
688  }
689 
690  if (bucket != NULL)
691  {
694  pLength++;
695  if (t_p != NULL) pNext(t_p) = pNext(p);
696  }
697  //kTest_L(this);
698  return p;
699 }
700 
701 KINLINE void
702 sLObject::ShallowCopyDelete(ring new_tailRing,
704 {
705  if (bucket != NULL)
706  kBucketShallowCopyDelete(bucket, new_tailRing, new_tailRing->PolyBin,
707  p_shallow_copy_delete);
708  sTObject::ShallowCopyDelete(new_tailRing,
709  new_tailRing->PolyBin,p_shallow_copy_delete,
710  FALSE);
711 }
712 
714 {
715  if (t_p != NULL)
716  {
717  sev = p_GetShortExpVector(t_p, tailRing);
718  }
719  else
720  {
722  }
723 }
724 
726 {
727  if (bucket != NULL)
728  {
730  kBucket_pt new_bucket = kBucketCreate(tailRing);
731  kBucketInit(new_bucket,
732  p_Copy(bucket->buckets[i], tailRing),
733  bucket->buckets_length[i]);
734  bucket = new_bucket;
735  if (t_p != NULL) pNext(t_p) = NULL;
736  if (p != NULL) pNext(p) = NULL;
737  }
738  TObject::Copy();
739 }
740 
742 {
743  if (bucket != NULL)
744  {
746  poly bp = p_Copy(bucket->buckets[i], tailRing);
747  pLength = bucket->buckets_length[i] + 1;
748  if (bp != NULL)
749  {
750  assume(t_p != NULL || p != NULL);
751  if (t_p != NULL) pNext(t_p) = bp;
752  else pNext(p) = bp;
753  }
754  bucket = NULL;
755  }
756  return sLObject::GetP();
757 }
758 
759 
761 {
762  poly tp = GetLmTailRing();
763  assume(tp != NULL);
764  if (bucket != NULL)
765  {
767  pNext(tp) = bucket->buckets[i];
768  long ldeg = tailRing->pLDeg(tp, &length, tailRing);
769  pNext(tp) = NULL;
770  return ldeg;
771  }
772  else
773  return tailRing->pLDeg(tp, &length, tailRing);
774 }
776 {
777  if (! deg_last || bucket != NULL) return sLObject::pLDeg();
778 
779  long ldeg;
780  ldeg = tailRing->pLDeg(GetLmTailRing(), &length, tailRing);
781 #ifdef HAVE_ASSUME
782  if ( pLength == 0)
783  p_Last(GetLmTailRing(), pLength, tailRing);
784  assume ( pLength == length || rIsSyzIndexRing(currRing));
785 #else
786  pLength=length;
787 #endif
788  return ldeg;
789 }
790 
792 {
793  FDeg = this->pFDeg();
794  long d = this->pLDeg();
795  ecart = d - FDeg;
796  return d;
797 }
799 {
800  FDeg = this->pFDeg();
801  long d = this->pLDeg(use_last);
802  ecart = d - FDeg;
803  return d;
804 }
806 {
807  if (bucket == NULL)
808  return sTObject::GetpLength();
810  return bucket->buckets_length[i] + 1;
811 }
813 {
814  if (length_pLength)
815  {
816  length = this->GetpLength();
817  }
818  else
819  this->pLDeg();
820  return length;
821 }
823 {
824  poly tp = GetLmTailRing();
825  assume(tp != NULL);
826  if (bucket != NULL)
827  {
829  pNext(tp) = bucket->buckets[i];
830  long m = p_MinComp(tp, tailRing);
831  pNext(tp) = NULL;
832  return m;
833  }
834  else
835  return p_MinComp(tp, tailRing);
836 }
838 {
839  poly pp;
840  ring r;
841  GetLm(pp, r);
842  assume(pp != NULL);
843  return p_GetComp(pp, r);
844 }
845 
847 {
848  memset(this, 0, sizeof(*this));
849  memcpy(this, &t, sizeof(sTObject));
850  return *this;
851 }
852 
854 {
855  if (p1 == NULL) return NULL;
856  if (i_r1 == -1) i_r1 = kFindInT(p1, s->T, s->tl);
857  assume(i_r1 >= 0 && i_r1 <= s->tl);
858  TObject* T = s->R[i_r1];
859  assume(T->p == p1);
860  return T;
861 }
862 
864 {
865  if (p1 == NULL) return NULL;
866  assume(p2 != NULL);
867  if (i_r2 == -1) i_r2 = kFindInT(p2, strat->T, strat->tl);
868  assume(i_r2 >= 0 && i_r2 <= strat->tl);
869  TObject* T = strat->R[i_r2];
870  assume(T->p == p2);
871  return T;
872 }
873 
875  TObject* &T_1, TObject* &T_2)
876 {
877  if (p1 == NULL)
878  {
879  T_1 = NULL;
880  T_2 = NULL;
881  return;
882  }
883  assume(p1 != NULL && p2 != NULL);
884  if (i_r1 == -1) i_r1 = kFindInT(p1, strat->T, strat->tl);
885  if (i_r2 == -1) i_r2 = kFindInT(p2, strat->T, strat->tl);
886  assume(i_r1 >= 0 && i_r1 <= strat->tl);
887  assume(i_r2 >= 0 && i_r2 <= strat->tl);
888  T_1 = strat->R[i_r1];
889  T_2 = strat->R[i_r2];
890  assume(T_1->p == p1);
891  assume(T_2->p == p2);
892  return;
893 }
894 
895 /***************************************************************
896  *
897  * Conversion of polys
898  *
899  ***************************************************************/
900 
902 {
903 
904  poly np = p_LmInit(p, currRing, tailRing, tailBin);
905  pNext(np) = pNext(p);
906  pSetCoeff0(np, pGetCoeff(p));
907  return np;
908 }
909 
911 {
912  poly np = p_LmInit(p, tailRing, currRing, lmBin);
913  pNext(np) = pNext(p);
914  pSetCoeff0(np, pGetCoeff(p));
915  return np;
916 }
917 
918 // this should be made more efficient
920 {
921  poly np = k_LmInit_currRing_2_tailRing(p, tailRing, tailBin);
922  p_LmFree(p, currRing);
923  return np;
924 }
925 
927 {
928  poly np = k_LmInit_tailRing_2_currRing(p, tailRing, lmBin);
929  p_LmFree(p, tailRing);
930  return np;
931 }
932 
934 {
935  return k_LmInit_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
936 }
937 
939 {
940  return k_LmInit_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
941 }
942 
944 {
945  return k_LmShallowCopyDelete_currRing_2_tailRing(p, tailRing, tailRing->PolyBin);
946 }
947 
949 {
950  return k_LmShallowCopyDelete_tailRing_2_currRing(p, tailRing, currRing->PolyBin);
951 }
952 
953 /***************************************************************
954  *
955  * Lcm business
956  *
957  ***************************************************************/
958 // get m1 = LCM(LM(p1), LM(p2))/LM(p1)
959 // m2 = LCM(LM(p1), LM(p2))/LM(p2)
960 KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r,
961  poly &m1, poly &m2, const ring m_r)
962 {
963  p_LmCheckPolyRing(p1, p_r);
964  p_LmCheckPolyRing(p2, p_r);
965 
966  int i;
967  long x;
968  m1 = p_Init(m_r);
969  m2 = p_Init(m_r);
970 
971  for (i = p_r->N; i; i--)
972  {
973  x = p_GetExpDiff(p1, p2, i, p_r);
974  if (x > 0)
975  {
976  if (x > (long) m_r->bitmask) goto false_return;
977  p_SetExp(m2,i,x, m_r);
978  p_SetExp(m1,i,0, m_r);
979  }
980  else
981  {
982  if (-x > (long) m_r->bitmask) goto false_return;
983  p_SetExp(m1,i,-x, m_r);
984  p_SetExp(m2,i,0, m_r);
985  }
986  }
987 
988  p_Setm(m1, m_r);
989  p_Setm(m2, m_r);
990  return TRUE;
991 
992  false_return:
993  p_LmFree(m1, m_r);
994  p_LmFree(m2, m_r);
995  m1 = m2 = NULL;
996  return FALSE;
997 }
998 
999 #ifdef HAVE_RINGS
1000 // get m1 = LCM(LM(p1), LM(p2))/LM(p1)
1001 // m2 = LCM(LM(p1), LM(p2))/LM(p2) in tailRing
1002 // lcm = LCM(LM(p1), LM(p2)) in leadRing
1003 KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing,
1004  poly &m1, poly &m2, poly &lcm, const ring tailRing)
1005 {
1006  p_LmCheckPolyRing(p1, leadRing);
1007  p_LmCheckPolyRing(p2, leadRing);
1008 
1009  int i;
1010  int x;
1011  int e1;
1012  int e2;
1013  int s;
1014  m1 = p_Init(tailRing);
1015  m2 = p_Init(tailRing);
1016  lcm = p_Init(leadRing);
1017 
1018  for (i = leadRing->N; i>=0; i--)
1019  {
1020  e1 = p_GetExp(p1,i,leadRing);
1021  e2 = p_GetExp(p2,i,leadRing);
1022  x = e1 - e2;
1023  if (x > 0)
1024  {
1025  p_SetExp(m2,i,x, tailRing);
1026  //p_SetExp(m1,i,0, tailRing); // done by p_Init
1027  s = e1;
1028  }
1029  else if (x<0)
1030  {
1031  p_SetExp(m1,i,-x, tailRing);
1032  //p_SetExp(m2,i,0, tailRing); // done by p_Init
1033  s = e2;
1034  }
1035  else
1036  s = e1; // e1==e2
1037  p_SetExp(lcm,i,s, leadRing);
1038  }
1039 
1040  p_Setm(m1, tailRing);
1041  p_Setm(m2, tailRing);
1042  p_Setm(lcm, leadRing);
1043 }
1044 #endif
1045 
1046 /***************************************************************
1047  *
1048  * Misc things
1049  *
1050  ***************************************************************/
1052 {
1053  BOOLEAN ret;
1054  number coef;
1055 
1056  assume(PR->GetLmCurrRing() != PW->GetLmCurrRing());
1057  Red->HeadNormalize();
1058  ret = ksReducePoly(Red, PW, NULL, &coef);
1059 
1060  if (!ret)
1061  {
1062  if (! n_IsOne(coef, currRing->cf))
1063  {
1064  PR->Mult_nn(coef);
1065  // HANNES: mark for Normalize
1066  }
1067  n_Delete(&coef, currRing->cf);
1068  }
1069  return ret;
1070 }
1071 
1072 /***************************************************************
1073  *
1074  * Routines for backwards-Compatibility
1075  *
1076  *
1077  ***************************************************************/
1079 {
1080  LObject L(p2);
1081  TObject T(p1);
1082 
1083  ksReducePoly(&L, &T, spNoether);
1084 
1085  return L.GetLmCurrRing();
1086 }
1087 
1089 {
1090  LObject L(p_Copy(p2, currRing));
1091  TObject T(p1);
1092 
1093  ksReducePoly(&L, &T, spNoether);
1094 
1095  return L.GetLmCurrRing();
1096 }
1097 
1099 {
1100  LObject L(r);
1101  L.p1 = p1;
1102  L.p2 = p2;
1103 
1104  ksCreateSpoly(&L, spNoether);
1105  return L.GetLmCurrRing();
1106 }
1107 
1108 void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r)
1109 {
1110  LObject L(q, currRing, r);
1111  TObject T(p1, currRing, r);
1112 
1113  ksReducePolyTail(&L, &T, q2, spNoether);
1114 }
1115 
1117 {
1118  LObject L(p, currRing, strat->tailRing);
1119  return redtailBba(&L, pos, strat,FALSE, normalize);
1120 }
1121 
1122 #ifdef HAVE_RINGS
1124 {
1125  LObject L(p, currRing, strat->tailRing);
1126  return redtailBba_Z(&L, pos, strat);
1127 }
1128 #endif
1129 
1131 {
1132  LObject L;
1133  L = *T;
1134  poly p = redtailBba(&L, pos, strat, FALSE);
1135  *T = L;
1136  //kTest_T(T);
1137  assume( p == T->p);
1138  return p;
1139 }
1140 
1141 KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
1142  kStrategy strat)
1143 {
1144  assume(p_sev == pGetShortExpVector(p));
1145  if (strat->noClearS) return;
1146  #if HAVE_RINGS
1148  {
1149  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at]))
1150  return;
1151  if(!n_DivBy(pGetCoeff(strat->S[*at]), pGetCoeff(p), currRing))
1152  return;
1153  }
1154  else
1155  {
1156  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1157  }
1158  #else
1159  if (!pLmShortDivisibleBy(p,p_sev, strat->S[*at], ~ strat->sevS[*at])) return;
1160  #endif
1161  deleteInS((*at),strat);
1162  (*at)--;
1163  (*k)--;
1164 }
1165 
1166 // dummy function for function pointer strat->rewCrit being usable in all
1167 // possible choices for criteria
1168 KINLINE BOOLEAN arriRewDummy(poly /*sig*/, unsigned long /*not_sevSig*/, poly /*lm*/, kStrategy /*strat*/, int /*start=0*/)
1169 {
1170  return FALSE;
1171 }
1172 
1173 #endif // defined(KINLINE) || defined(KUTIL_CC)
1174 #endif // KINLINE_H
KINLINE void Init(ring tailRing=currRing)
Definition: kInline.h:502
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:499
KINLINE int GetpLength()
Definition: kInline.h:805
KINLINE poly GetP(omBin lmBin=NULL)
Definition: kInline.h:675
denominator_list_s * denominator_list
Definition: kutil.h:65
static number Copy(number a, const coeffs r)
Definition: flintcf_Q.cc:233
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:960
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition: syz3.cc:1028
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:513
KINLINE void SetShortExpVector()
Definition: kInline.h:713
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:471
omBin_t * omBin
Definition: omStructs.h:12
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:1123
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:377
TObject * TSet
Definition: kutil.h:61
KINLINE TSet initT()
Definition: kInline.h:81
KINLINE sLObject & operator=(const sTObject &)
Definition: kInline.h:846
KINLINE poly Next()
Definition: kInline.h:280
#define FALSE
Definition: auxiliary.h:140
Compatiblity layer for legacy polynomial operations (over currRing)
int * S_2_R
Definition: kutil.h:340
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:469
KINLINE int ksReducePolyTail(LObject *PR, TObject *PW, LObject *Red)
Definition: kInline.h:1051
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:910
#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:617
KINLINE sLObject(ring tailRing=currRing)
Definition: kInline.h:510
KINLINE void Init(ring r=currRing)
Definition: kInline.h:107
KINLINE BOOLEAN IsNull() const
Definition: kInline.h:263
poly kNoether
Definition: kutil.h:326
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
Definition: kInline.h:1098
int tl
Definition: kutil.h:348
KINLINE void HeadNormalize()
Definition: kInline.h:334
static poly p_LmShallowCopyDelete(poly p, const ring r)
Definition: p_polys.h:1322
char noClearS
Definition: kutil.h:392
#define TRUE
Definition: auxiliary.h:144
#define nIsOne(n)
Definition: numbers.h:25
denominator_list DENOMINATOR_LIST
Definition: kutil.cc:81
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
Definition: kspoly.cc:38
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1436
void deleteInS(int i, kStrategy strat)
Definition: kutil.cc:942
pShallowCopyDeleteProc p_shallow_copy_delete
Definition: kutil.h:336
int k
Definition: cfEzgcd.cc:93
KINLINE void pNorm()
Definition: kInline.h:469
void p_Norm(poly p1, const ring r)
Definition: p_polys.cc:3576
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:576
KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether)
Definition: kInline.h:576
#define omAlloc(size)
Definition: omAllocDecl.h:210
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition: kInline.h:1116
#define KINLINE
Definition: kutil.h:51
static void p_LmFree(poly p, ring)
Definition: p_polys.h:678
static int pLength(poly a)
Definition: p_polys.h:189
poly kBucketExtractLm(kBucket_pt bucket)
Definition: kbuckets.cc:489
KINLINE void PrepareRed(BOOLEAN use_bucket)
Definition: kInline.h:526
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:810
poly pp
Definition: myNF.cc:296
KINLINE void Tail_Mult_nn(number n)
Definition: kInline.h:562
KINLINE void LmDeleteAndIter()
Definition: kInline.h:288
KINLINE void Copy()
Definition: kInline.h:725
KINLINE void SetLmTail(poly lm, poly new_p, int length, int use_bucket, ring r)
Definition: kInline.h:544
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:2837
KINLINE int GetpLength()
Definition: kInline.h:268
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:12
KINLINE void Copy()
Definition: kInline.h:200
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:818
const ring r
Definition: syzextra.cc:208
KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:901
KINLINE TObject * S_2_T(int i)
Definition: kInline.h:35
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:204
KINLINE long pLDeg()
Definition: kInline.h:760
#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
static int max(int a, int b)
Definition: fast_mult.cc:264
KINLINE long pTotalDeg() const
Definition: kInline.h:400
KINLINE void Clear()
Definition: kInline.h:189
KINLINE void LmDeleteAndIter()
Definition: kInline.h:598
#define assume(x)
Definition: mod2.h:405
KINLINE TObject * T_2(const skStrategy *strat)
Definition: kInline.h:863
KINLINE poly CanonicalizeP()
Definition: kInline.h:644
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl.cc )
Definition: polys.h:140
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:776
void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r)
Definition: kInline.h:1108
#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:134
#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:379
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:901
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:338
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:698
KINLINE long Comp()
Definition: kInline.h:837
polyset S
Definition: kutil.h:302
#define nDelete(n)
Definition: numbers.h:16
#define p_Test(p, r)
Definition: p_polys.h:160
KINLINE void pCleardenom()
Definition: kInline.h:431
KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether)
Definition: kInline.h:1088
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:849
KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin tailBin)
Definition: kInline.h:919
static number Init(long i, const coeffs r)
Definition: flintcf_Q.cc:149
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4586
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
LSet L
Definition: kutil.h:323
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:434
#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:341
poly p_Last(const poly p, int &l, const ring r)
Definition: p_polys.cc:4427
KINLINE poly GetLmTailRing()
Definition: kInline.h:224
KINLINE long pLDeg()
Definition: kInline.h:415
KINLINE poly GetTP()
Definition: kInline.h:659
denominator_list next
Definition: kutil.h:67
poly t_kNoether
Definition: kutil.h:329
omBin tailBin
Definition: kutil.h:343
KINLINE int SetLength(BOOLEAN lengt_pLength=FALSE)
Definition: kInline.h:812
unsigned long * sevS
Definition: kutil.h:318
KINLINE long SetDegStuffReturnLDeg()
Definition: kInline.h:419
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:1264
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
KINLINE void Delete()
Definition: kInline.h:495
#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:1141
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:982
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:1003
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
Definition: kInline.h:1078
int sl
Definition: kutil.h:346
KINLINE long pFDeg() const
Definition: kInline.h:395
TSet T
Definition: kutil.h:322
KINLINE long GetpFDeg() const
Definition: kInline.h:410
omBin lmBin
Definition: kutil.h:342
KINLINE poly LmExtractAndIter()
Definition: kInline.h:618
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:456
KINLINE poly GetLm(ring r)
Definition: kInline.h:237
KINLINE void Clear()
Definition: kInline.h:489
polyrec * poly
Definition: hilb.h:10
KINLINE poly CopyGetP()
Definition: kInline.h:741
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition: kbuckets.cc:197
int BOOLEAN
Definition: auxiliary.h:131
int kBucketCanonicalize(kBucket_pt bucket)
KINLINE long SetpFDeg()
Definition: kInline.h:405
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1249
KINLINE poly kNoetherTail()
Definition: kInline.h:63
KINLINE BOOLEAN arriRewDummy(poly, unsigned long, poly, kStrategy, int)
Definition: kInline.h:1168
KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin lmBin)
Definition: kInline.h:926
void kBucketDeleteAndDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:211
KINLINE void T_1_2(const skStrategy *strat, TObject *&T_1, TObject *&T_2)
Definition: kInline.h:874
void p_ProjectiveUnique(poly ph, const ring r)
Definition: p_polys.cc:3019
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
KINLINE long SetDegStuffReturnLDeg()
Definition: kInline.h:791
class sTObject TObject
Definition: kutil.h:59
KINLINE void Delete()
Definition: kInline.h:175
KINLINE long MinComp()
Definition: kInline.h:822
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 TObject * T_1(const skStrategy *strat)
Definition: kInline.h:853
KINLINE void ShallowCopyDelete(ring new_tailRing, pShallowCopyDeleteProc p_shallow_copy_delete)
Definition: kInline.h:702