30#define TEST_OPT_DEBUG_RED
44#ifdef STDZ_EXCHANGE_DURING_REDUCTION
53#ifdef TEST_OPT_DEBUG_RED
64 ring tailRing = PR->tailRing;
70 poly p1 = PR->GetLmTailRing();
71 poly p2 = PW->GetLmTailRing();
72 poly t2 =
pNext(p2), lm = p1;
93 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
96 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
112 if ((ct == 0) || (ct == 2))
113 PR->Tail_Mult_nn(an);
114 if (coef !=
NULL) *coef = an;
117 PR->LmDeleteAndIter();
118 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
131 if (strat ==
NULL)
return 2;
134 p1 = PR->GetLmTailRing();
135 p2 = PW->GetLmTailRing();
145 if (tailRing->isLPring)
160 if ((ct == 0) || (ct == 2))
161 PR->Tail_Mult_nn(an);
162 if (coef !=
NULL) *coef = an;
167 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
173 if (tailRing->isLPring)
175 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
180 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
183 PR->LmDeleteAndIter();
199#ifdef TEST_OPT_DEBUG_RED
210 ring tailRing = PR->tailRing;
217 poly p1 = PR->GetLmTailRing();
218 poly p2 = PW->GetLmTailRing();
219 poly t2 =
pNext(p2), lm = p1;
240 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
243 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
252 PR->LmDeleteAndIter();
253 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
266 if (strat ==
NULL)
return 2;
269 p1 = PR->GetLmTailRing();
270 p2 = PW->GetLmTailRing();
280 if (tailRing->isLPring)
303 else if(!
n_IsOne(an,tailRing->cf))
313 if ((ct == 0) || (ct == 2))
314 PR->Tail_Mult_nn(an);
315 if (coef !=
NULL) *coef = an;
320 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
326 if (tailRing->isLPring)
328 poly tmp=tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing);
329 PR->Tail_Minus_mm_Mult_qq(lm, tmp,
pLength(t2), spNoether);
337 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
340 PR->LmDeleteAndIter();
346#ifdef STDZ_EXCHANGE_DURING_REDUCTION
355#ifdef TEST_OPT_DEBUG_RED
366 ring tailRing = PR->tailRing;
373 poly p1 = PR->GetLmTailRing();
374 poly p2 = PW->GetLmTailRing();
396 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
399 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
410 if (strat ==
NULL)
return 2;
413 p1 = PR->GetLmTailRing();
414 p2 = PW->GetLmTailRing();
423 if (tailRing->isLPring)
447 PR->Tail_Mult_nn(an);
451 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
457 if (tailRing->isLPring)
459 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
464 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
489#ifdef TEST_OPT_DEBUG_RED
502 ring tailRing = PR->tailRing;
509 poly p1 = PR->GetLmTailRing();
510 poly p2 = PW->GetLmTailRing();
511 poly t2 =
pNext(p2), lm = p1;
532 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
535 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
548 if (strat ==
NULL)
return 2;
551 p1 = PR->GetLmTailRing();
552 p2 = PW->GetLmTailRing();
561 if (tailRing->isLPring)
571 if (tailRing->isLPring)
573 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(p2, lmRight, tailRing),
pLength(p2), spNoether);
578 PR->Tail_Minus_mm_Mult_qq(lm, p2,
pLength(p2) , spNoether);
582 PR->LmDeleteAndIter();
585#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
604#ifdef TEST_OPT_DEBUG_RED
615 ring tailRing = PR->tailRing;
622 poly p1 = PR->GetLmTailRing();
623 poly p2 = PW->GetLmTailRing();
624 poly t2 =
pNext(p2), lm = p1;
645 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
648 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
657 PR->LmDeleteAndIter();
658 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
671 if (strat ==
NULL)
return 2;
674 p1 = PR->GetLmTailRing();
675 p2 = PW->GetLmTailRing();
685 if (tailRing->isLPring)
700 if ((ct == 0) || (ct == 2))
701 PR->Tail_Mult_nn(an);
702 if (coef !=
NULL) *coef = an;
707 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
713 if (tailRing->isLPring)
715 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
720 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
723 PR->LmDeleteAndIter();
725#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
751#ifdef TEST_OPT_DEBUG_RED
760 ring tailRing = PR->tailRing;
797 poly sigMult =
pCopy(PW->sig);
800 printf(
"IN KSREDUCEPOLYSIG: \n");
804 printf(
"--------------\n");
809 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
814 printf(
"--------------\n");
821 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
830 PR->is_redundant =
TRUE;
835 PR->is_redundant =
FALSE;
836 poly p1 = PR->GetLmTailRing();
837 poly p2 = PW->GetLmTailRing();
838 poly t2 =
pNext(p2), lm = p1;
859 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
862 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
871 PR->LmDeleteAndIter();
872 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
885 if (strat ==
NULL)
return 2;
888 p1 = PR->GetLmTailRing();
889 p2 = PW->GetLmTailRing();
899 if (tailRing->isLPring)
914 if ((ct == 0) || (ct == 2))
915 PR->Tail_Mult_nn(an);
916 if (coef !=
NULL) *coef = an;
921 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
927 if (tailRing->isLPring)
929 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
934 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
937 PR->LmDeleteAndIter();
939#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
957#ifdef TEST_OPT_DEBUG_RED
966 ring tailRing = PR->tailRing;
1001 if (!PW->is_sigsafe)
1003 poly sigMult =
pCopy(PW->sig);
1006 printf(
"IN KSREDUCEPOLYSIG: \n");
1010 printf(
"--------------\n");
1024 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
1029 printf(
"--------------\n");
1038 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
1044 poly origsig =
pCopy(PR->sig);
1046 PR->sig =
pHead(
pSub(PR->sig, sigMult));
1055 if(
pLtCmp(PR->sig,origsig) == 1)
1059 PR->is_redundant =
TRUE;
1065 if(
pLtCmp(PR->sig,origsig) == -1)
1077 PR->is_redundant =
TRUE;
1082 PR->is_redundant =
FALSE;
1083 poly p1 = PR->GetLmTailRing();
1084 poly p2 = PW->GetLmTailRing();
1085 poly t2 =
pNext(p2), lm = p1;
1106 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
1109 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
1118 PR->LmDeleteAndIter();
1119 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1132 if (strat ==
NULL)
return 2;
1135 p1 = PR->GetLmTailRing();
1136 p2 = PW->GetLmTailRing();
1146 if (tailRing->isLPring)
1158 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1168 if (((ct == 0) || (ct == 2)))
1169 PR->Tail_Mult_nn(an);
1170 if (coef !=
NULL) *coef = an;
1175 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1181 if (tailRing->isLPring)
1183 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
1188 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
1191 PR->LmDeleteAndIter();
1193#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
1209 int use_buckets, ring tailRing,
1217 Pair->tailRing = tailRing;
1254 if (tailRing->isLPring)
1268 if (Pair->i_r1 == -1)
1274 l1 = (
R[Pair->i_r1])->GetpLength() - 1;
1276 if ((Pair->i_r2 == -1)||(
R[Pair->i_r2]==
NULL))
1282 l2 = (
R[Pair->i_r2])->GetpLength() - 1;
1288 if (tailRing->isLPring)
1291 poly tmp= tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing);
1292 a2 = tailRing->p_Procs->pp_Mult_mm(tmp, m22, tailRing);
1297 if (spNoether !=
NULL)
1300 a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
1305 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
1311 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
1314 if (tailRing->isLPring)
1317 poly tmp=tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing);
1318 Pair->Tail_Minus_mm_Mult_qq(m1, tmp, l1, spNoether);
1325 Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
1329 Pair->LmDeleteAndIter();
1332 if (tailRing->isLPring)
1335 assume(Pair->shift == 0);
1361 poly Lp = PR->GetLmCurrRing();
1362 poly Save = PW->GetLmCurrRing();
1380 if (Current == PR->p && PR->t_p !=
NULL)
1386 pNext(Current) = Red.GetLmTailRing();
1387 if (Current == PR->p && PR->t_p !=
NULL)
1401 poly Lp = PR->GetLmCurrRing();
1402 poly Save = PW->GetLmCurrRing();
1420 if (Current == PR->p && PR->t_p !=
NULL)
1426 pNext(Current) = Red.GetLmTailRing();
1427 if (Current == PR->p && PR->t_p !=
NULL)
1458 if (tailRing->isLPring)
1500 if (tailRing->isLPring)
1524 if ((c1==c2)||(c2!=0))
1543 if (tailRing->isLPring && (shift2!=0))
1580 if ((c1==c2)||(c1!=0))
1599 if (tailRing->isLPring && (shift1!=0))
1660 if (tailRing->isLPring)
1681 if (tailRing->isLPring)
1718 if (tailRing->isLPring)
1762 if (tailRing->isLPring)
static int si_max(const int a, const int b)
static CanonicalForm bound(const CFMatrix &M)
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff 'n' represents the additive inverse of the one element, i.e. -1.
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 void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
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, const coeffs r)
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 ksReducePolyTail(LObject *PR, TObject *PW, poly Current, poly spNoether)
int ksReducePolyTailBound(LObject *PR, TObject *PW, int bound, poly Current, poly spNoether)
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, poly *mon, kStrategy strat, BOOLEAN reduce)
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)
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
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)
int ksReducePolyGCD(LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
int ksReducePolyZ(LObject *PR, TObject *PW, poly spNoether=NULL, number *coef=NULL, kStrategy strat=NULL)
static void nc_kBucketPolyRed_Z(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r)
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 int pLength(poly a)
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)
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 ...
Compatibility 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
void StringSetS(const char *st)
void StringAppendS(const char *st)
void PrintS(const char *s)
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)