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();
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)
181 PR->LmDeleteAndIter();
197#ifdef TEST_OPT_DEBUG_RED
208 ring tailRing =
PR->tailRing;
215 poly p1 =
PR->GetLmTailRing();
216 poly p2 =
PW->GetLmTailRing();
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)
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);
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();
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)
485#ifdef TEST_OPT_DEBUG_RED
498 ring tailRing =
PR->tailRing;
505 poly p1 =
PR->GetLmTailRing();
506 poly p2 =
PW->GetLmTailRing();
544 if (strat ==
NULL)
return 2;
547 p1 =
PR->GetLmTailRing();
548 p2 =
PW->GetLmTailRing();
556 if (tailRing->isLPring)
566 if (tailRing->isLPring)
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();
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)
718 PR->LmDeleteAndIter();
720#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
746#ifdef TEST_OPT_DEBUG_RED
755 ring tailRing =
PR->tailRing;
795 printf(
"IN KSREDUCEPOLYSIG: \n");
799 printf(
"--------------\n");
804 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
809 printf(
"--------------\n");
831 poly p1 =
PR->GetLmTailRing();
832 poly p2 =
PW->GetLmTailRing();
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)
932 PR->LmDeleteAndIter();
934#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
952#ifdef TEST_OPT_DEBUG_RED
961 ring tailRing =
PR->tailRing;
1001 printf(
"IN KSREDUCEPOLYSIG: \n");
1005 printf(
"--------------\n");
1019 printf(
"------------------- IN KSREDUCEPOLYSIG: --------------------\n");
1024 printf(
"--------------\n");
1078 poly p1 =
PR->GetLmTailRing();
1079 poly p2 =
PW->GetLmTailRing();
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)
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;
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);
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);
1322 Pair->LmDeleteAndIter();
1325 if (tailRing->isLPring)
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)
1532 if (tailRing->isLPring && (
shift2!=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)