Macros | Functions | Variables
kbuckets.cc File Reference
#include "omalloc/omalloc.h"
#include "misc/auxiliary.h"
#include "misc/options.h"
#include "polys/monomials/p_polys.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "polys/monomials/ring.h"
#include "polys/kbuckets.h"

Go to the source code of this file.

Macros

#define MULTIPLY_BUCKET(B, I)
 

Functions

static int LOG4 (int v)
 Some internal stuff. More...
 
static unsigned int pLogLength (unsigned int l)
 
static unsigned int pLogLength (poly p)
 
BOOLEAN kbTest (kBucket_pt bucket)
 Tests. More...
 
kBucket_pt kBucketCreate (const ring bucket_ring)
 Creation/Destruction of buckets. More...
 
void kBucketDestroy (kBucket_pt *bucket_pt)
 
void kBucketDeleteAndDestroy (kBucket_pt *bucket_pt)
 
void kBucketInit (kBucket_pt bucket, poly lm, int length)
 
const poly kBucketGetLm (kBucket_pt bucket)
 
poly kBucketExtractLm (kBucket_pt bucket)
 
void kBucketClear (kBucket_pt bucket, poly *p, int *length)
 
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. More...
 
void kBucketAdjust (kBucket_pt bucket, int i)
 Bucket number i from bucket is out of length sync, resync. More...
 
void kBucket_Mult_n (kBucket_pt bucket, number n)
 Multiply Bucket by number ,i.e. Bpoly == n*Bpoly. More...
 
void kBucket_Add_q (kBucket_pt bucket, poly q, int *l)
 Add to Bucket a poly ,i.e. Bpoly == q+Bpoly. More...
 
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) More...
 
void kBucket_Plus_mm_Mult_pp (kBucket_pt bucket, poly m, poly p, int l)
 Bpoly == Bpoly + m*p; where m is a monom Does not destroy p and m assume (l <= 0 || pLength(p) == l) More...
 
poly kBucket_ExtractLarger (kBucket_pt bucket, poly q, poly append)
 Extract all monomials of bucket which are larger than q Append those to append, and return last monomial of append. More...
 
void p_TakeOutComp (poly *p, long comp, poly *q, int *lq, const ring r)
 
void kBucketTakeOutComp (kBucket_pt bucket, long comp, poly *r_p, int *l)
 
int ksCheckCoeff (number *a, number *b)
 
number kBucketPolyRed (kBucket_pt bucket, poly p1, int l1, poly spNoether)
 
void kBucketSimpleContent (kBucket_pt bucket)
 
poly kBucketExtractLmOfBucket (kBucket_pt bucket, int i)
 
int ksCheckCoeff (number *a, number *b, const coeffs r)
 

Variables

static omBin kBucket_bin = omGetSpecBin(sizeof(kBucket))
 

Macro Definition Documentation

◆ MULTIPLY_BUCKET

#define MULTIPLY_BUCKET (   B,
 
)

Definition at line 40 of file kbuckets.cc.

Function Documentation

◆ kbTest()

BOOLEAN kbTest ( kBucket_pt  bucket)

Tests.

Definition at line 194 of file kbuckets.cc.

195 {
196  return TRUE;
197 }
#define TRUE
Definition: auxiliary.h:98

◆ kBucket_Add_q()

void kBucket_Add_q ( kBucket_pt  bucket,
poly  q,
int *  l 
)

Add to Bucket a poly ,i.e. Bpoly == q+Bpoly.

Add to Bucket a poly ,i.e. Bpoly == Bpoly + q.

Definition at line 636 of file kbuckets.cc.

637 {
638  if (q == NULL) return;
639  assume(*l <= 0 || pLength(q) == *l);
640 
641  int i, l1;
642  ring r = bucket->bucket_ring;
643 
644  if (*l <= 0)
645  {
646  l1 = pLength(q);
647  *l = l1;
648  }
649  else
650  l1 = *l;
651 
652  kBucketMergeLm(bucket);
653  kbTest(bucket);
654  i = pLogLength(l1);
655 
656  while (bucket->buckets[i] != NULL)
657  {
658  //MULTIPLY_BUCKET(bucket,i);
659  #ifdef USE_COEF_BUCKETS
660  if (bucket->coef[i]!=NULL)
661  {
662  q = p_Plus_mm_Mult_qq(q, bucket->coef[i], bucket->buckets[i],
663  l1, bucket->buckets_length[i], r);
664  p_Delete(&bucket->coef[i],r);
665  p_Delete(&bucket->buckets[i],r);
666  }
667  else
668  q = p_Add_q(q, bucket->buckets[i],
669  l1, bucket->buckets_length[i], r);
670  #else
671  q = p_Add_q(q, bucket->buckets[i],
672  l1, bucket->buckets_length[i], r);
673  #endif
674  bucket->buckets[i] = NULL;
675  bucket->buckets_length[i] = 0;
676  i = pLogLength(l1);
677  assume(i<= MAX_BUCKET);
678  assume(bucket->buckets_used<= MAX_BUCKET);
679  }
680 
681  kbTest(bucket);
682  bucket->buckets[i] = q;
683  bucket->buckets_length[i]=l1;
684  if (i >= bucket->buckets_used)
685  bucket->buckets_used = i;
686  else
687  kBucketAdjustBucketsUsed(bucket);
688  kbTest(bucket);
689 }
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:194
#define MAX_BUCKET
Bucket definition (should be no one elses business, though)
Definition: kbuckets.h:172
ring bucket_ring
Definition: kbuckets.h:189
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:192
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define NULL
Definition: omList.c:10
static unsigned int pLogLength(unsigned int l)
Definition: kbuckets.cc:68
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
int l
Definition: cfEzgcd.cc:93
static poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq, const ring r)
Definition: p_polys.h:1129

