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)
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();
196 #ifdef TEST_OPT_DEBUG_RED
207 ring tailRing = PR->tailRing;
211 poly p1 = PR->GetLmTailRing();
212 poly p2 = PW->GetLmTailRing();
213 poly t2 =
pNext(p2), lm = p1;
234 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
237 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
246 PR->LmDeleteAndIter();
247 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
260 if (strat ==
NULL)
return 2;
263 p1 = PR->GetLmTailRing();
264 p2 = PW->GetLmTailRing();
274 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 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
312 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
315 PR->LmDeleteAndIter();
328 #ifdef TEST_OPT_DEBUG_RED
339 ring tailRing = PR->tailRing;
343 poly p1 = PR->GetLmTailRing();
344 poly p2 = PW->GetLmTailRing();
366 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
369 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
380 if (strat ==
NULL)
return 2;
383 p1 = PR->GetLmTailRing();
384 p2 = PW->GetLmTailRing();
399 PR->Tail_Mult_nn(an);
403 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
408 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
413 #ifdef HAVE_SHIFTBBA_NONEXISTENT
422 PR->SetShortExpVector();
444 #ifdef TEST_OPT_DEBUG_RED
457 ring tailRing = PR->tailRing;
461 poly p1 = PR->GetLmTailRing();
462 poly p2 = PW->GetLmTailRing();
463 poly t2 =
pNext(p2), lm = p1;
484 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
487 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
500 if (strat ==
NULL)
return 2;
503 p1 = PR->GetLmTailRing();
504 p2 = PW->GetLmTailRing();
512 PR->Tail_Minus_mm_Mult_qq(lm, p2,
pLength(p2) , spNoether);
515 PR->LmDeleteAndIter();
520 #ifdef HAVE_SHIFTBBA_NONEXISTENT
529 PR->SetShortExpVector();
533 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
552 #ifdef TEST_OPT_DEBUG_RED
563 ring tailRing = PR->tailRing;
567 poly p1 = PR->GetLmTailRing();
568 poly p2 = PW->GetLmTailRing();
569 poly t2 =
pNext(p2), lm = p1;
590 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
593 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
602 PR->LmDeleteAndIter();
603 if (coef !=
NULL) *coef =
n_Init(1, tailRing);
616 if (strat ==
NULL)
return 2;
619 p1 = PR->GetLmTailRing();
620 p2 = PW->GetLmTailRing();
630 if (tailRing->isLPring)
648 if ((ct == 0) || (ct == 2))
649 PR->Tail_Mult_nn(an);
650 if (coef !=
NULL) *coef = an;
655 if (coef !=
NULL) *coef =
n_Init(1, tailRing);
661 if (tailRing->isLPring)
663 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
668 PR->Tail_Minus_mm_Mult_qq(lm, t2,
pLength(t2) , spNoether);
671 PR->LmDeleteAndIter();
673 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
699 #ifdef TEST_OPT_DEBUG_RED
708 ring tailRing = PR->tailRing;
742 poly sigMult =
pCopy(PW->sig);
745 printf(
"IN KSREDUCEPOLYSIG: \n");
749 printf(
"--------------\n");
754 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
759 printf(
"--------------\n");
766 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
775 PR->is_redundant =
TRUE;
780 PR->is_redundant =
FALSE;
781 poly p1 = PR->GetLmTailRing();
782 poly p2 = PW->GetLmTailRing();
783 poly t2 =
pNext(p2), lm = p1;
804 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
807 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
816 PR->LmDeleteAndIter();
817 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
830 if (strat ==
NULL)
return 2;
833 p1 = PR->GetLmTailRing();
834 p2 = PW->GetLmTailRing();
844 if (tailRing->isLPring)
862 if ((ct == 0) || (ct == 2))
863 PR->Tail_Mult_nn(an);
864 if (coef !=
NULL) *coef = an;
869 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
875 if (tailRing->isLPring)
877 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
882 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
885 PR->LmDeleteAndIter();
887 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
905 #ifdef TEST_OPT_DEBUG_RED
914 ring tailRing = PR->tailRing;
948 poly sigMult =
pCopy(PW->sig);
951 printf(
"IN KSREDUCEPOLYSIG: \n");
955 printf(
"--------------\n");
969 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
974 printf(
"--------------\n");
983 printf(
"%d -- %d sig\n",sigSafe,PW->is_sigsafe);
989 poly origsig =
pCopy(PR->sig);
1000 if(
pLtCmp(PR->sig,origsig) == 1)
1004 PR->is_redundant =
TRUE;
1010 if(
pLtCmp(PR->sig,origsig) == -1)
1022 PR->is_redundant =
TRUE;
1027 PR->is_redundant =
FALSE;
1028 poly p1 = PR->GetLmTailRing();
1029 poly p2 = PW->GetLmTailRing();
1030 poly t2 =
pNext(p2), lm = p1;
1051 poly _p = (PR->t_p !=
NULL ? PR->t_p : PR->p);
1054 if (PR->t_p!=
NULL) PR->t_p=_p;
else PR->p=_p;
1063 PR->LmDeleteAndIter();
1064 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1077 if (strat ==
NULL)
return 2;
1080 p1 = PR->GetLmTailRing();
1081 p2 = PW->GetLmTailRing();
1089 #ifdef HAVE_SHIFTBBA
1091 if (tailRing->isLPring)
1103 #ifdef HAVE_SHIFTBBA
1106 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1116 #ifdef HAVE_SHIFTBBA
1119 if (((ct == 0) || (ct == 2)))
1120 PR->Tail_Mult_nn(an);
1121 if (coef !=
NULL) *coef = an;
1126 if (coef !=
NULL) *coef =
n_Init(1, tailRing->cf);
1131 #ifdef HAVE_SHIFTBBA
1132 if (tailRing->isLPring)
1134 PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing),
pLength(t2), spNoether);
1139 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
1142 PR->LmDeleteAndIter();
1144 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
1160 int use_buckets, ring tailRing,
1169 Pair->tailRing = tailRing;
1204 #ifdef HAVE_SHIFTBBA
1206 if (tailRing->isLPring)
1214 n_Delete(&(m1->coef), tailRing->cf);
1215 n_Delete(&(m2->coef), tailRing->cf);
1224 if (Pair->i_r1 == -1)
1230 l1 = (
R[Pair->i_r1])->GetpLength() - 1;
1232 if ((Pair->i_r2 == -1)||(
R[Pair->i_r2]==
NULL))
1238 l2 = (
R[Pair->i_r2])->GetpLength() - 1;
1243 if (spNoether !=
NULL)
1246 a2 = tailRing->p_Procs->pp_Mult_mm_Noether(a2, m2, spNoether, l2, tailRing);
1250 #ifdef HAVE_SHIFTBBA
1251 if (tailRing->isLPring)
1254 a2 = tailRing->p_Procs->pp_Mult_mm(tailRing->p_Procs->pp_mm_Mult(a2, m2, tailRing), m22, tailRing);
1259 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing);
1265 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
1267 #ifdef HAVE_SHIFTBBA
1268 if (tailRing->isLPring)
1271 Pair->Tail_Minus_mm_Mult_qq(m1, tailRing->p_Procs->pp_Mult_mm(a1, m12, tailRing), l1, spNoether);
1277 Pair->Tail_Minus_mm_Mult_qq(m1, a1, l1, spNoether);
1281 Pair->LmDeleteAndIter();
1283 #ifdef HAVE_SHIFTBBA
1284 if (tailRing->isLPring)
1287 assume(Pair->shift == 0);
1313 poly Lp = PR->GetLmCurrRing();
1314 poly Save = PW->GetLmCurrRing();
1334 if (Current == PR->p && PR->t_p !=
NULL)
1340 pNext(Current) = Red.GetLmTailRing();
1341 if (Current == PR->p && PR->t_p !=
NULL)
1355 poly Lp = PR->GetLmCurrRing();
1356 poly Save = PW->GetLmCurrRing();
1376 if (Current == PR->p && PR->t_p !=
NULL)
1382 pNext(Current) = Red.GetLmTailRing();
1383 if (Current == PR->p && PR->t_p !=
NULL)
1412 #ifdef HAVE_SHIFTBBA
1414 if (tailRing->isLPring) {
1453 #ifdef HAVE_SHIFTBBA
1455 if (tailRing->isLPring)
1479 if ((c1==c2)||(c2!=0))
1529 if ((c1==c2)||(c1!=0))
1683 #ifdef HAVE_SHIFTBBA
1684 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 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.
static CFList split(const CanonicalForm &F, const int m, const Variable &x)
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)
int ksReducePoly(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 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)
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)