Hello,
i have two technical questions concerning some code from the singular kernel.
1.)
In kInline.cc kspoly.cc a function named ksOldSpolyRed invokes the function ksReducePoly with 3 Arguments:
Code:
//extracted from kInline.cc
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
{
LObject L(p2);
TObject T(p1);
ksReducePoly(&L, &T, spNoether);
return L.GetLmCurrRing();
}
,
but i can find no definition of ksReducePoly, which need less than 5 Arguments.
The only definition i can find (in kspoly.cc) needs 5 Argument (and none of it is optional).
Where can i find the appropriate definition needed for ksOldSpolyRed?(I am sorry for spamming with code here, i don't really believe it will be necessary for you to review it, but i give it for the sake of completeness.)
Code:
//extracted from kspoly.cc
/***************************************************************
*
* Reduces PR with PW
* Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
*
***************************************************************/
int ksReducePoly(LObject* PR,
TObject* PW,
poly spNoether,
number *coef,
kStrategy strat)
{
#ifdef KDEBUG
red_count++;
#ifdef TEST_OPT_DEBUG_RED
if (TEST_OPT_DEBUG)
{
Print("Red %d:", red_count); PR->wrp(); Print(" with:");
PW->wrp();
}
#endif
#endif
int ret = 0;
ring tailRing = PR->tailRing;
kTest_L(PR);
kTest_T(PW);
poly p1 = PR->GetLmTailRing(); // p2 | p1
poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2)
poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2
assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special
p_CheckPolyRing(p1, tailRing);
p_CheckPolyRing(p2, tailRing);
pAssume1(p2 != NULL && p1 != NULL &&
p_DivisibleBy(p2, p1, tailRing));
pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||
(p_GetComp(p2, tailRing) == 0 &&
p_MaxComp(pNext(p2),tailRing) == 0));
#ifdef HAVE_PLURAL
if (rIsPluralRing(currRing))
{
// for the time being: we know currRing==strat->tailRing
// no exp-bound checking needed
// (only needed if exp-bound(tailring)<exp-b(currRing))
if (PR->bucket!=NULL) nc_kBucketPolyRed(PR->bucket, p2,coef);
else
{
poly _p = (PR->t_p != NULL ? PR->t_p : PR->p);
assume(_p != NULL);
nc_PolyPolyRed(_p, p2,coef);
if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p;
PR->pLength=0; // usaully not used, GetpLength re-comoutes it if needed
}
return 0;
}
#endif
if (t2==NULL) // Divisor is just one term, therefore it will
{ // just cancel the leading term
PR->LmDeleteAndIter();
if (coef != NULL) *coef = n_Init(1, tailRing);
return 0;
}
p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2
if (tailRing != currRing)
{
// check that reduction does not violate exp bound
while (PW->max != NULL && !p_LmExpVectorAddIsOk(lm, PW->max, tailRing))
{
// undo changes of lm
p_ExpVectorAdd(lm, p2, tailRing);
if (strat == NULL) return 2;
if (! kStratChangeTailRing(strat, PR, PW)) return -1;
tailRing = strat->tailRing;
p1 = PR->GetLmTailRing();
p2 = PW->GetLmTailRing();
t2 = pNext(p2);
lm = p1;
p_ExpVectorSub(lm, p2, tailRing);
ret = 1;
}
}
// take care of coef buisness
if (! n_IsOne(pGetCoeff(p2), tailRing))
{
number bn = pGetCoeff(lm);
number an = pGetCoeff(p2);
int ct = ksCheckCoeff(&an, &bn); // Calculate special LC
p_SetCoeff(lm, bn, tailRing);
if ((ct == 0) || (ct == 2))
PR->Tail_Mult_nn(an);
if (coef != NULL) *coef = an;
else n_Delete(&an, tailRing);
}
else
{
if (coef != NULL) *coef = n_Init(1, tailRing);
}
// and finally,
PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
PR->LmDeleteAndIter();
// the following is commented out: shrinking
#ifdef HAVE_SHIFTBBA_NONEXISTENT
if ( (currRing->isLPring) && (!strat->homog) )
{
// assume? h->p in currRing
PR->GetP();
poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
PR->Clear(); // does the right things
PR->p = qq;
PR->t_p = NULL;
PR->SetShortExpVector();
}
#endif
#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
if (TEST_OPT_DEBUG)
{
Print(" to: "); PR->wrp(); Print("\n");
}
#endif
return ret;
}
My second question is less important, i just ask out of curiosity.
2.)
In various function in the kernel of Singular i found a strange loop construct, which i suspect not to be in the language specification of C. Is it a macro? Where is it defined? Here is an example extracted from the bba function in kstd2.cc:
Code:
loop
{
if (j>=k) break;
clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
j++;
}
edit:
I forgot to say, that i use Singular Version 3-1-3.
Background:
I am currently adapting code from the singular kernel for a new letterplace approach using Distance Vectors as shift invariant representations for monomials.
I am a Hiwi of Viktor Levandovskyy Lehrstuhl D fuer Mathematik, Rwth Aachen and working together with Grischa Studzinski.
Thanks in advance for any answers, especially with respect to my first question.
Benjamin Schnitzler