◆ kBucket_ExtractLarger()

poly kBucket_ExtractLarger ( kBucket_pt  bucket,
poly  q,
poly  append 
)

Extract all monomials of bucket which are larger than q Append those to append, and return last monomial of append.

Definition at line 986 of file kbuckets.cc.

987 {
988  if (q == NULL) return append;
989  poly lm;
990  loop
991  {
992  lm = kBucketGetLm(bucket);
993  if (lm == NULL) return append;
994  if (p_LmCmp(lm, q, bucket->bucket_ring) == 1)
995  {
996  lm = kBucketExtractLm(bucket);
997  pNext(append) = lm;
998  pIter(append);
999  }
1000  else
1001  {
1002  return append;
1003  }
1004  }
1005 }
CFFList append(const CFFList &Inputlist, const CFFactor &TheFactor)
const poly kBucketGetLm(kBucket_pt bucket)
Definition: kbuckets.cc:488
#define loop
Definition: structs.h:78
poly kBucketExtractLm(kBucket_pt bucket)
Definition: kbuckets.cc:493
#define pIter(p)
Definition: monomials.h:44
ring bucket_ring
Definition: kbuckets.h:189
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1507
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43

◆ kBucket_Minus_m_Mult_p()

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)

Bpoly == Bpoly - m*p; where m is a monom Does not destroy p and m (TODO: rename into kBucket_Minus_mm_Mult_pp!?) assume (*l <= 0 || pLength(p) == *l)

Definition at line 698 of file kbuckets.cc.

700 {
701  assume(*l <= 0 || pLength(p) == *l);
702  int i, l1;
703  poly p1 = p;
704  ring r = bucket->bucket_ring;
705 
706  if (*l <= 0)
707  {
708  l1 = pLength(p1);
709  *l = l1;
710  }
711  else
712  l1 = *l;
713 
714  if (m == NULL || p == NULL) return;
715 
716 #ifndef HAVE_PSEUDO_BUCKETS
717  kBucketMergeLm(bucket);
718  kbTest(bucket);
719  i = pLogLength(l1);
720 
721 #if defined(HAVE_PLURAL)
722  if ((rField_is_Ring(r) && !(rField_is_Domain(r)))
723  ||(rIsPluralRing(r)))
724  {
725  pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
726  p1=pp_Mult_mm(p,m,r);
727  pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
728  l1=pLength(p1);
729  i = pLogLength(l1);
730  }
731  else
732 #endif
733  {
734  if ((i <= bucket->buckets_used) && (bucket->buckets[i] != NULL))
735  {
736  assume(pLength(bucket->buckets[i])==(unsigned)bucket->buckets_length[i]);
737 //#ifdef USE_COEF_BUCKETS
738 // if(bucket->coef[i]!=NULL)
739 // {
740 // poly mult=p_Mult_mm(bucket->coef[i],m,r);
741 // bucket->coef[i]=NULL;
742 // p1 = p_Minus_mm_Mult_qq(bucket->buckets[i], mult, p1,
743 // bucket->buckets_length[i], l1,
744 // spNoether, r);
745 // }
746 // else
747 //#endif
748  MULTIPLY_BUCKET(bucket,i);
749  p1 = p_Minus_mm_Mult_qq(bucket->buckets[i], m, p1,
750  bucket->buckets_length[i], l1,
751  spNoether, r);
752  l1 = bucket->buckets_length[i];
753  bucket->buckets[i] = NULL;
754  bucket->buckets_length[i] = 0;
755  i = pLogLength(l1);
756  }
757  else
758  {
759  pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
760  if (spNoether != NULL)
761  {
762  l1 = -1;
763  p1 = r->p_Procs->pp_Mult_mm_Noether(p1, m, spNoether, l1, r);
764  i = pLogLength(l1);
765  }
766  else
767  {
768  p1 = r->p_Procs->pp_Mult_mm(p1, m, r);
769  }
770  pSetCoeff0(m, n_InpNeg(pGetCoeff(m),r->cf));
771  }
772  }
773 
774  while (bucket->buckets[i] != NULL)
775  {
776  //kbTest(bucket);
777  MULTIPLY_BUCKET(bucket,i);
778  p1 = p_Add_q(p1, bucket->buckets[i],
779  l1, bucket->buckets_length[i], r);
780  bucket->buckets[i] = NULL;
781  bucket->buckets_length[i] = 0;
782  i = pLogLength(l1);
783  }
784 
785  bucket->buckets[i] = p1;
786  bucket->buckets_length[i]=l1;
787  if (i >= bucket->buckets_used)
788  bucket->buckets_used = i;
789  else
790  kBucketAdjustBucketsUsed(bucket);
791 #else // HAVE_PSEUDO_BUCKETS
792  bucket->p = p_Minus_mm_Mult_qq(bucket->p, m, p,
793  bucket->l, l1,
794  spNoether, r);
795 #endif
796 }
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:194
#define MULTIPLY_BUCKET(B, I)
Definition: kbuckets.cc:40
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:987
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:480
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
ring bucket_ring
Definition: kbuckets.h:189
#define assume(x)
Definition: mod2.h:390
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
int m
Definition: cfEzgcd.cc:121
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:192
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
int l
Definition: kbuckets.h:180
poly p
Definition: kbuckets.h:179
#define pSetCoeff0(p, n)
Definition: monomials.h:66
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:1006
static unsigned int pLogLength(unsigned int l)
Definition: kbuckets.cc:68
int p
Definition: cfModGcd.cc:4019
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
int l
Definition: cfEzgcd.cc:93

◆ kBucket_Mult_n()

void kBucket_Mult_n ( kBucket_pt  bucket,
number  n 
)

Multiply Bucket by number ,i.e. Bpoly == n*Bpoly.

