28#define TEST_OPT_DEBUG_RED
42#ifdef STDZ_EXCHANGE_DURING_REDUCTION
51#ifdef TEST_OPT_DEBUG_RED
62 ring tailRing = PR->tailRing;
68 poly p1 = PR->GetLmTailRing();
69 poly p2 = PW->GetLmTailRing();
70 poly t2 =
pNext(p2), lm = p1;
91 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
94 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
110 if ((ct == 0) || (ct == 2))
111 PR->Tail_Mult_nn(an);
112 if (coef !=
NULL) *coef = an;
115 PR->LmDeleteAndIter();
116 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
129 if (strat ==
NULL)
return 2;
132 p1 = PR->GetLmTailRing();
133 p2 = PW->GetLmTailRing();
143 if (tailRing->isLPring)
158 if ((ct == 0) || (ct == 2))
159 PR->Tail_Mult_nn(an);
160 if (coef !=
NULL) *coef = an;
165 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
171 if (tailRing->isLPring)
173 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
178 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
181 PR->LmDeleteAndIter();
197#ifdef TEST_OPT_DEBUG_RED
208 ring tailRing = PR->tailRing;
215 poly p1 = PR->GetLmTailRing();
216 poly p2 = PW->GetLmTailRing();
217 poly t2 =
pNext(p2), lm = p1;
238 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
241 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
250 PR->LmDeleteAndIter();
251 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
264 if (strat ==
NULL)
return 2;
267 p1 = PR->GetLmTailRing();
268 p2 = PW->GetLmTailRing();
278 if (tailRing->isLPring)
301 else if(!
n_IsOne(an,tailRing->cf))
311 if ((ct == 0) || (ct == 2))
312 PR->Tail_Mult_nn(an);
313 if (coef !=
NULL) *coef = an;
318 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
324 if (tailRing->isLPring)
326 poly tmp=tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing);
327 PR->Tail_Minus_mm_Mult_qq(lm, tmp,
pLength(t2), spNoether);
335 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
338 PR->LmDeleteAndIter();
343#ifdef STDZ_EXCHANGE_DURING_REDUCTION
352#ifdef TEST_OPT_DEBUG_RED
363 ring tailRing = PR->tailRing;
370 poly p1 = PR->GetLmTailRing();
371 poly p2 = PW->GetLmTailRing();
393 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
396 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
407 if (strat ==
NULL)
return 2;
410 p1 = PR->GetLmTailRing();
411 p2 = PW->GetLmTailRing();
420 if (tailRing->isLPring)
444 PR->Tail_Mult_nn(an);
448 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
454 if (tailRing->isLPring)
456 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
461 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
485#ifdef TEST_OPT_DEBUG_RED
498 ring tailRing = PR->tailRing;
505 poly p1 = PR->GetLmTailRing();
506 poly p2 = PW->GetLmTailRing();
528 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
531 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
544 if (strat ==
NULL)
return 2;
547 p1 = PR->GetLmTailRing();
548 p2 = PW->GetLmTailRing();
556 if (tailRing->isLPring)
566 if (tailRing->isLPring)
568 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(p2, lmRight, tailRing),
pLength(p2), spNoether);
573 PR->Tail_Minus_mm_Mult_qq(lm, p2,
pLength(p2) , spNoether);
577 PR->LmDeleteAndIter();
580#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
599#ifdef TEST_OPT_DEBUG_RED
610 ring tailRing = PR->tailRing;
617 poly p1 = PR->GetLmTailRing();
618 poly p2 = PW->GetLmTailRing();
619 poly t2 =
pNext(p2), lm = p1;
640 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
643 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
652 PR->LmDeleteAndIter();
653 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
666 if (strat ==
NULL)
return 2;
669 p1 = PR->GetLmTailRing();
670 p2 = PW->GetLmTailRing();
680 if (tailRing->isLPring)
695 if ((ct == 0) || (ct == 2))
696 PR->Tail_Mult_nn(an);
697 if (coef !=
NULL) *coef = an;
702 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
708 if (tailRing->isLPring)
710 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
715 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
718 PR->LmDeleteAndIter();
720#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
746#ifdef TEST_OPT_DEBUG_RED
755 ring tailRing = PR->tailRing;
792 poly sigMult =
pCopy(PW->sig);
795 printf(
"IN KSREDUCEPOLYSIG: \n");
799 printf(
"--------------\n");
804 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
809 printf(
"--------------\n");
816 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
825 PR->is_redundant =
TRUE;
830 PR->is_redundant =
FALSE;
831 poly p1 = PR->GetLmTailRing();
832 poly p2 = PW->GetLmTailRing();
833 poly t2 =
pNext(p2), lm = p1;
854 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
857 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
866 PR->LmDeleteAndIter();
867 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
880 if (strat ==
NULL)
return 2;
883 p1 = PR->GetLmTailRing();
884 p2 = PW->GetLmTailRing();
894 if (tailRing->isLPring)
909 if ((ct == 0) || (ct == 2))
910 PR->Tail_Mult_nn(an);
911 if (coef !=
NULL) *coef = an;
916 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
922 if (tailRing->isLPring)
924 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
929 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
932 PR->LmDeleteAndIter();
934#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
952#ifdef TEST_OPT_DEBUG_RED
961 ring tailRing = PR->tailRing;
998 poly sigMult =
pCopy(PW->sig);
1001 printf(
"IN KSREDUCEPOLYSIG: \n");
1005 printf(
"--------------\n");
1019 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
1024 printf(
"--------------\n");
1033 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
1039 poly origsig =
pCopy(PR->sig);
1041 PR->sig =
pHead(
pSub(PR->sig, sigMult));
1050 if(
pLtCmp(PR->sig,origsig) == 1)
1054 PR->is_redundant =
TRUE;
1060 if(
pLtCmp(PR->sig,origsig) == -1)
1072 PR->is_redundant =
TRUE;
1077 PR->is_redundant =
FALSE;
1078 poly p1 = PR->GetLmTailRing();
1079 poly p2 = PW->GetLmTailRing();
1080 poly t2 =
pNext(p2), lm = p1;
1101 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
1104 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
1113 PR->LmDeleteAndIter();
1114 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1127 if (strat ==
NULL)
return 2;
1130 p1 = PR->GetLmTailRing();
1131 p2 = PW->GetLmTailRing();
1141 if (tailRing->isLPring)
1153 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1163 if (((ct == 0) || (ct == 2)))
1164 PR->Tail_Mult_nn(an);
1165 if (coef !=
NULL) *coef = an;
1170 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1176 if (tailRing->isLPring)
1178 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
1183 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
1186 PR->LmDeleteAndIter();
1188#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
1204 int use_buckets, ring tailRing,
1212 Pair->tailRing = tailRing;
1249 if (tailRing->isLPring)
1263 if (Pair->i_r1 == -1)
1269 l1 = (
R[Pair->i_r1])->GetpLength() - 1;
1271 if ((Pair->i_r2 == -1)||(
R[Pair->i_r2]==
NULL))
1277 l2 = (
R[Pair->i_r2])->GetpLength() - 1;
1283 if (tailRing->isLPring)
1286 poly tmp= tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing);
1287 a2 = tailRing->p_Procs->pp_Mult_mm(tmp, m22, tailRing);
1292 if (spNoether !=
NULL)
1295 a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
1300 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
1304 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
1307 if (tailRing->isLPring)
1310 poly tmp=tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing);
1311 Pair->Tail_Minus_mm_Mult_qq(m1, tmp, l1, spNoether);
1318 Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
1322 Pair->LmDeleteAndIter();
1325 if (tailRing->isLPring)
1328 assume(Pair->shift == 0);
1354 poly Lp = PR->GetLmCurrRing();
1355 poly Save = PW->GetLmCurrRing();
1373 if (Current == PR->p && PR->t_p !=
NULL)
1379 pNext(Current) = Red.GetLmTailRing();
1380 if (Current == PR->p && PR->t_p !=
NULL)
1394 poly Lp = PR->GetLmCurrRing();
1395 poly Save = PW->GetLmCurrRing();
1413 if (Current == PR->p && PR->t_p !=
NULL)
1419 pNext(Current) = Red.GetLmTailRing();
1420 if (Current == PR->p && PR->t_p !=
NULL)
1451 if (tailRing->isLPring)
1491 if (tailRing->isLPring)
1515 if ((c1==c2)||(c2!=0))
1532 if (tailRing->isLPring && (shift2!=0))
1567 if ((c1==c2)||(c1!=0))
1584 if (tailRing->isLPring && (shift1!=0))
1643 if (tailRing->isLPring)
1662 if (tailRing->isLPring)
1695 if (tailRing->isLPring)
1737 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)