Loading...
Searching...
No Matches
p_kBucketSetLm__T.cc
Go to the documentation of this file.
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/***************************************************************
* File: p_KBucketSetLm__Template.cc
* Purpose: template for setting the Lm of a bucket
* Author: obachman (Olaf Bachmann)
* Created: 12/00
*******************************************************************/
#undef USE_COEF_BUCKETS
#ifdef HAVE_COEF_BUCKETS
#define USE_COEF_BUCKETS
#endif
#ifdef USE_COEF_BUCKETS
#define MULTIPLY_BUCKET(B,I) do \
{ if (B->coef[I]!=NULL) \
{ \
B->buckets[I]=p_Mult_q(B->buckets[I],B->coef[I],B->bucket_ring); \
B->coef[I]=NULL; \
} \
} while(0)
#else
#define MULTIPLY_BUCKET(B,I)
#endif
#ifndef USE_COEF_BUCKETS
LINKAGE void p_kBucketSetLm__T(kBucket_pt bucket)
{
int j = 0;
poly lt;
ring r = bucket->bucket_ring;
assume(bucket->buckets[0] == NULL && bucket->buckets_length[0] == 0);
DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
DECLARE_ORDSGN(const long* ordsgn = r->ordsgn);
poly p;
do
{
j = 0;
for (int i = 1; i<=bucket->buckets_used; i++)
{
if (bucket->buckets[i] != NULL)
{
MULTIPLY_BUCKET(bucket,i);
p = bucket->buckets[j];
if (j == 0)
{
if (p != NULL) goto Greater;
j = i;
goto Continue;
}
assume(p != NULL);
p_MemCmp__T(bucket->buckets[i]->exp, p->exp, length, ordsgn, goto Equal, goto Greater, goto Continue);
Greater:
{
if (n_IsZero__T(pGetCoeff(p), r->cf))
{
n_Delete__T(&pGetCoeff(p), r->cf);
pIter(bucket->buckets[j]);
p_FreeBinAddr(p, r);
(bucket->buckets_length[j])--;
}
j = i;
goto Continue;
}
Equal:
{
MULTIPLY_BUCKET(bucket,i);
number tn = pGetCoeff(p);
#if 0
pSetCoeff0(p, n_Add__T(pGetCoeff(bucket->buckets[i]), tn, r->cf));
n_Delete__T(&tn, r->cf);
#else
n_InpAdd__T(tn,pGetCoeff(bucket->buckets[i]), r->cf);
pSetCoeff0(p, tn);
#endif
p = bucket->buckets[i];
pIter(bucket->buckets[i]);
n_Delete__T(&pGetCoeff(p), r->cf);
p_FreeBinAddr(p, r);
(bucket->buckets_length[i])--;
}
Continue:;
}
}
p = bucket->buckets[j];
if (j > 0 && n_IsZero__T(pGetCoeff(p), r->cf))
{
n_Delete__T(&pGetCoeff(p), r->cf);
pIter(bucket->buckets[j]);
p_FreeBinAddr(p, r);
(bucket->buckets_length[j])--;
j = -1;
}
}
while (j < 0);
if (j == 0)
{
return;
}
assume(bucket->buckets[j] != NULL);
lt = bucket->buckets[j];
bucket->buckets[j] = pNext(lt);
bucket->buckets_length[j]--;
pNext(lt) = NULL;
bucket->buckets[0] = lt;
bucket->buckets_length[0] = 1;
kBucketAdjustBucketsUsed(bucket);
}
#else
LINKAGE void p_kBucketSetLm__T(kBucket_pt bucket)
{
//int j = 0;
poly lt;
ring r = bucket->bucket_ring;
assume((bucket->buckets[0] == NULL) && (bucket->buckets_length[0] == 0) && (bucket->coef[0]==0));
DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
DECLARE_ORDSGN(const long* ordsgn = r->ordsgn);
poly p=NULL;
while(p==NULL)
{
int found=-1000;
for (int i = 1; i<=bucket->buckets_used; i++)
{
if (bucket->buckets[i] != NULL)
{
if (p == NULL)
{
p=bucket->buckets[i];
found=i;
continue;
}
assume(p != NULL);
p_MemCmp__T(bucket->buckets[i]->exp, p->exp, length, ordsgn, goto Continue, goto Greater, goto Continue);
//assume(p_LmCmp(bucket->buckets[i],p,r)==1);
Greater:
//if (p_LmCmp(bucket->buckets[i],p,r)!=1) continue;
found=i;
p=bucket->buckets[i];
Continue:;
}
}
if (found<0) return;
assume(p==bucket->buckets[found]);
assume(p!=NULL);
p=kBucketExtractLmOfBucket(bucket, found);
assume(p!=NULL);
p_Test(p,r);
poly copy=p_LmInit(p, r);
for (int i = found+1; i<=bucket->buckets_used; i++)
{
if (bucket->buckets[i] != NULL)
{
if(p_LmEqual(bucket->buckets[i], copy,r))
{
poly q=kBucketExtractLmOfBucket(bucket,i);
assume(p!=q);
p=p_Add_q(p, q,r);
assume(pLength(bucket->buckets[i])==bucket->buckets_length[i]);
}
}
}
p_Delete(&copy, r);
}
//assume(bucket->buckets[j] != NULL);
assume(pLength(lt)==1);
bucket->buckets[0] = lt;
bucket->buckets_length[0] = 1;
kBucketAdjustBucketsUsed(bucket);
kbTest(bucket);
}
#endif
i
int i
Definition cfEzgcd.cc:132
p
int p
Definition cfModGcd.cc:4086
found
bool found
Definition facFactorize.cc:55
copy
CFArray copy(const CFList &list)
write elements of list into an array
Definition facFqBivarUtil.cc:364
j
int j
Definition facHensel.cc:110
Equal
static BOOLEAN Equal(number a, number b, const coeffs)
Definition flintcf_Q.cc:381
Greater
static bool Greater(mono_type m1, mono_type m2)
Definition interpolation.cc:285
length
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
kbTest
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
Definition kbuckets.cc:197
kBucketExtractLmOfBucket
poly kBucketExtractLmOfBucket(kBucket_pt bucket, int i)
Definition kbuckets.cc:1455
kBucket::bucket_ring
ring bucket_ring
Definition kbuckets.h:196
assume
#define assume(x)
Definition mod2.h:389
LINKAGE
#define LINKAGE
Definition mod2.h:140
p_FreeBinAddr
#define p_FreeBinAddr(p, r)
Definition monomials.h:217
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
pSetCoeff0
#define pSetCoeff0(p, n)
Definition monomials.h:59
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
NULL
#define NULL
Definition omList.c:12
p_kBucketSetLm__T
LINKAGE void p_kBucketSetLm__T(kBucket_pt bucket)
Definition p_kBucketSetLm__T.cc:27
MULTIPLY_BUCKET
#define MULTIPLY_BUCKET(B, I)
Definition p_kBucketSetLm__T.cc:24
n_Delete__T
#define n_Delete__T(n, r)
Definition p_polys.cc:5042
pLength
static int pLength(poly a)
Definition p_polys.h:190
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
p_LmInit
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1356
p_LmEqual
#define p_LmEqual(p1, p2, r)
Definition p_polys.h:1744
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
p_Test
#define p_Test(p, r)
Definition p_polys.h:161
kBucket_pt
kBucket * kBucket_pt
Definition ring.h:26