Definition at line 580 of file kbuckets.cc.

581 {
582 #ifndef HAVE_PSEUDO_BUCKETS
583  kbTest(bucket);
584  ring r=bucket->bucket_ring;
585  int i;
586 
587  for (i=0; i<= bucket->buckets_used; i++)
588  {
589  if (bucket->buckets[i] != NULL)
590  {
591 #ifdef USE_COEF_BUCKETS
592  if (i<coef_start)
593  bucket->buckets[i] = __p_Mult_nn(bucket->buckets[i], n, r);
594  /* Frank Seelisch on March 11, 2010:
595  This looks a bit strange: The following "if" is indented
596  like the previous line of code. But coded as it is,
597  it should actually be two spaces less indented.
598  Question: Should the following "if" also only be
599  performed when "(i<coef_start)" is true?
600  For the time being, I leave it as it is. */
601  if (rField_is_Ring(r) && !(rField_is_Domain(r)))
602  {
603  bucket->buckets_length[i] = pLength(bucket->buckets[i]);
604  kBucketAdjust(bucket, i);
605  }
606  else
607  if (bucket->coef[i]!=NULL)
608  {
609  bucket->coef[i] = __p_Mult_nn(bucket->coef[i],n,r);
610  }
611  else
612  {
613  bucket->coef[i] = p_NSet(n_Copy(n,r),r);
614  }
615 #else
616  bucket->buckets[i] = __p_Mult_nn(bucket->buckets[i], n, r);
617  if (rField_is_Ring(r) && !(rField_is_Domain(r)))
618  {
619  bucket->buckets_length[i] = pLength(bucket->buckets[i]);
620  kBucketAdjust(bucket, i);
621  }
622 #endif
623  }
624  }
625  kbTest(bucket);
626 #else
627  bucket->p = __p_Mult_nn(bucket->p, n, bucket->bucket_ring);
628 #endif
629 }
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:194
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:480
ring bucket_ring
Definition: kbuckets.h:189
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:192
void kBucketAdjust(kBucket_pt bucket, int i)
Bucket number i from bucket is out of length sync, resync.
Definition: kbuckets.cc:547
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
poly p
Definition: kbuckets.h:179

◆ kBucket_Plus_mm_Mult_pp()

void kBucket_Plus_mm_Mult_pp ( kBucket_pt  bucket,
poly  m,
poly  p,
int  l 
)

Bpoly == Bpoly + m*p; where m is a monom Does not destroy p and m assume (l <= 0 || pLength(p) == l)

Definition at line 803 of file kbuckets.cc.

