30 #define TEST_OPT_DEBUG_RED
52 #ifdef TEST_OPT_DEBUG_RED
63 ring tailRing = PR->tailRing;
67 poly p1 = PR->GetLmTailRing();
68 poly p2 = PW->GetLmTailRing();
69 poly t2 =
pNext(p2), lm = p1;
90 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
93 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
109 if ((ct == 0) || (ct == 2))
110 PR->Tail_Mult_nn(an);
111 if (coef !=
NULL) *coef = an;
114 PR->LmDeleteAndIter();
115 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
128 if (strat ==
NULL)
return 2;
131 p1 = PR->GetLmTailRing();
132 p2 = PW->GetLmTailRing();
142 if (tailRing->isLPring)
157 if ((ct == 0) || (ct == 2))
158 PR->Tail_Mult_nn(an);
159 if (coef !=
NULL) *coef = an;
164 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
170 if (tailRing->isLPring)
172 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
177 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
180 PR->LmDeleteAndIter();
194 #ifdef TEST_OPT_DEBUG_RED
205 ring tailRing = PR->tailRing;
209 poly p1 = PR->GetLmTailRing();
210 poly p2 = PW->GetLmTailRing();
211 poly t2 =
pNext(p2), lm = p1;
232 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
235 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
244 PR->LmDeleteAndIter();
245 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
258 if (strat ==
NULL)
return 2;
261 p1 = PR->GetLmTailRing();
262 p2 = PW->GetLmTailRing();
272 if (tailRing->isLPring)
287 if ((ct == 0) || (ct == 2))
288 PR->Tail_Mult_nn(an);
289 if (coef !=
NULL) *coef = an;
294 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
300 if (tailRing->isLPring)
302 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
307 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
310 PR->LmDeleteAndIter();
324 #ifdef TEST_OPT_DEBUG_RED
335 ring tailRing = PR->tailRing;
339 poly p1 = PR->GetLmTailRing();
340 poly p2 = PW->GetLmTailRing();
362 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
365 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
376 if (strat ==
NULL)
return 2;
379 p1 = PR->GetLmTailRing();
380 p2 = PW->GetLmTailRing();
389 if (tailRing->isLPring)
419 PR->Tail_Mult_nn(an);
423 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
429 if (tailRing->isLPring)
431 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
436 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
460 #ifdef TEST_OPT_DEBUG_RED
473 ring tailRing = PR->tailRing;
477 poly p1 = PR->GetLmTailRing();
478 poly p2 = PW->GetLmTailRing();
479 poly t2 =
pNext(p2), lm = p1;
500 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
503 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
516 if (strat ==
NULL)
return 2;
519 p1 = PR->GetLmTailRing();
520 p2 = PW->GetLmTailRing();
529 if (tailRing->isLPring)
539 if (tailRing->isLPring)
541 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(p2, lmRight, tailRing),
pLength(p2), spNoether);
546 PR->Tail_Minus_mm_Mult_qq(lm, p2,
pLength(p2) , spNoether);
550 PR->LmDeleteAndIter();
553 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
572 #ifdef TEST_OPT_DEBUG_RED
583 ring tailRing = PR->tailRing;
587 poly p1 = PR->GetLmTailRing();
588 poly p2 = PW->GetLmTailRing();
589 poly t2 =
pNext(p2), lm = p1;
610 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
613 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
622 PR->LmDeleteAndIter();
623 if (coef !=
NULL) *coef =
n_Init(1, tailRing);
636 if (strat ==
NULL)
return 2;
639 p1 = PR->GetLmTailRing();
640 p2 = PW->GetLmTailRing();
650 if (tailRing->isLPring)
665 if ((ct == 0) || (ct == 2))
666 PR->Tail_Mult_nn(an);
667 if (coef !=
NULL) *coef = an;
672 if (coef !=
NULL) *coef =
n_Init(1, tailRing);
678 if (tailRing->isLPring)
680 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
685 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
688 PR->LmDeleteAndIter();
690 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
716 #ifdef TEST_OPT_DEBUG_RED
725 ring tailRing = PR->tailRing;
759 poly sigMult =
pCopy(PW->sig);
762 printf(
"IN KSREDUCEPOLYSIG: \n");
766 printf(
"--------------\n");
771 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
776 printf(
"--------------\n");
783 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
792 PR->is_redundant =
TRUE;
797 PR->is_redundant =
FALSE;
798 poly p1 = PR->GetLmTailRing();
799 poly p2 = PW->GetLmTailRing();
800 poly t2 =
pNext(p2), lm = p1;
821 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
824 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
833 PR->LmDeleteAndIter();
834 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
847 if (strat ==
NULL)
return 2;
850 p1 = PR->GetLmTailRing();
851 p2 = PW->GetLmTailRing();
861 if (tailRing->isLPring)
876 if ((ct == 0) || (ct == 2))
877 PR->Tail_Mult_nn(an);
878 if (coef !=
NULL) *coef = an;
883 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
889 if (tailRing->isLPring)
891 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
896 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
899 PR->LmDeleteAndIter();
901 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
919 #ifdef TEST_OPT_DEBUG_RED
928 ring tailRing = PR->tailRing;
962 poly sigMult =
pCopy(PW->sig);
965 printf(
"IN KSREDUCEPOLYSIG: \n");
969 printf(
"--------------\n");
983 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
988 printf(
"--------------\n");
997 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
1003 poly origsig =
pCopy(PR->sig);
1005 PR->sig =
pHead(
pSub(PR->sig, sigMult));
1014 if(
pLtCmp(PR->sig,origsig) == 1)
1018 PR->is_redundant =
TRUE;
1024 if(
pLtCmp(PR->sig,origsig) == -1)
1036 PR->is_redundant =
TRUE;
1041 PR->is_redundant =
FALSE;
1042 poly p1 = PR->GetLmTailRing();
1043 poly p2 = PW->GetLmTailRing();
1044 poly t2 =
pNext(p2), lm = p1;
1065 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
1068 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
1077 PR->LmDeleteAndIter();
1078 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1091 if (strat ==
NULL)
return 2;
1094 p1 = PR->GetLmTailRing();
1095 p2 = PW->GetLmTailRing();
1103 #ifdef HAVE_SHIFTBBA
1105 if (tailRing->isLPring)
1117 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1127 if (((ct == 0) || (ct == 2)))
1128 PR->Tail_Mult_nn(an);
1129 if (coef !=
NULL) *coef = an;
1134 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1139 #ifdef HAVE_SHIFTBBA
1140 if (tailRing->isLPring)
1142 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
1147 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
1150 PR->LmDeleteAndIter();
1152 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
1168 int use_buckets, ring tailRing,
1177 Pair->tailRing = tailRing;
1212 #ifdef HAVE_SHIFTBBA
1214 if (tailRing->isLPring)
1220 n_Delete(&(m1->coef), tailRing->cf);
1221 n_Delete(&(m2->coef), tailRing->cf);
1230 if (Pair->i_r1 == -1)
1236 l1 = (
R[Pair->i_r1])->GetpLength() - 1;
1238 if ((Pair->i_r2 == -1)||(
R[Pair->i_r2]==
NULL))
1244 l2 = (
R[Pair->i_r2])->GetpLength() - 1;
1249 if (spNoether !=
NULL)
1252 a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
1256 #ifdef HAVE_SHIFTBBA
1257 if (tailRing->isLPring)
1260 a2 = tailRing->p_Procs->pp_Mult_mm(tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing), m22, tailRing);
1265 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
1271 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
1273 #ifdef HAVE_SHIFTBBA
1274 if (tailRing->isLPring)
1277 Pair->Tail_Minus_mm_Mult_qq(m1, tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing), l1, spNoether);
1283 Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
1287 Pair->LmDeleteAndIter();
1289 #ifdef HAVE_SHIFTBBA
1290 if (tailRing->isLPring)
1293 assume(Pair->shift == 0);
1319 poly Lp = PR->GetLmCurrRing();
1320 poly Save = PW->GetLmCurrRing();
1340 if (Current == PR->p && PR->t_p !=
NULL)
1346 pNext(Current) = Red.GetLmTailRing();
1347 if (Current == PR->p && PR->t_p !=
NULL)
1361 poly Lp = PR->GetLmCurrRing();
1362 poly Save = PW->GetLmCurrRing();
1382 if (Current == PR->p && PR->t_p !=
NULL)
1388 pNext(Current) = Red.GetLmTailRing();
1389 if (Current == PR->p && PR->t_p !=
NULL)
1418 #ifdef HAVE_SHIFTBBA
1420 if (tailRing->isLPring)
1460 #ifdef HAVE_SHIFTBBA
1462 if (tailRing->isLPring)
1486 if ((c1==c2)||(c2!=0))
1536 if ((c1==c2)||(c1!=0))
1690 #ifdef HAVE_SHIFTBBA
1691 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 bound, 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 kTest_L(LObject *L, ring strat_tailRing, BOOLEAN testp, int lpos, TSet T, int tlength)
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
BOOLEAN kTest_T(TObject *T, ring strat_tailRing, 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 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 rField_is_Ring(const ring r)
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
static BOOLEAN rField_is_Domain(const ring r)
static BOOLEAN rIsLPRing(const 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)