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();
193 #ifdef TEST_OPT_DEBUG_RED 204 ring tailRing = PR->tailRing;
208 poly p1 = PR->GetLmTailRing();
209 poly p2 = PW->GetLmTailRing();
210 poly t2 =
pNext(p2), lm = p1;
231 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
234 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
243 PR->LmDeleteAndIter();
244 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
257 if (strat ==
NULL)
return 2;
260 p1 = PR->GetLmTailRing();
261 p2 = PW->GetLmTailRing();
271 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();
323 #ifdef TEST_OPT_DEBUG_RED 334 ring tailRing = PR->tailRing;
338 poly p1 = PR->GetLmTailRing();
339 poly p2 = PW->GetLmTailRing();
361 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
364 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
375 if (strat ==
NULL)
return 2;
378 p1 = PR->GetLmTailRing();
379 p2 = PW->GetLmTailRing();
394 PR->Tail_Mult_nn(an);
398 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
403 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
408 #ifdef HAVE_SHIFTBBA_NONEXISTENT 417 PR->SetShortExpVector();
439 #ifdef TEST_OPT_DEBUG_RED 452 ring tailRing = PR->tailRing;
456 poly p1 = PR->GetLmTailRing();
457 poly p2 = PW->GetLmTailRing();
458 poly t2 =
pNext(p2), lm = p1;
479 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
482 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
495 if (strat ==
NULL)
return 2;
498 p1 = PR->GetLmTailRing();
499 p2 = PW->GetLmTailRing();
507 PR->Tail_Minus_mm_Mult_qq(lm, p2,
pLength(p2) , spNoether);
510 PR->LmDeleteAndIter();
515 #ifdef HAVE_SHIFTBBA_NONEXISTENT 524 PR->SetShortExpVector();
528 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) 547 #ifdef TEST_OPT_DEBUG_RED 558 ring tailRing = PR->tailRing;
562 poly p1 = PR->GetLmTailRing();
563 poly p2 = PW->GetLmTailRing();
564 poly t2 =
pNext(p2), lm = p1;
585 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
588 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
597 PR->LmDeleteAndIter();
598 if (coef !=
NULL) *coef =
n_Init(1, tailRing);
611 if (strat ==
NULL)
return 2;
614 p1 = PR->GetLmTailRing();
615 p2 = PW->GetLmTailRing();
625 if (tailRing->isLPring) {
640 if ((ct == 0) || (ct == 2))
641 PR->Tail_Mult_nn(an);
642 if (coef !=
NULL) *coef = an;
647 if (coef !=
NULL) *coef =
n_Init(1, tailRing);
653 if (tailRing->isLPring)
655 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
660 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
663 PR->LmDeleteAndIter();
665 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) 691 #ifdef TEST_OPT_DEBUG_RED 700 ring tailRing = PR->tailRing;
734 poly sigMult =
pCopy(PW->sig);
737 printf(
"IN KSREDUCEPOLYSIG: \n");
741 printf(
"--------------\n");
746 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
751 printf(
"--------------\n");
758 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
767 PR->is_redundant =
TRUE;
772 PR->is_redundant =
FALSE;
773 poly p1 = PR->GetLmTailRing();
774 poly p2 = PW->GetLmTailRing();
775 poly t2 =
pNext(p2), lm = p1;
796 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
799 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
808 PR->LmDeleteAndIter();
809 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
822 if (strat ==
NULL)
return 2;
825 p1 = PR->GetLmTailRing();
826 p2 = PW->GetLmTailRing();
836 if (tailRing->isLPring) {
851 if ((ct == 0) || (ct == 2))
852 PR->Tail_Mult_nn(an);
853 if (coef !=
NULL) *coef = an;
858 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
864 if (tailRing->isLPring)
866 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
871 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
874 PR->LmDeleteAndIter();
876 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) 894 #ifdef TEST_OPT_DEBUG_RED 903 ring tailRing = PR->tailRing;
937 poly sigMult =
pCopy(PW->sig);
940 printf(
"IN KSREDUCEPOLYSIG: \n");
944 printf(
"--------------\n");
958 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
963 printf(
"--------------\n");
972 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
978 poly origsig =
pCopy(PR->sig);
989 if(
pLtCmp(PR->sig,origsig) == 1)
993 PR->is_redundant =
TRUE;
999 if(
pLtCmp(PR->sig,origsig) == -1)
1011 PR->is_redundant =
TRUE;
1016 PR->is_redundant =
FALSE;
1017 poly p1 = PR->GetLmTailRing();
1018 poly p2 = PW->GetLmTailRing();
1019 poly t2 =
pNext(p2), lm = p1;
1040 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
1043 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
1052 PR->LmDeleteAndIter();
1053 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1066 if (strat ==
NULL)
return 2;
1069 p1 = PR->GetLmTailRing();
1070 p2 = PW->GetLmTailRing();
1078 #ifdef HAVE_SHIFTBBA 1080 if (tailRing->isLPring) {
1089 #ifdef HAVE_SHIFTBBA 1092 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1102 #ifdef HAVE_SHIFTBBA 1105 if (((ct == 0) || (ct == 2)))
1106 PR->Tail_Mult_nn(an);
1107 if (coef !=
NULL) *coef = an;
1112 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1117 #ifdef HAVE_SHIFTBBA 1118 if (tailRing->isLPring)
1120 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
1125 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
1128 PR->LmDeleteAndIter();
1130 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) 1146 int use_buckets, ring tailRing,
1155 Pair->tailRing = tailRing;
1190 #ifdef HAVE_SHIFTBBA 1192 if (tailRing->isLPring)
1199 n_Delete(&(m1->coef), tailRing->cf);
1200 n_Delete(&(m2->coef), tailRing->cf);
1209 if (Pair->i_r1 == -1)
1215 l1 = (R[Pair->i_r1])->GetpLength() - 1;
1217 if ((Pair->i_r2 == -1)||(R[Pair->i_r2]==
NULL))
1223 l2 = (R[Pair->i_r2])->GetpLength() - 1;
1228 if (spNoether !=
NULL)
1231 a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
1235 #ifdef HAVE_SHIFTBBA 1236 if (tailRing->isLPring)
1239 a2 = tailRing->p_Procs->pp_Mult_mm(tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing), m22, tailRing);
1244 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
1250 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
1252 #ifdef HAVE_SHIFTBBA 1253 if (tailRing->isLPring)
1256 Pair->Tail_Minus_mm_Mult_qq(m1, tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing), l1, spNoether);
1262 Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
1266 Pair->LmDeleteAndIter();
1268 #ifdef HAVE_SHIFTBBA 1269 if (tailRing->isLPring)
1294 poly Lp = PR->GetLmCurrRing();
1295 poly Save = PW->GetLmCurrRing();
1315 if (Current == PR->p && PR->t_p !=
NULL)
1321 pNext(Current) = Red.GetLmTailRing();
1322 if (Current == PR->p && PR->t_p !=
NULL)
1336 poly Lp = PR->GetLmCurrRing();
1337 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)
1393 #ifdef HAVE_SHIFTBBA 1395 if (tailRing->isLPring) {
1434 #ifdef HAVE_SHIFTBBA 1436 if (tailRing->isLPring)
1460 if ((c1==c2)||(c2!=0))
1510 if ((c1==c2)||(c1!=0))
1664 #ifdef HAVE_SHIFTBBA 1665 if (tailRing->isLPring)
#define __p_GetComp(p, r)
int ksReducePolyLC(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, poly &m1, poly &m2, const ring m_r)
static CanonicalForm bound(const CFMatrix &M)
void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r)
Compatiblity layer for legacy polynomial operations (over currRing)
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
int ksCheckCoeff(number *a, number *b)
int ksReducePolyTailBound(LObject *PR, TObject *PW, int bound, poly Current, poly spNoether)
int p_mFirstVblock(poly p, const ring ri)
int ksReducePoly(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
static BOOLEAN rField_is_Domain(const ring r)
int ksReducePolyZ(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing)
BOOLEAN pHaveCommonMonoms(poly p, poly q)
static number p_SetCoeff(poly p, number n, ring r)
static void p_LmFree(poly p, ring)
BOOLEAN pIsMonomOf(poly p, poly m)
int ksReducePolySig(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)
BOOLEAN p_CheckPolyRing(poly p, ring r)
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
static void p_SetCompP(poly p, int i, ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
void ksCreateSpoly(LObject *Pair, poly spNoether, int use_buckets, ring tailRing, poly m1, poly m2, TObject **R)
int ksReducePolyGCD(LObject *PR, TObject *PW, poly spNoether, number *coef, kStrategy strat)
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
static int p_LmCmp(poly p, poly q, const ring r)
BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject *T, unsigned long expbound)
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 void p_ExpVectorSub(poly p1, poly p2, const ring r)
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
static unsigned pLength(poly a)
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
static void nc_kBucketPolyRed_Z(kBucket_pt b, poly p, number *c)
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 CFList split(const CanonicalForm &F, const int m, const Variable &x)
int ksReducePolyBound(LObject *PR, TObject *PW, int bound, poly spNoether, number *coef, kStrategy strat)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
static BOOLEAN rField_is_Ring(const ring r)
poly p_LPCopyAndShiftLM(poly p, int sh, const ring r)
int p_FirstVblock(poly p, const ring r)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
static void p_Setm(poly p, const ring r)
static void p_LmDelete(poly p, const ring r)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static void p_ExpVectorAddSub(poly p1, poly p2, poly p3, const ring r)
int ksReducePolyTail(LObject *PR, TObject *PW, poly Current, poly spNoether)
static poly p_Init(const ring r, omBin bin)
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
void k_SplitFrame(poly &m1, poly &m2, int at, const ring r)
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
#define pCopy(p)
return a copy of the poly
int ksReducePolySigRing(LObject *PR, TObject *PW, long, poly spNoether, number *coef, kStrategy strat)