804 {
805  assume((!rIsPluralRing(bucket->bucket_ring))||p_IsConstant(m, bucket->bucket_ring));
806  assume(l <= 0 || pLength(p) == (unsigned)l);
807  int i, l1;
808  poly p1 = p;
809  ring r = bucket->bucket_ring;
810 
811  if (m == NULL || p == NULL) return;
812 
813  if (l <= 0)
814  {
815  l1 = pLength(p1);
816  l = l1;
817  }
818  else
819  l1 = l;
820 
821  kBucketMergeLm(bucket);
822  kbTest(bucket);
823  i = pLogLength(l1);
824  #ifdef USE_COEF_BUCKETS
825  number n=n_Init(1,r->cf);
826  #endif
827  if (i <= bucket->buckets_used && bucket->buckets[i] != NULL)
828  {
829  //if (FALSE){
830  #ifdef USE_COEF_BUCKETS
831  if ((bucket->coef[i]!=NULL) &&(i>=coef_start))
832  {
833  number orig_coef=p_GetCoeff(bucket->coef[i],r);
834  //we take ownership:
835  p_SetCoeff0(bucket->coef[i],n_Init(0,r),r);
836  number add_coef=n_Copy(p_GetCoeff(m,r),r);
837  number gcd=n_Gcd(add_coef, orig_coef,r);
838 
839  if (!(n_IsOne(gcd,r)))
840  {
841  number orig_coef2=n_ExactDiv(orig_coef,gcd,r);
842  number add_coef2=n_ExactDiv(add_coef, gcd,r);
843  n_Delete(&orig_coef,r);
844  n_Delete(&add_coef,r);
845  orig_coef=orig_coef2;
846  add_coef=add_coef2;
847 
848  //p_Mult_nn(bucket->buckets[i], orig_coef,r);
849  n_Delete(&n,r);
850  n=gcd;
851  }
852 
853  //assume(n_IsOne(n,r));
854  number backup=p_GetCoeff(m,r);
855 
856  p_SetCoeff0(m,add_coef,r);
857  bucket->buckets[i]=__p_Mult_nn(bucket->buckets[i],orig_coef,r);
858 
859  n_Delete(&orig_coef,r);
860  p_Delete(&bucket->coef[i],r);
861 
862  p1 = p_Plus_mm_Mult_qq(bucket->buckets[i], m, p1,
863  bucket->buckets_length[i], l1, r);
864  l1=bucket->buckets_length[i];
865  bucket->buckets[i]=NULL;
866  bucket->buckets_length[i] = 0;
867  i = pLogLength(l1);
868  assume(l1==pLength(p1));
869 
870  p_SetCoeff(m,backup,r); //deletes add_coef
871  }
872  else
873  #endif
874  {
875  MULTIPLY_BUCKET(bucket,i);
876  p1 = p_Plus_mm_Mult_qq(bucket->buckets[i], m, p1,
877  bucket->buckets_length[i], l1, r);
878  l1 = bucket->buckets_length[i];
879  bucket->buckets[i] = NULL;
880  bucket->buckets_length[i] = 0;
881  i = pLogLength(l1);
882  }
883  }
884  else
885  {
886  #ifdef USE_COEF_BUCKETS
887  number swap_n=p_GetCoeff(m,r);
888 
889  assume(n_IsOne(n,r));
890  p_SetCoeff0(m,n,r);
891  n=swap_n;
892  //p_SetCoeff0(n, swap_n, r);
893  //p_GetCoeff0(n, swap_n,r);
894  #endif
895  p1 = r->p_Procs->pp_Mult_mm(p1, m, r);
896  #ifdef USE_COEF_BUCKETS
897  //m may not be changed
898  p_SetCoeff(m,n_Copy(n,r),r);
899  #endif
900  }
901 
902  while ((bucket->buckets[i] != NULL) && (p1!=NULL))
903  {
904  assume(i!=0);
905  #ifdef USE_COEF_BUCKETS
906  if ((bucket->coef[i]!=NULL) &&(i>=coef_start))
907  {
908  number orig_coef=p_GetCoeff(bucket->coef[i],r);
909  //we take ownership:
910  p_SetCoeff0(bucket->coef[i],n_Init(0,r),r);
911  number add_coef=n_Copy(n,r);
912  number gcd=n_Gcd(add_coef, orig_coef,r);
913 
914  if (!(n_IsOne(gcd,r)))
915  {
916  number orig_coef2=n_ExactDiv(orig_coef,gcd,r);
917  number add_coef2=n_ExactDiv(add_coef, gcd,r);
918  n_Delete(&orig_coef,r);
919  n_Delete(&n,r);
920  n_Delete(&add_coef,r);
921  orig_coef=orig_coef2;
922  add_coef=add_coef2;
923  //p_Mult_nn(bucket->buckets[i], orig_coef,r);
924  n=gcd;
925  }
926  //assume(n_IsOne(n,r));
927  bucket->buckets[i]=__p_Mult_nn(bucket->buckets[i],orig_coef,r);
928  p1=__p_Mult_nn(p1,add_coef,r);
929 
930  p1 = p_Add_q(p1, bucket->buckets[i],r);
931  l1=pLength(p1);
932 
933  bucket->buckets[i]=NULL;
934  n_Delete(&orig_coef,r);
935  p_Delete(&bucket->coef[i],r);
936  //l1=bucket->buckets_length[i];
937  assume(l1==pLength(p1));
938  }
939  else
940  #endif
941  {
942  //don't do that, pull out gcd
943  #ifdef USE_COEF_BUCKETS
944  if(!(n_IsOne(n,r)))
945  {
946  p1=__p_Mult_nn(p1, n, r);
947  n_Delete(&n,r);
948  n=n_Init(1,r);
949  }
950  #endif
951  MULTIPLY_BUCKET(bucket,i);
952  p1 = p_Add_q(p1, bucket->buckets[i],
953  l1, bucket->buckets_length[i], r);
954  bucket->buckets[i] = NULL;
955  bucket->buckets_length[i] = 0;
956  }
957  i = pLogLength(l1);
958  }
959 
960  bucket->buckets[i] = p1;
961 #ifdef USE_COEF_BUCKETS
962  assume(bucket->coef[i]==NULL);
963 
964  if (!(n_IsOne(n,r)))
965  {
966  bucket->coef[i]=p_NSet(n,r);
967  }
968  else
969  {
970  bucket->coef[i]=NULL;
971  n_Delete(&n,r);
972  }
973 
974  if (p1==NULL)
975  p_Delete(&bucket->coef[i],r);
976 #endif
977  bucket->buckets_length[i]=l1;
978  if (i > bucket->buckets_used)
979  bucket->buckets_used = i;
980  else
981  kBucketAdjustBucketsUsed(bucket);
982 
983  kbTest(bucket);
984 }
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:194
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:687
#define MULTIPLY_BUCKET(B, I)
Definition: kbuckets.cc:40
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1435
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:539
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
ring bucket_ring
Definition: kbuckets.h:189
#define assume(x)
Definition: mod2.h:390
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:192
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
int gcd(int a, int b)
Definition: walkSupport.cc:836
static FORCE_INLINE number n_ExactDiv(number a, number b, const coeffs r)
assume that there is a canonical subring in cf and we know that division is possible for these a and ...
Definition: coeffs.h:623
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static unsigned int pLogLength(unsigned int l)
Definition: kbuckets.cc:68
#define p_SetCoeff0(p, n, r)
Definition: monomials.h:67
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
int p
Definition: cfModGcd.cc:4019
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
int l
Definition: cfEzgcd.cc:93
static poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq, const ring r)
Definition: p_polys.h:1129

◆ kBucketAdjust()

void kBucketAdjust ( kBucket_pt  bucket,
int  i 
)

Bucket number i from bucket is out of length sync, resync.

Definition at line 547 of file kbuckets.cc.

547  {
548 
549  MULTIPLY_BUCKET(bucket,i);
550 
551  int l1 = bucket->buckets_length[i];
552  poly p1 = bucket->buckets[i];
553  bucket->buckets[i] = NULL;
554  bucket->buckets_length[i] = 0;
555  i = pLogLength(l1);
556 
557  while (bucket->buckets[i] != NULL)
558  {
559  //kbTest(bucket);
560  MULTIPLY_BUCKET(bucket,i);
561  p1 = p_Add_q(p1, bucket->buckets[i],
562  l1, bucket->buckets_length[i], bucket->bucket_ring);
563  bucket->buckets[i] = NULL;
564  bucket->buckets_length[i] = 0;
565  i = pLogLength(l1);
566  }
567 
568  bucket->buckets[i] = p1;
569  bucket->buckets_length[i]=l1;
570  if (i >= bucket->buckets_used)
571  bucket->buckets_used = i;
572  else
573  kBucketAdjustBucketsUsed(bucket);
574 }
#define MULTIPLY_BUCKET(B, I)
Definition: kbuckets.cc:40
ring bucket_ring
Definition: kbuckets.h:189
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:10
static unsigned int pLogLength(unsigned int l)
Definition: kbuckets.cc:68
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892

