33 #define pDeg(A) p_Deg(A,currRing) 60 p2 = *(left + (right - left >> 1));
78 }
while(++ptr1 <= --ptr2);
118 for(
j=1;
j<=
k;
j++) {
134 LList*
F5inc(
int i,
poly f_i,
LList* gPrev,
LList* reducers, ideal gbPrev,
poly ONE,
LTagList* lTag,
RList* rules,
RTagList* rTag,
int plus,
int termination) {
137 int iterationstep =
i;
157 criticalPair(gPrev, critPairs, lTag, rTag, rules, rejectedGBList, plus);
185 critPairsMinDeg = critPairs->
getMinDeg();
194 computeSPols(critPairsMinDeg,rTag,rules,sPolyList, rejectedGBList);
219 newReduction(sPolyList, critPairs, gPrev, reducers, rules, lTag, rTag, gbPrev, termination, rejectedGBList, plus);
323 while(
NULL != temp) {
325 number nOne =
nInit(1);
328 while(
NULL != temp2) {
374 PrintS(
"------------------\n");
390 while(
NULL != temp) {
398 LNode* tempPoly = firstGCurr;
399 while(
NULL != tempPoly) {
401 while(
NULL != tempPoly2) {
402 number nOne =
nInit(1);
408 LNode* tempPoly3 = firstGCurr;
409 while(
NULL != tempPoly3) {
423 tempPoly3 = tempPoly3->
getNext();
426 tempPoly2 = tempPoly2->
getNext();
428 tempPoly = tempPoly->
getNext();
448 number nOne =
nInit(1);
463 while( gPrev->
getLast() != temp) {
488 if(newElement->getIndex() == temp->getIndex() &&
491 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 0 , testedRuleOld);
498 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 0, testedRuleOld);
526 if(newElement->getIndex() == temp->getIndex() &&
529 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 1 , testedRuleOld);
535 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 1, testedRuleOld);
560 number nOne =
nInit(1);
572 while( gPrev->
getLast() != temp) {
592 if(newElement->getIndex() == temp->getIndex() &&
595 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 1 , testedRuleOld);
601 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 1, testedRuleOld);
607 temp = temp->getNext();
620 int idx =
l->getIndex();
647 testNode = testNode->
getNext();
702 if(idx >
l->getIndex()) {
749 if(
NULL != testNode ) {
752 if(
NULL != testNode) {
776 testNode = testNode->
getNext();
813 while(
NULL != testNode && testNode->
getRuleOld() != testedRuleOld) {
822 testNode = testNode->
getNext();
835 while(
NULL != temp) {
867 while(
NULL != temp) {
970 //sPolyList->insertByLabel(ppMult_qq(temp->getT1(),temp->getLp1Term()),temp->getLp1Index(),sp,rules->getFirst()->getRuleOld());
975 sp = ksOldSpolyRedNew(ppMult_qq(temp->getT1(),temp->getLp1Poly()),
976 ppMult_qq(temp->getT2(),temp->getLp2Poly()));
977 //Print("BEGIN SPOLY2\n====================\n");
980 //Print("END SPOLY2\n====================\n");
983 //rules->insert(temp->getLp1Index(),ppMult_qq(temp->getT1(),temp->getLp1Term()));
988 rules->insert(temp->getLp1Index(),ppMult_qq(temp->getT1(),temp->getLp1Term()));
990 // save the address of the rule again in a different
993 f5rules->insert(rules->getFirst()->getRuleOld());
994 f5pairs->insertWithoutSort(temp->getData());
996 //sPolyList->insertByLabel(ppMult_qq(temp->getT1(),temp->getLp1Term()),temp->getLp1Index(),sp,rules->getFirst()->getRuleOld());
1001 // the following else is not needed at all as we are checking
1002 // F5-critical pairs in this step
1005 if(!temp->getDel()) {
1006 rejectedGBList->insert(pHead(ppMult_qq(temp->getT1(),temp->getLp1Poly())));
1094 ideal gbPrev,
PList* rejectedGBList,
int plus) {
1099 while(
NULL != temp) {
1110 if(
NULL != tempNF) {
1118 topReduction(temp,sPolyList,gPrev,critPairs,rules,lTag,rTag,gbPrev, rejectedGBList,plus);
1140 ideal gbPrev,
int termination,
PList* rejectedGBList,
int plus) {
1147 while(
NULL != temp) {
1172 findReducers(temp,sPolyList,gbPrev,gPrev,reducers,critPairs,rules,lTag,rTag, termination, rejectedGBList,plus);
1206 void findReducers(
LNode*
l,
LList* sPolyList, ideal gbPrev,
LList* gPrev,
LList* reducers,
CListOld* critPairs,
RList* rules,
LTagList* lTag,
RTagList* rTag,
int termination,
PList* rejectedGBList,
int plus) {
1207 int canonicalize = 0;
1215 number nOne =
nInit(1);
1220 int idx =
l->getIndex();
1223 tempPoly =
pCopy(
l->getPoly());
1234 while(
NULL != tempPoly) {
1237 while(
NULL != tempRed) {
1252 int lTempRedPoly =
pLength(tempRedPoly);
1257 if(!(canonicalize % 50)) {
1263 if(
NULL != tempPoly) {
1287 if(
NULL == redPoly) {
1288 bad->insert(tempRed->getLPolyOld());
1295 poly tempRedPoly = tempRed->getPoly();
1299 int lTempRedPoly =
pLength(tempRedPoly);
1307 if(!(canonicalize % 50)) {
1315 if(
NULL != tempPoly) {
1362 int lTempRedPoly =
pLength(tempRedPoly);
1367 if(!(canonicalize % 50)) {
1373 if(
NULL != tempPoly) {
1386 if(
NULL != tempPoly) {
1389 while(
NULL != tempRed) {
1405 int lTempRedPoly =
pLength(tempRedPoly);
1410 if(!(canonicalize % 50)) {
1416 if(
NULL != tempPoly) {
1440 if(
NULL == redPoly) {
1441 bad->insert(tempRed->getLPolyOld());
1448 poly tempRedPoly = tempRed->getPoly();
1452 int lTempRedPoly =
pLength(tempRedPoly);
1460 if(!(canonicalize % 50)) {
1468 if(
NULL != tempPoly) {
1514 if(
NULL != tempPoly) {
1515 if(
NULL == redPoly) {
1529 if(
NULL == redPoly) {
1535 PrintS(
"\nELEMENT ADDED TO GPREV: ");
1544 l->setPoly(redPoly);
1548 Print(
"redundant? %d\n\n",
l->getDel());
1549 if(addToG == 0 && termination == 1) {
1550 reducers->
insert(
l->getLPolyOld());
1553 gPrev->
insert(
l->getLPolyOld());
1556 if(termination == 1) {
1559 criticalPair(gPrev,critPairs,lTag,rTag,rules, rejectedGBList,plus);
1573 criticalPair(gPrev,critPairs,lTag,rTag,rules,rejectedGBList,plus);
1576 criticalPair2(gPrev,critPairs,lTag,rTag,rules, rejectedGBList);
1588 while(
NULL != tempBad) {
1603 rules->insert(tempBad->getIndex(),
ppMult_qq(u,tempBad->getTerm()));
1613 LNode* tempBadNew =
new LNode(
ppMult_qq(u,tempBad->getTerm()),tempBad->getIndex(),temp,rules->getFirst()->getRuleOld());
1719 tempRed =
findReductor(
l,sPolyList,gPrevRedCheck,gPrev,rules,lTag,rTag);
1723 if(
NULL != tempRed) {
1775 if(
NULL == tempNF) {
1794 if(
NULL !=
l->getPoly()) {
1798 gPrev->
insert(
l->getLPolyOld());
1803 criticalPair(gPrev,critPairs,lTag,rTag,rules, rejectedGBList,plus);
1824 number nOne =
nInit(1);
1831 temp = gPrevRedCheck;
1834 while(
NULL != temp && temp->getIndex() ==
l->getIndex()) {
1850 gPrevRedCheck = temp->
getNext();
1862 rules->insert(temp->getIndex(),
ppMult_qq(u,temp->getTerm()));
1863 gPrevRedCheck = temp->
getNext();
1864 if(
NULL != tempSpoly) {
1866 sPolyList->
insertByLabel(
ppMult_qq(u,temp->getTerm()),temp->getIndex(),tempSpoly,rules->getFirst()->getRuleOld());
1878 temp = temp->getNext();
1893 ideal
F5main(ideal
id, ring
r,
int opt,
int plus,
int termination)
1898 PrintS(
"\nComputations are done by the standard F5 Algorithm");
1901 PrintS(
"\nComputations are done by the variant F5R of the F5 Algorithm");
1904 PrintS(
"\nComputations are done by the variant F5C of the F5 Algorithm");
1907 WerrorS(
"\nThe option can only be set to \"0\", \"1\" or \"2\":\n\"0\": standard F5 Algorithm\n\"1\": variant F5R\n\"2\": variant F5C\nComputations are aborted!\n");
1918 number nOne =
nInit(1);
1975 ideal gbPrev =
idInit(gbLength,1);
1985 Print(
"Iteration: %d\n\n",
i);
1986 gPrev =
F5inc(
i, id->m[
i-1], gPrev, reducers, gbPrev, ONE, lTag, rules, rTag, plus, termination);
2010 LNode* temp = gPrevTag;
2014 if(0 == temp->getDel()) {
2019 gbPrev =
idAdd(gbPrev,gbAdd);
2023 LNode* temp = gPrevTag;
2028 gbPrev =
idAdd(gbPrev,gbAdd);
2046 LNode* temp = gPrevTag;
2050 if(0 == temp->getDel()) {
2055 gbPrev =
idAdd(gbPrev,gbAdd);
2059 LNode* temp = gPrevTag;
2064 gbPrev =
idAdd(gbPrev,gbAdd);
2084 LNode* temp = gPrevTag;
2089 gbPrev =
idAdd(gbPrev,gbAdd);
2093 LNode* temp = gPrevTag;
2098 gbPrev =
idAdd(gbPrev,gbAdd);
2107 rules =
new RList();
2133 Print(
"Time for computations: %d/1000 seconds\n",timer);
2134 Print(
"Number of elements in gb: %d\n",
IDELEMS(gbPrev));
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
int highestDegreeGBCriticalPair
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
void kBucketInit(kBucket_pt bucket, poly lm, int length)
void qsortDegree(poly *left, poly *right)
void findReducers(LNode *l, LList *sPolyList, ideal gbPrev, LList *gPrev, LList *reducers, CListOld *critPairs, RList *rules, LTagList *lTag, RTagList *rTag, int termination, PList *rejectedGBList, int plus)
searches for reducers of temp similar to the symbolic preprocessing of F4 and divides them into a "g...
void insert(LPolyOld *lp)
Compatiblity layer for legacy polynomial operations (over currRing)
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
structure of RuleOlds(i.e.
void setFirstCurrentIdx(LNode *l)
const poly kBucketGetLm(kBucket_pt bucket)
bool arrisCheck(CNode *first, LNode *firstGCurr, long arrideg)
static long p_Totaldegree(poly p, const ring r)
void WerrorS(const char *s)
LList * F5inc(int i, poly f_i, LList *gPrev, LList *reducers, ideal gbPrev, poly ONE, LTagList *lTag, RList *rules, RTagList *rTag, int plus, int termination)
void computeSPols(CNode *first, RTagList *rTag, RList *rules, LList *sPolyList, PList *rejectedGBList)
poly kBucketExtractLm(kBucket_pt bucket)
RuleOld * getTestedRuleOld()
class PList of lists of PNodes
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void criticalPair(LList *gPrev, CListOld *critPairs, LTagList *lTag, RTagList *rTag, RList *rules, PList *rejectedGBList, int plus)
#define pLmDivisibleByNoComp(a, b)
like pLmDivisibleBy, does not check components
LNode * getFirstCurrentIdx()
bool compareMonomials(int *m1, int **m2, int numberOfRules, int k)
compares monomials, i.e.
class of labeled polynomials
ideal kInterRed(ideal F, ideal Q)
LNode * findReductor(LNode *l, LList *sPolyList, LNode *gPrevRedCheck, LList *gPrev, RList *rules, LTagList *lTag, RTagList *rTag, PList *rejectedGBList)
bool criterion1(LList *gPrev, poly t, LNode *l, LTagList *lTag)
long sumVector(int *v, int k)
builds the sum of the entries of the exponent vectors, i.e.
void PrintS(const char *s)
static unsigned pLength(poly a)
void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, poly spNoether)
Bpoly == Bpoly - m*p; where m is a monom Does not destroy p and m assume (*l <= 0 || pLength(p) == *...
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
int computeUsefulMinDeg(CNode *first)
KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether)
bool criterion2(int idx, poly t, LNode *l, RList *rules, RTagList *rTag)
ideal idInit(int idsize, int rank)
initialise an ideal / module
const Variable & v
< [in] a sqrfree bivariate poly
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
static poly p_Merge_q(poly p, poly q, const ring r)
void reduction(LList *sPolyList, CListOld *critPairs, LList *gPrev, RList *rules, LTagList *lTag, RTagList *rTag, ideal gbPrev, PList *rejectedGBList, int plus)
void pNorm(poly p, const ring R=currRing)
void insertByLabel(poly t, int i, poly p, RuleOld *r=NULL)
#define pInit()
allocates a new monomial and initializes everything to 0
int numberUsefulPairsMinDeg
void criticalPair2(LList *gPrev, CListOld *critPairs, LTagList *lTag, RTagList *rTag, RList *rules, PList *rejectedGBList)
int numberRejectedF5CriticalPairs
bool checkDGB(LList *gPrev)
ideal idAdd(ideal h1, ideal h2)
h1 + h2
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets
void newReduction(LList *sPolyList, CListOld *critPairs, LList *gPrev, LList *reducers, RList *rules, LTagList *lTag, RTagList *rTag, ideal gbPrev, int termination, PList *rejectedGBList, int plus)
int kBucketCanonicalize(kBucket_pt bucket)
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
void topReduction(LNode *l, LList *sPolyList, LList *gPrev, CListOld *critPairs, RList *rules, LTagList *lTag, RTagList *rTag, ideal gbPrev, PList *rejectedGBList, int plus)
#define pCopy(p)
return a copy of the poly
ideal F5main(ideal id, ring r, int opt, int plus, int termination)
structure of labeled critical pairs