30#define TEST_OPT_DEBUG_RED
52#ifdef TEST_OPT_DEBUG_RED
63 ring tailRing = PR->tailRing;
69 poly p1 = PR->GetLmTailRing();
70 poly p2 = PW->GetLmTailRing();
71 poly t2 =
pNext(p2), lm = p1;
92 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
95 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
111 if ((ct == 0) || (ct == 2))
112 PR->Tail_Mult_nn(an);
113 if (coef !=
NULL) *coef = an;
116 PR->LmDeleteAndIter();
117 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
130 if (strat ==
NULL)
return 2;
133 p1 = PR->GetLmTailRing();
134 p2 = PW->GetLmTailRing();
144 if (tailRing->isLPring)
159 if ((ct == 0) || (ct == 2))
160 PR->Tail_Mult_nn(an);
161 if (coef !=
NULL) *coef = an;
166 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
172 if (tailRing->isLPring)
174 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
179 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
182 PR->LmDeleteAndIter();
196#ifdef TEST_OPT_DEBUG_RED
207 ring tailRing = PR->tailRing;
214 poly p1 = PR->GetLmTailRing();
215 poly p2 = PW->GetLmTailRing();
216 poly t2 =
pNext(p2), lm = p1;
237 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
240 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
249 PR->LmDeleteAndIter();
250 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
263 if (strat ==
NULL)
return 2;
266 p1 = PR->GetLmTailRing();
267 p2 = PW->GetLmTailRing();
277 if (tailRing->isLPring)
292 if ((ct == 0) || (ct == 2))
293 PR->Tail_Mult_nn(an);
294 if (coef !=
NULL) *coef = an;
299 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
305 if (tailRing->isLPring)
307 poly tmp=tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing);
308 PR->Tail_Minus_mm_Mult_qq(lm, tmp,
pLength(t2), spNoether);
316 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
319 PR->LmDeleteAndIter();
333#ifdef TEST_OPT_DEBUG_RED
344 ring tailRing = PR->tailRing;
351 poly p1 = PR->GetLmTailRing();
352 poly p2 = PW->GetLmTailRing();
374 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
377 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
388 if (strat ==
NULL)
return 2;
391 p1 = PR->GetLmTailRing();
392 p2 = PW->GetLmTailRing();
401 if (tailRing->isLPring)
425 PR->Tail_Mult_nn(an);
429 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
435 if (tailRing->isLPring)
437 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
442 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
466#ifdef TEST_OPT_DEBUG_RED
479 ring tailRing = PR->tailRing;
486 poly p1 = PR->GetLmTailRing();
487 poly p2 = PW->GetLmTailRing();
488 poly t2 =
pNext(p2), lm = p1;
509 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
512 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
525 if (strat ==
NULL)
return 2;
528 p1 = PR->GetLmTailRing();
529 p2 = PW->GetLmTailRing();
538 if (tailRing->isLPring)
548 if (tailRing->isLPring)
550 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(p2, lmRight, tailRing),
pLength(p2), spNoether);
555 PR->Tail_Minus_mm_Mult_qq(lm, p2,
pLength(p2) , spNoether);
559 PR->LmDeleteAndIter();
562#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
581#ifdef TEST_OPT_DEBUG_RED
592 ring tailRing = PR->tailRing;
599 poly p1 = PR->GetLmTailRing();
600 poly p2 = PW->GetLmTailRing();
601 poly t2 =
pNext(p2), lm = p1;
622 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
625 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
634 PR->LmDeleteAndIter();
635 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
648 if (strat ==
NULL)
return 2;
651 p1 = PR->GetLmTailRing();
652 p2 = PW->GetLmTailRing();
662 if (tailRing->isLPring)
677 if ((ct == 0) || (ct == 2))
678 PR->Tail_Mult_nn(an);
679 if (coef !=
NULL) *coef = an;
684 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
690 if (tailRing->isLPring)
692 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
697 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
700 PR->LmDeleteAndIter();
702#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
728#ifdef TEST_OPT_DEBUG_RED
737 ring tailRing = PR->tailRing;
774 poly sigMult =
pCopy(PW->sig);
777 printf(
"IN KSREDUCEPOLYSIG: \n");
781 printf(
"--------------\n");
786 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
791 printf(
"--------------\n");
798 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
807 PR->is_redundant =
TRUE;
812 PR->is_redundant =
FALSE;
813 poly p1 = PR->GetLmTailRing();
814 poly p2 = PW->GetLmTailRing();
815 poly t2 =
pNext(p2), lm = p1;
836 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
839 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
848 PR->LmDeleteAndIter();
849 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
862 if (strat ==
NULL)
return 2;
865 p1 = PR->GetLmTailRing();
866 p2 = PW->GetLmTailRing();
876 if (tailRing->isLPring)
891 if ((ct == 0) || (ct == 2))
892 PR->Tail_Mult_nn(an);
893 if (coef !=
NULL) *coef = an;
898 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
904 if (tailRing->isLPring)
906 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
911 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
914 PR->LmDeleteAndIter();
916#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
934#ifdef TEST_OPT_DEBUG_RED
943 ring tailRing = PR->tailRing;
980 poly sigMult =
pCopy(PW->sig);
983 printf(
"IN KSREDUCEPOLYSIG: \n");
987 printf(
"--------------\n");
1001 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
1006 printf(
"--------------\n");
1015 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
1021 poly origsig =
pCopy(PR->sig);
1023 PR->sig =
pHead(
pSub(PR->sig, sigMult));
1032 if(
pLtCmp(PR->sig,origsig) == 1)
1036 PR->is_redundant =
TRUE;
1042 if(
pLtCmp(PR->sig,origsig) == -1)
1054 PR->is_redundant =
TRUE;
1059 PR->is_redundant =
FALSE;
1060 poly p1 = PR->GetLmTailRing();
1061 poly p2 = PW->GetLmTailRing();
1062 poly t2 =
pNext(p2), lm = p1;
1083 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
1086 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
1095 PR->LmDeleteAndIter();
1096 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1109 if (strat ==
NULL)
return 2;
1112 p1 = PR->GetLmTailRing();
1113 p2 = PW->GetLmTailRing();
1123 if (tailRing->isLPring)
1135 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1145 if (((ct == 0) || (ct == 2)))
1146 PR->Tail_Mult_nn(an);
1147 if (coef !=
NULL) *coef = an;
1152 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1158 if (tailRing->isLPring)
1160 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
1165 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
1168 PR->LmDeleteAndIter();
1170#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
1186 int use_buckets, ring tailRing,
1194 Pair->tailRing = tailRing;
1231 if (tailRing->isLPring)
1245 if (Pair->i_r1 == -1)
1251 l1 = (
R[Pair->i_r1])->GetpLength() - 1;
1253 if ((Pair->i_r2 == -1)||(
R[Pair->i_r2]==
NULL))
1259 l2 = (
R[Pair->i_r2])->GetpLength() - 1;
1265 if (tailRing->isLPring)
1268 poly tmp= tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing);
1269 a2 = tailRing->p_Procs->pp_Mult_mm(tmp, m22, tailRing);
1274 if (spNoether !=
NULL)
1277 a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
1282 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
1288 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
1291 if (tailRing->isLPring)
1294 poly tmp=tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing);
1295 Pair->Tail_Minus_mm_Mult_qq(m1, tmp, l1, spNoether);
1302 Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
1306 Pair->LmDeleteAndIter();
1309 if (tailRing->isLPring)
1312 assume(Pair->shift == 0);
1338 poly Lp = PR->GetLmCurrRing();
1339 poly Save = PW->GetLmCurrRing();
1357 if (Current == PR->p && PR->t_p !=
NULL)
1363 pNext(Current) = Red.GetLmTailRing();
1364 if (Current == PR->p && PR->t_p !=
NULL)
1378 poly Lp = PR->GetLmCurrRing();
1379 poly Save = PW->GetLmCurrRing();
1397 if (Current == PR->p && PR->t_p !=
NULL)
1403 pNext(Current) = Red.GetLmTailRing();
1404 if (Current == PR->p && PR->t_p !=
NULL)
1435 if (tailRing->isLPring)
1477 if (tailRing->isLPring)
1501 if ((c1==c2)||(c2!=0))
1520 if (tailRing->isLPring && (shift2!=0))
1557 if ((c1==c2)||(c1!=0))
1576 if (tailRing->isLPring && (shift1!=0))
1637 if (tailRing->isLPring)
1658 if (tailRing->isLPring)
1695 if (tailRing->isLPring)
1739 if (tailRing->isLPring)
static int si_max(const int a, const int b)
static CanonicalForm bound(const CFMatrix &M)
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)
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
int ksCheckCoeff(number *a, number *b)
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat)
int ksReducePolyTail(LObject *PR, TObject *PW, poly Current, poly spNoether)
int ksReducePolyTailBound(LObject *PR, TObject *PW, int bound, poly Current, poly spNoether)
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
int ksReducePolyBound(LObject *PR, TObject *PW, int, poly spNoether, number *coef, kStrategy strat)
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
int ksReducePolyZ(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
int ksReducePolyGCD(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
BOOLEAN kTest_L(LObject *L, kStrategy strat, BOOLEAN testp, int lpos, TSet T, int tlength)
BOOLEAN kTest_T(TObject *T, kStrategy strat, int i, char TN)
void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r)
static void nc_kBucketPolyRed_Z(kBucket_pt b, poly p, number *c)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
#define __p_GetComp(p, r)
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
static void p_LmDelete(poly p, const ring r)
BOOLEAN pIsMonomOf(poly p, poly m)
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
static void p_SetCompP(poly p, int i, ring r)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
static void p_Setm(poly p, const ring r)
static number p_SetCoeff(poly p, number n, ring r)
static int p_LmCmp(poly p, poly q, const ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
static void p_Delete(poly *p, const ring r)
static unsigned pLength(poly a)
BOOLEAN p_CheckPolyRing(poly p, ring r)
static void p_LmFree(poly p, ring)
static poly p_Init(const ring r, omBin bin)
BOOLEAN pHaveCommonMonoms(poly p, poly q)
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
static void p_ExpVectorAddSub(poly p1, poly p2, poly p3, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatiblity layer for legacy polynomial operations (over currRing)
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
#define pCopy(p)
return a copy of the poly
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
static BOOLEAN rField_is_Domain(const ring r)
#define rField_is_Ring(R)
poly p_LPCopyAndShiftLM(poly p, int sh, const ring r)
int p_mFirstVblock(poly p, const ring ri)
int p_FirstVblock(poly p, const ring r)
void k_SplitFrame(poly &m1, poly &m2, int at, const ring r)