◆ kBucketClear()

void kBucketClear ( kBucket_pt  bucket,
poly *  p,
int *  length 
)

Definition at line 503 of file kbuckets.cc.

504 {
505  assume(pLength(bucket->p) == bucket->l);
506  *p = bucket->p;
507  *length = bucket->l;
508  bucket->p = NULL;
509  bucket->l = 0;
510 }
#define assume(x)
Definition: mod2.h:390
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:267
int l
Definition: kbuckets.h:180
poly p
Definition: kbuckets.h:179
int p
Definition: cfModGcd.cc:4019

◆ kBucketCreate()

kBucket_pt kBucketCreate ( const ring  bucket_ring)

Creation/Destruction of buckets.

Definition at line 206 of file kbuckets.cc.

207 {
208  assume(bucket_ring != NULL);
210  bucket->bucket_ring = bucket_ring;
211  return bucket;
212 }
kBucket * kBucket_pt
Definition: ring.h:31
static omBin kBucket_bin
Definition: kbuckets.cc:42
ring bucket_ring
Definition: kbuckets.h:189
#define assume(x)
Definition: mod2.h:390
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10

◆ kBucketDeleteAndDestroy()

void kBucketDeleteAndDestroy ( kBucket_pt bucket_pt)

Definition at line 220 of file kbuckets.cc.

221 {
222  kBucket_pt bucket = *bucket_pt;
223  kbTest(bucket);
224  int i;
225  for (i=0; i<= bucket->buckets_used; i++)
226  {
227  p_Delete(&(bucket->buckets[i]), bucket->bucket_ring);
228 #ifdef USE_COEF_BUCKETS
229  p_Delete(&(bucket->coef[i]), bucket->bucket_ring);
230 #endif
231  }
232  omFreeBin(bucket, kBucket_bin);
233  *bucket_pt = NULL;
234 }
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:194
static omBin kBucket_bin
Definition: kbuckets.cc:42
ring bucket_ring
Definition: kbuckets.h:189
int i
Definition: cfEzgcd.cc:125
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
#define NULL
Definition: omList.c:10
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259

◆ kBucketDestroy()

void kBucketDestroy ( kBucket_pt bucket_pt)

Definition at line 213 of file kbuckets.cc.

214 {
215  omFreeBin(*bucket_pt, kBucket_bin);
216  *bucket_pt = NULL;
217 }
static omBin kBucket_bin
Definition: kbuckets.cc:42
#define NULL
Definition: omList.c:10
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259

◆ kBucketExtractLm()

poly kBucketExtractLm ( kBucket_pt  bucket)
inline

Definition at line 493 of file kbuckets.cc.

494 {
495  poly lm = bucket->p;
496  assume(pLength(bucket->p) == bucket->l);
497  pIter(bucket->p);
498  (bucket->l)--;
499  pNext(lm) = NULL;
500  return lm;
501 }
#define pIter(p)
Definition: monomials.h:44
#define assume(x)
Definition: mod2.h:390
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
int l
Definition: kbuckets.h:180
#define pNext(p)
Definition: monomials.h:43
poly p
Definition: kbuckets.h:179

◆ kBucketExtractLmOfBucket()

poly kBucketExtractLmOfBucket ( kBucket_pt  bucket,
int  i 
)

Definition at line 1334 of file kbuckets.cc.

1335 {
1336  assume(bucket->buckets[i]!=NULL);
1337 
1338  poly p=bucket->buckets[i];
1339  bucket->buckets_length[i]--;
1340 #ifdef USE_COEF_BUCKETS
1341  ring r=bucket->bucket_ring;
1342  if (bucket->coef[i]!=NULL)
1343  {
1344  poly next=pNext(p);
1345  if (next==NULL)
1346  {
1347  MULTIPLY_BUCKET(bucket,i);
1348  p=bucket->buckets[i];
1349  bucket->buckets[i]=NULL;
1350  return p;
1351  }
1352  else
1353  {
1354  bucket->buckets[i]=next;
1355  number c=p_GetCoeff(bucket->coef[i],r);
1356  pNext(p)=NULL;
1357  p=__p_Mult_nn(p,c,r);
1358  assume(p!=NULL);
1359  return p;
1360  }
1361  }
1362  else
1363 #endif
1364  {
1365  bucket->buckets[i]=pNext(bucket->buckets[i]);
1366  pNext(p)=NULL;
1367  assume(p!=NULL);
1368  return p;
1369  }
1370 }
#define MULTIPLY_BUCKET(B, I)
Definition: kbuckets.cc:40
ring bucket_ring
Definition: kbuckets.h:189
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
#define p_GetCoeff(p, r)
Definition: monomials.h:57
int p
Definition: cfModGcd.cc:4019
ListNode * next
Definition: janet.h:31

◆ kBucketGetLm()

const poly kBucketGetLm ( kBucket_pt  bucket)

Definition at line 488 of file kbuckets.cc.

489 {
490  return bucket->p;
491 }
poly p
Definition: kbuckets.h:179

◆ kBucketInit()

void kBucketInit ( kBucket_pt  bucket,
poly  lm,
int  length 
)

Definition at line 475 of file kbuckets.cc.

476 {
477  int i;
478 
479  assume(bucket != NULL);
480  assume(length <= 0 || length == pLength(lm));
481 
482  bucket->p = lm;
483  if (length <= 0) bucket->l = pLength(lm);
484  else bucket->l = length;
485 
486 }
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:267
int l
Definition: kbuckets.h:180
poly p
Definition: kbuckets.h:179

◆ kBucketPolyRed()

