14 int s = p_LmCmp(one,t,r);
26 number commonGcdCache = n_Gcd(commonGcd,
p_GetCoeff(gCache,r),r->cf);
27 n_Delete(&commonGcd,r->cf);
28 commonGcd = commonGcdCache;
29 if (n_IsOne(commonGcd,r->cf))
31 n_Delete(&commonGcd,r->cf);
35 for (poly gCache=
g; gCache;
pIter(gCache))
38 number newCoeff = n_Div(oldCoeff,commonGcd,r->cf);
39 p_SetCoeff(gCache,newCoeff,r);
42 n_Delete(&commonGcd,r->cf);
60 poly toBeChecked =
pNext(
g);
67 for (gCache =
g; gCache;
pIter(gCache))
68 if (p_LeadmonomDivisibleBy(gCache,toBeChecked,r))
break;
71 n_Power(
p,p_GetExp(toBeChecked,1,r)-p_GetExp(gCache,1,r),&
pPower,r->cf);
73 p_SetCoeff(gCache,n_Add(
p_GetCoeff(gCache,r),coeff,r->cf),r);
74 n_Delete(&
pPower,r->cf); n_Delete(&coeff,r->cf);
75 toBeChecked=p_LmDeleteAndNext(toBeChecked,r);
83 while (n_DivBy(coeff,
p,r->cf))
86 number coeff0 = n_Div(coeff,
p,r->cf);
87 n_Delete(&coeff,r->cf);
92 WerrorS(
"pReduce: overflow in exponent");
96 subst=p_LmInit(toBeChecked,r);
98 p_SetCoeff(
subst,coeff,r);
100 toBeChecked=p_LmDeleteAndNext(toBeChecked,r);
101 toBeChecked=p_Add_q(toBeChecked,
subst,r);
106 pNext(gEnd)=toBeChecked;
120 poly gx = p_Head(
g,r);
121 poly fx = p_Head(
f,r);
126 bool b = p_LeadmonomDivisibleBy(gx,fx,r);
138 poly toBeChecked =
pNext(
g);
145 for (gCache =
g; gCache;
pIter(gCache))
149 n_Power(
p,p_GetExp(toBeChecked,1,r)-p_GetExp(gCache,1,r),&
pPower,r->cf);
151 p_SetCoeff(gCache,n_Add(
p_GetCoeff(gCache,r),coeff,r->cf),r);
152 n_Delete(&
pPower,r->cf); n_Delete(&coeff,r->cf);
153 toBeChecked=p_LmDeleteAndNext(toBeChecked,r);
161 while (n_DivBy(coeff,
p,r->cf))
164 number coeff0 = n_Div(coeff,
p,r->cf);
165 n_Delete(&coeff,r->cf);
170 WerrorS(
"pReduce: overflow in exponent");
174 subst=p_LmInit(toBeChecked,r);
176 p_SetCoeff(
subst,coeff,r);
178 toBeChecked=p_LmDeleteAndNext(toBeChecked,r);
179 toBeChecked=p_Add_q(toBeChecked,
subst,r);
184 pNext(gEnd)=toBeChecked;
205 p_SetCoeff(pt,n_Copy(
p,r->cf),r);
207 pNext(pt) = p_Init(r);
208 p_SetExp(
pNext(pt),1,1,r);
210 p_SetCoeff(
pNext(pt),n_Init(-1,r->cf),r);
218 poly
m = p_Head(
g,r);
219 p_SetCoeff(
m,n_Init(1,r->cf),r);
220 g = p_Add_q(p_Mult_nn(
g,a,r),p_Mult_nn(p_Mult_mm(pt,
m,r),
b,r),r);
223 n_Delete(&
gcd,r->cf);
250 ideal I = (ideal) u->
CopyD();
251 number
p = (number)
v->CopyD();
255 res->data = (
char*) I;
263void pReduce(ideal &I,
const number
p,
const ring r)
266 for (
int i=0;
i<
k;
i++)
271 if (!n_DivBy(
p,c,r->cf))
292 for (hCache=
h; hCache;
pIter(hCache))
293 if (p_LeadmonomDivisibleBy(
g,hCache,r))
break;
297 poly hAlphaT = p_Init(r);
298 p_SetCoeff(hAlphaT,n_Copy(
p_GetCoeff(hCache,r),r->cf),r);
299 p_SetExp(hAlphaT,1,p_GetExp(hCache,1,r)-p_GetExp(
g,1,r),r);
300 for (
int i=2;
i<=r->N;
i++)
301 p_SetExp(hAlphaT,
i,0,r);
302 p_Setm(hAlphaT,r);
p_Test(hAlphaT,r);
303 poly q1 = p_Mult_nn(
h,gAlpha,r);
p_Test(q1,r);
304 poly q2 = p_Mult_q(p_Copy(
g,r),hAlphaT,r);
p_Test(q2,r);
305 q2 = p_Neg(q2,r);
p_Test(q2,r);
306 h = p_Add_q(q1,q2,r);
330 for (
int i=1;
i<n;
i++)
332 if (p_LmCmp(I->m[
i-1],I->m[
i],r)<0)
342 for (
int i=0;
i<
m;
i++)
348 for (
int i=0;
i<
m-1;
i++)
349 for (
int j=
i+1;
j<
m;
j++)
356 for (
int i=0;
i<
m-1;
i++)
357 for (
int j=
i+1;
j<
m;
j++)
382 for (
j=n-1;
j>0;
j--)
384 if (p_LmCmp(I->m[
j], I->m[
j-1],r)>0)
386 poly cache = I->m[
j];
398 for (
int i=0;
i<
j;
i++)
401 for (
int k=
j+1;
k<n;
k++)
405 for (
int l=
j+1;
l<
k;
l++)
414 for (
int i=0;
i<
j;
i++)
415 for (
int k=
j;
k<n;
k++)
418 for (
int k=
j;
k<n-1;
k++)
419 for (
int l=
k+1;
l<n;
l++)
435 for (
int i=0;
i<
l;
i++)
445static void sortMarks(
const ideal
H,
const ring r, std::vector<mark> &
T)
447 std::pair<int,int> pointerToTerm;
452 for (
int i=1;
i<
k-1;
i++)
454 int generatorA =
T[
i-1].first;
455 int termA =
T[
i-1].second;
456 int generatorB =
T[
i].first;
457 int termB =
T[
i].second;
458 if (p_LmCmp(
ppNext(
H->m[generatorA],termA),
ppNext(
H->m[generatorB],termB),r)<0)
482 for (
unsigned i=0;
i<
T.size();
i++)
484 if (
T[
i].first>=newEntry)
485 T[
i].first =
T[
i].first+1;
493 for (
unsigned i=0;
i<
T.size();)
496 T.erase(
T.begin()+
i);
529 for (
int i=0;
i<
m;
i++)
535 T.push_back(std::pair<int,int>(
i,1));
552 if (p_LeadmonomDivisibleBy(
G->m[
i],
getTerm(I,
T[0]),r))
break;
559 for (
int j=2;
j<=r->N;
j++)
560 p_SetExp(
g,
j,p_GetExp(
h0,
j,r)-p_GetExp(
G->m[
i],
j,r),r);
562 g = p_Mult_q(
g,p_Copy(
G->m[
i],r),r);
567 T[0].second =
T[0].second+1;
575 for (
int i=0;
i<
k;
i++)
579 for (
int j=0;
j<
m;
j++)
582 && (p_LeadmonomDivisibleBy(
H->m[
j],I->m[
i],r)))
607 std::map<long,ideal>
H;
int n =
IDELEMS(I);
608 for (
int i=0;
i<n;
i++)
614 for (
int j=2;
j<=r->N;
j++)
615 d += p_GetExp(I->m[
i],
j,r);
616 std::map<long,ideal>::iterator it =
H.find(d);
621 std::pair<long,ideal> Hd(d,
idInit(1));
622 Hd.second->m[0] = I->m[
i];
628 std::map<long,ideal>::iterator it=
H.begin();
629 ideal Hi = it->second;
630 idShallowDelete(&Hi);
647 for (it++; it!=
H.end(); it++)
657 for (
int i=1;
i<
k;
i++)
659 if (p_GetExp(Hi->m[
i-1],1,r)<p_GetExp(Hi->m[
i],1,r))
670 for (
int i=n-
m-
l;
i<n;
i++)
674 memcpy(&(
G->m[
i]),&(Hi->m[kH]),(n-
i)*
sizeof(poly));
679 if (p_GetExp(
G->m[kG],1,r)>p_GetExp(Hi->m[kH],1,r))
680 G->m[
i] =
G->m[kG++];
682 G->m[
i] = Hi->m[kH++];
690 idShallowDelete(&Hi); Hi = it->second;
692 idShallowDelete(&Hi);
const CanonicalForm int s
CanonicalForm subst(const CanonicalForm &f, const CFList &a, const CFList &b, const CanonicalForm &Rstar, bool isFunctionField)
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
#define omFreeBin(addr, bin)
poly p_Cleardenom(poly p, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void pReduceInhomogeneous(poly &g, const number p, const ring r)
void ptNormalize(poly *gStar, const number p, const ring r)
static poly ppNext(poly p, int l)
static void cleanupMarks(const ideal H, std::vector< mark > &T)
bool isOrderingLocalInT(const ring r)
void pReduce(poly &g, const number p, const ring r)
static poly getTerm(const ideal H, const mark ab)
void divideByCommonGcd(poly &g, const ring r)
static void adjustMarks(std::vector< mark > &T, const int newEntry)
static void sortMarks(const ideal H, const ring r, std::vector< mark > &T)
bool ppreduceInitially(poly *hStar, const poly g, const ring r)
reduces h initially with respect to g, returns false if h was initially reduced in the first place,...
bool p_xLeadmonomDivisibleBy(const poly g, const poly f, const ring r)
std::pair< int, int > mark
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size