number kBucketPolyRed ( kBucket_pt  bucket,
poly  p1,
int  l1,
poly  spNoether 
)

Definition at line 1061 of file kbuckets.cc.

1064 {
1065  ring r=bucket->bucket_ring;
1066  assume((!rIsPluralRing(r))||p_LmEqual(p1,kBucketGetLm(bucket), r));
1067  assume(p1 != NULL &&
1068  p_DivisibleBy(p1, kBucketGetLm(bucket), r));
1069  assume(pLength(p1) == (unsigned) l1);
1070 
1071  poly a1 = pNext(p1), lm = kBucketExtractLm(bucket);
1072  BOOLEAN reset_vec=FALSE;
1073  number rn;
1074 
1075  /* we shall reduce bucket=bn*lm+... by p1=an*t+a1 where t=lm(p1)
1076  and an,bn shall be defined further down only if lc(p1)!=1
1077  we already know: an|bn and t|lm */
1078  if(a1==NULL)
1079  {
1080  p_LmDelete(&lm, r);
1081  return n_Init(1,r->cf);
1082  }
1083 
1084  if (! n_IsOne(pGetCoeff(p1),r->cf))
1085  {
1086  number an = pGetCoeff(p1), bn = pGetCoeff(lm);
1087 //StringSetS("##### an = "); nWrite(an); PrintS(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
1088 //StringSetS("##### bn = "); nWrite(bn); PrintS(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
1089  /* ksCheckCoeff: divide out gcd from an and bn: */
1090  int ct = ksCheckCoeff(&an, &bn,r->cf);
1091  /* the previous command returns ct=0 or ct=2 iff an!=1
1092  note: an is now 1 or -1 */
1093 
1094  /* setup factor for p1 which cancels leading terms */
1095  p_SetCoeff(lm, bn, r);
1096  if ((ct == 0) || (ct == 2))
1097  {
1098  /* next line used to be here before but is WRONG:
1099  kBucket_Mult_n(bucket, an);
1100  its use would result in a wrong sign for the tail of bucket
1101  in the reduction */
1102 
1103  /* correct factor for cancelation by changing sign if an=-1 */
1104  if (rField_is_Ring(r))
1105  lm = __p_Mult_nn(lm, an, r);
1106  else
1107  kBucket_Mult_n(bucket, an);
1108  }
1109  rn = an;
1110  }
1111  else
1112  {
1113  rn = n_Init(1,r->cf);
1114  }
1115 
1116  if (p_GetComp(p1, r) != p_GetComp(lm, r))
1117  {
1118  p_SetCompP(a1, p_GetComp(lm, r), r);
1119  reset_vec = TRUE;
1120  p_SetComp(lm, p_GetComp(p1, r), r);
1121  p_Setm(lm, r);
1122  }
1123 
1124  p_ExpVectorSub(lm, p1, r);
1125  l1--;
1126 
1127  assume((unsigned)l1==pLength(a1));
1128 #if 0
1129  BOOLEAN backuped=FALSE;
1130  number coef;
1131  //@Viktor, don't ignore coefficients on monomials
1132  if(l1==1) {
1133 
1134  //if (rField_is_Q(r)) {
1135  //avoid this for function fields, as gcds are expensive at the moment
1136 
1137 
1138  coef=p_GetCoeff(a1,r);
1139  lm=p_Mult_nn(lm, coef, r);
1140  p_SetCoeff0(a1, n_Init(1,r), r);
1141  backuped=TRUE;
1142  //WARNING: not thread_safe
1143  //deletes coef as side effect
1144  //}
1145  }
1146 #endif
1147 
1148  kBucket_Minus_m_Mult_p(bucket, lm, a1, &l1, spNoether);
1149 
1150 #if 0
1151  if (backuped)
1152  p_SetCoeff0(a1,coef,r);
1153 #endif
1154 
1155  p_LmDelete(&lm, r);
1156  if (reset_vec) p_SetCompP(a1, 0, r);
1157  kbTest(bucket);
1158  return rn;
1159 }
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:194
#define FALSE
Definition: auxiliary.h:94
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
#define p_GetComp(p, r)
Definition: monomials.h:71
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:539
const poly kBucketGetLm(kBucket_pt bucket)
Definition: kbuckets.cc:488
int ksCheckCoeff(number *a, number *b)
#define TRUE
Definition: auxiliary.h:98
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:580
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
poly kBucketExtractLm(kBucket_pt bucket)
Definition: kbuckets.cc:493
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:254
ring bucket_ring
Definition: kbuckets.h:189
#define assume(x)
Definition: mod2.h:390
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1824
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
Definition: p_polys.h:1386
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:914
static unsigned pLength(poly a)
Definition: p_polys.h:192
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
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1658
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:711
#define p_SetCoeff0(p, n, r)
Definition: monomials.h:67
int BOOLEAN
Definition: auxiliary.h:85

◆ kBucketShallowCopyDelete()

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 at line 517 of file kbuckets.cc.

520 {
521 #ifndef HAVE_PSEUDO_BUCKETS
522  int i;
523 
524  kBucketCanonicalize(bucket);
525  for (i=0; i<= bucket->buckets_used; i++)
526  if (bucket->buckets[i] != NULL)
527  {
528  MULTIPLY_BUCKET(bucket,i);
529  bucket->buckets[i] = p_shallow_copy_delete(bucket->buckets[i],
530  bucket->bucket_ring,
531  new_tailRing,
532  new_tailBin);
533  }
534 #else
535  bucket->p = p_shallow_copy_delete(p,
536  bucket_ring,
537  new_tailRing,
538  new_tailBin);
539 #endif
540  bucket->bucket_ring = new_tailRing;
541 }
#define MULTIPLY_BUCKET(B, I)
Definition: kbuckets.cc:40
ring bucket_ring
Definition: kbuckets.h:189
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:10
poly p
Definition: kbuckets.h:179
int p
Definition: cfModGcd.cc:4019
int kBucketCanonicalize(kBucket_pt bucket)

◆ kBucketSimpleContent()

void kBucketSimpleContent ( kBucket_pt  bucket)

Definition at line 1162 of file kbuckets.cc.

1163 {
1164  if (bucket->buckets[0]==NULL) return;
1165 
1166  ring r=bucket->bucket_ring;
1167  if (rField_is_Ring(r)) return;
1168 
1169  coeffs cf=r->cf;
1170  if (cf->cfSubringGcd==ndGcd) /* trivial gcd*/ return;
1171 
1172  number nn=pGetCoeff(bucket->buckets[0]);
1173  //if ((bucket->buckets_used==0)
1174  //&&(!n_IsOne(nn,cf)))
1175  //{
1176  // if (TEST_OPT_PROT) PrintS("@");
1177  // p_SetCoeff(bucket->buckets[0],n_Init(1,cf),r);
1178  // return;
1179  //}
1180 
1181  if (n_Size(nn,cf)<2) return;
1182 
1183  //kBucketAdjustBucketsUsed(bucket);
1184  number coef=n_Copy(nn,cf);
1185  // find an initial guess of a gcd
1186  for (int i=1; i<=bucket->buckets_used;i++)
1187  {
1188  if (bucket->buckets[i]!=NULL)
1189  {
1190  number t=p_InitContent(bucket->buckets[i],r);
1191  if (n_Size(t,cf)<2)
1192  {
1193  n_Delete(&t,cf);
1194  n_Delete(&coef,cf);
1195  return;
1196  }
1197  number t2=n_SubringGcd(coef,t,cf);
1198  n_Delete(&t,cf);
1199  n_Delete(&coef,cf);
1200  coef=t2;
1201  if (n_Size(coef,cf)<2) { n_Delete(&coef,cf);return;}
1202  }
1203  }
1204  // find the gcd
1205  for (int i=0; i<=bucket->buckets_used;i++)
1206  {
1207  if (bucket->buckets[i]!=NULL)
1208  {
1209  poly p=bucket->buckets[i];
1210  while(p!=NULL)
1211  {
1212  number t=n_SubringGcd(coef,pGetCoeff(p),cf);
1213  if (n_Size(t,cf)<2)
1214  {
1215  n_Delete(&t,cf);
1216  n_Delete(&coef,cf);
1217  return;
1218  }
1219  pIter(p);
1220  }
1221  }
1222  }
1223  // divided by the gcd
1224  if (TEST_OPT_PROT) PrintS("@");
1225  for (int i=bucket->buckets_used;i>=0;i--)
1226  {
1227  if (bucket->buckets[i]!=NULL)
1228  {
1229  poly p=bucket->buckets[i];
1230  while(p!=NULL)
1231  {
1232  number d = n_ExactDiv(pGetCoeff(p),coef,cf);
1233  p_SetCoeff(p,d,r);
1234  pIter(p);
1235  }
1236  }
1237  }
1238  n_Delete(&coef,cf);
1239 }
number ndGcd(number, number, const coeffs r)
Definition: numbers.cc:161
#define TEST_OPT_PROT
Definition: options.h:102
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
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
#define pIter(p)
Definition: monomials.h:44
ring bucket_ring
Definition: kbuckets.h:189
The main handler for Singular numbers which are suitable for Singular polynomials.
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
number p_InitContent(poly ph, const ring r)
Definition: p_polys.cc:2549
CanonicalForm cf
Definition: cfModGcd.cc:4024
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
static FORCE_INLINE number n_ExactDiv(number a, number b, const coeffs r)
assume that there is a canonical subring in cf and we know that division is possible for these a and ...
Definition: coeffs.h:623
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:689
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
int p
Definition: cfModGcd.cc:4019
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:571

◆ kBucketTakeOutComp()

void kBucketTakeOutComp ( kBucket_pt  bucket,
long  comp,
poly *  r_p,
int *  l 
)

Definition at line 1020 of file kbuckets.cc.

1023 {
1024  poly p = NULL, q;
1025  int i, lp = 0, lq;
1026 
1027 #ifndef HAVE_PSEUDO_BUCKETS
1028  kBucketMergeLm(bucket);
1029  for (i=1; i<=bucket->buckets_used; i++)
1030  {
1031  if (bucket->buckets[i] != NULL)
1032  {
1033  MULTIPLY_BUCKET(bucket,i);
1034  p_TakeOutComp(&(bucket->buckets[i]), comp, &q, &lq, bucket->bucket_ring);
1035  if (q != NULL)
1036  {
1037  assume(pLength(q) == (unsigned)lq);
1038  bucket->buckets_length[i] -= lq;
1039  assume(pLength(bucket->buckets[i]) == (unsigned)bucket->buckets_length[i]);
1040  p = p_Add_q(p, q, lp, lq, bucket->bucket_ring);
1041  }
1042  }
1043  }
1044  kBucketAdjustBucketsUsed(bucket);
1045 #else
1046  p_TakeOutComp(&(bucket->p), comp, &p, &lp,bucket->bucket_ring);
1047  (bucket->l) -= lp;
1048 #endif
1049  *r_p = p;
1050  *l = lp;
1051 
1052  kbTest(bucket);
1053 }
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition: kbuckets.cc:194
#define MULTIPLY_BUCKET(B, I)
Definition: kbuckets.cc:40
void p_TakeOutComp(poly *p, long comp, poly *q, int *lq, const ring r)
Definition: p_polys.cc:3446
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
ring bucket_ring
Definition: kbuckets.h:189
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define NULL
Definition: omList.c:10
int l
Definition: kbuckets.h:180
poly p
Definition: kbuckets.h:179
Definition: lq.h:39
int p
Definition: cfModGcd.cc:4019
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
int l
Definition: cfEzgcd.cc:93

◆ ksCheckCoeff() [1/2]

int ksCheckCoeff ( number *  a,
number *  b 
)

◆ ksCheckCoeff() [2/2]

int ksCheckCoeff ( number *  a,
number *  b,
const coeffs  r 
)

Definition at line 1383 of file kbuckets.cc.

1384 {
1385  int c = 0;
1386  number an = *a, bn = *b;
1387  n_Test(an,r);
1388  n_Test(bn,r);
1389 
1390  number cn = n_SubringGcd(an, bn, r);
1391 
1392  if(n_IsOne(cn, r))
1393  {
1394  an = n_Copy(an, r);
1395  bn = n_Copy(bn, r);
1396  }
1397  else
1398  {
1399  an = n_ExactDiv(an, cn, r); n_Normalize(an,r);
1400  bn = n_ExactDiv(bn, cn, r); n_Normalize(bn,r);
1401  }
1402  n_Delete(&cn, r);
1403  if (n_IsOne(an, r))
1404  {
1405  c = 1;
1406  }
1407  if (n_IsOne(bn, r))
1408  {
1409  c += 2;
1410  }
1411  *a = an;
1412  *b = bn;
1413  return c;
1414 }
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
CanonicalForm b
Definition: cfModGcd.cc:4044
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:739
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
static FORCE_INLINE number n_ExactDiv(number a, number b, const coeffs r)
assume that there is a canonical subring in cf and we know that division is possible for these a and ...
Definition: coeffs.h:623
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:689
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456

◆ LOG4()

static int LOG4 ( int  v)
inlinestatic

Some internal stuff.

Definition at line 53 of file kbuckets.cc.

54 {
55  const unsigned int b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
56  const unsigned int S[] = {1, 2, 4, 8, 16};
57 
58  unsigned int r = 0; // result of log4(v) will go here
59  if (v & b[4]) { v >>= S[4]; r |= S[3]; }
60  if (v & b[3]) { v >>= S[3]; r |= S[2]; }
61  if (v & b[2]) { v >>= S[2]; r |= S[1]; }
62  if (v & b[1]) { v >>= S[1]; r |= S[0]; }
63  return (int)r;
64 }
CanonicalForm b
Definition: cfModGcd.cc:4044
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

◆ p_TakeOutComp()

void p_TakeOutComp ( poly *  p,
long  comp,
poly *  q,
int *  lq,
const ring  r 
)

Definition at line 3446 of file p_polys.cc.

3447 {
3448  spolyrec pp, qq;
3449  poly p, q, p_prev;
3450  int l = 0;
3451 
3452 #ifndef SING_NDEBUG
3453  int lp = pLength(*r_p);
3454 #endif
3455 
3456  pNext(&pp) = *r_p;
3457  p = *r_p;
3458  p_prev = &pp;
3459  q = &qq;
3460 
3461  while(p != NULL)
3462  {
3463  while (__p_GetComp(p,r) == comp)
3464  {
3465  pNext(q) = p;
3466  pIter(q);
3467  p_SetComp(p, 0,r);
3468  p_SetmComp(p,r);
3469  pIter(p);
3470  l++;
3471  if (p == NULL)
3472  {
3473  pNext(p_prev) = NULL;
3474  goto Finish;
3475  }
3476  }
3477  pNext(p_prev) = p;
3478  p_prev = p;
3479  pIter(p);
3480  }
3481 
3482  Finish:
3483  pNext(q) = NULL;
3484  *r_p = pNext(&pp);
3485  *r_q = pNext(&qq);
3486  *lq = l;
3487 #ifndef SING_NDEBUG
3488  assume(pLength(*r_p) + pLength(*r_q) == lp);
3489 #endif
3490  p_Test(*r_p,r);
3491  p_Test(*r_q,r);
3492 }
#define __p_GetComp(p, r)
Definition: monomials.h:70
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#define pIter(p)
Definition: monomials.h:44
#define assume(x)
Definition: mod2.h:390
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
static unsigned pLength(poly a)
Definition: p_polys.h:192
#define p_Test(p, r)
Definition: p_polys.h:163
#define p_SetmComp
Definition: p_polys.h:244
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
Definition: lq.h:39
int p
Definition: cfModGcd.cc:4019
int l
Definition: cfEzgcd.cc:93

◆ pLogLength() [1/2]

static unsigned int pLogLength ( unsigned int  l)
inlinestatic

Definition at line 68 of file kbuckets.cc.

69 {
70  unsigned int i = 0;
71 
72  if (l == 0) return 0;
73  l--;
74 #ifdef BUCKET_TWO_BASE
75  i=SI_LOG2(l);
76 #else
77  i=LOG4(l);
78 #endif
79  return i+1;
80 }
static int LOG4(int v)
Some internal stuff.
Definition: kbuckets.cc:53
int i
Definition: cfEzgcd.cc:125
static int SI_LOG2(int v)
Definition: auxiliary.h:119
int l
Definition: cfEzgcd.cc:93

◆ pLogLength() [2/2]

static unsigned int pLogLength ( poly  p)
inlinestatic

Definition at line 83 of file kbuckets.cc.

84 {
85  return pLogLength((unsigned int) pLength(p));
86 }
static unsigned pLength(poly a)
Definition: p_polys.h:192
static unsigned int pLogLength(unsigned int l)
Definition: kbuckets.cc:68
int p
Definition: cfModGcd.cc:4019

Variable Documentation

◆ kBucket_bin

omBin kBucket_bin = omGetSpecBin(sizeof(kBucket))
static

Definition at line 42 of file kbuckets.cc.