My Project  UNKNOWN_GIT_VERSION
Macros | Functions | Variables
janet.cc File Reference
#include "kernel/mod2.h"
#include "omalloc/omalloc.h"
#include "coeffs/numbers.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
#include "polys/kbuckets.h"
#include "kernel/ideals.h"
#include "kernel/polys.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/GBEngine/janet.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>

Go to the source code of this file.

Macros

#define pow_(x)   jDeg((x),currRing)
 

Functions

int ReducePolyLead (Poly *x, Poly *y)
 
int ReducePoly (Poly *x, poly from, Poly *y)
 
void PNF (Poly *p, TreeM *F)
 
void NFL (Poly *p, TreeM *F)
 
int ValidatePoly (Poly *x, TreeM *)
 
PolyNewPoly (poly p)
 
void DestroyPoly (Poly *x)
 
void ControlProlong (Poly *x)
 
void InitHistory (Poly *p)
 
void InitLead (Poly *p)
 
void InitProl (Poly *p)
 
int GetMult (Poly *x, int i)
 
void SetMult (Poly *x, int i)
 
void ClearMult (Poly *x, int i)
 
int GetProl (Poly *x, int i)
 
void SetProl (Poly *x, int i)
 
void ClearProl (Poly *x, int i)
 
int LengthCompare (poly p1, poly p2)
 
int ProlCompare (Poly *item1, Poly *item2)
 
void ProlVar (Poly *temp, int i)
 
void DestroyListNode (ListNode *x)
 
ListNodeCreateListNode (Poly *x)
 
PolyFindMinList (jList *L)
 
void InsertInList (jList *x, Poly *y)
 
void InsertInCount (jList *x, Poly *y)
 
int ListGreatMoveOrder (jList *A, jList *B, poly x)
 
int ListGreatMoveDegree (jList *A, jList *B, poly x)
 
int CountList (jList *Q)
 
void NFListQ ()
 
void ForEachPNF (jList *x, int i)
 
void ForEachControlProlong (jList *x)
 
void DestroyList (jList *x)
 
Polyis_present (jList *F, poly x)
 
int GB_length ()
 
NodeMcreate ()
 
void DestroyFreeNodes ()
 
void DestroyTree (NodeM *G)
 
void Define (TreeM **G)
 
int sp_div (poly m1, poly m2, int from)
 
void div_l (poly item, NodeM *x, int from)
 
Polyis_div_upper (poly item, NodeM *x, int from)
 
Polyis_div_ (TreeM *tree, poly item)
 
static void ClearMultiplicative (NodeM *xx, int i)
 
void insert_ (TreeM **tree, Poly *item)
 
void Initialization (char *Ord)
 
void T2G ()
 
int ComputeBasis (jList *_lT, jList *_lQ)
 

Variables

static int offset
 
static jListT
 
static jListQ
 
static TreeMG
 
static NodeMFreeNodes
 
static int degree_compatible
 
static int(* ListGreatMove )(jList *, jList *, poly)
 
static int Mask [8] ={0x80,0x40,0x20,0x10,0x8,0x4,0x2,0x1}
 
pFDegProc jDeg
 
static Polytemp_l
 
static Polyh
 

Macro Definition Documentation

◆ pow_

#define pow_ (   x)    jDeg((x),currRing)

Definition at line 44 of file janet.cc.

Function Documentation

◆ ClearMult()

void ClearMult ( Poly x,
int  i 
)

Definition at line 432 of file janet.cc.

433 {
434  x->mult[i/8] &= ~Mask[i%8];
435 }

◆ ClearMultiplicative()

static void ClearMultiplicative ( NodeM xx,
int  i 
)
static

Definition at line 895 of file janet.cc.

896 {
897  if (!xx) return;
898 
899  while (xx->left)
900  {
901  ClearMultiplicative(xx->right, i);
902  xx = xx->left;
903  }
904  if ((xx->ended) && (GetMult(xx->ended,i)))
905  {
906  ClearMult(xx->ended,i);
907  ProlVar(xx->ended,i);
908  }
909  else
910  ClearMultiplicative(xx->right,i);
911 }

◆ ClearProl()

void ClearProl ( Poly x,
int  i 
)

Definition at line 447 of file janet.cc.

448 {
449  (x->mult+offset)[i/8] &= ~Mask[i%8];
450 }

◆ ComputeBasis()

int ComputeBasis ( jList _lT,
jList _lQ 
)

Definition at line 1001 of file janet.cc.

1002 {
1003  // int gb_l,i,ret_value=1;
1004 
1005  T=_lT; Q=_lQ;
1006 
1007 // Debug();
1008 
1009  while((h=FindMinList(Q))!=NULL)
1010  {
1011 // PrintS("New element\n");
1012 // Debug();
1013 
1014  if (!degree_compatible)
1015  {
1016  if (!ValidatePoly(h,G))
1017  {
1018  DestroyPoly(h);
1019  continue;
1020  }
1021 
1022  h->changed=0;
1023 
1024  NFL(h,G);
1025 
1026  if (!h->root)
1027  {
1028  DestroyPoly(h);
1029  continue;
1030  }
1031  }
1032 
1033  if (h->root)
1034  {
1035  if (pIsConstant(h->root))
1036  {
1037  WarnS("Constant in basis\n");
1038  return 0;
1039  }
1040 
1041  if (h->changed && ListGreatMove(T,Q,h->root))
1042  {
1043 // PrintS("<-\n");
1044  DestroyTree(G->root);
1045  G->root=create();
1046  T2G();
1047  }
1048  }
1049 
1050 // PrintS("PNF\n");
1051  PNF(h,G);
1052 // Print("{%d}\n",pow_(h->root));
1053  insert_(&G,h);
1054  InsertInList(T,h);
1055 
1056 // PrintS("For each PNF\n");
1057  if (degree_compatible)
1058  ForEachPNF(T,pow_(h->root));
1059 
1060 // PrintS("Control of prolongations\n");
1061  if (h->changed)
1063  else
1064  ControlProlong(h);
1065 
1066 // Debug();
1067 
1068 // PrintS("NFListQ\n");
1069  if (degree_compatible)
1070  NFListQ();
1071 //Debug();
1072  }
1073 
1074 // gb_l=GB_length();
1075 
1076  Print("Length of Janet basis: %d\n",CountList(T));
1077 // Print("Length of Groebner basis: %d\n",gb_l);
1078 
1079  DestroyTree(G->root);
1080  GCF(G);
1081  DestroyFreeNodes();
1082 
1083  return 1;
1084 }

◆ ControlProlong()

void ControlProlong ( Poly x)

Definition at line 393 of file janet.cc.

394 {
395  for (int i = 0; i< offset; i++)
396  {
397  (x->mult+offset)[i]&=~((x->mult)[i]);
398 // if (!GetMult(x,i) && !GetProl(x,i))
399 // ProlVar(x,i);
400  }
401 }

◆ CountList()

int CountList ( jList Q)

Definition at line 618 of file janet.cc.

619 {
620  int i=0;
621  LCI y=Q->root;
622 
623  while(y)
624  {
625  i++;
626  y=y->next;
627  }
628 
629  return i;
630 }

◆ create()

NodeM* create ( )

Definition at line 758 of file janet.cc.

759 {
760  NodeM *y;
761 
762  if (FreeNodes == NULL)
763  {
764  y=(NodeM *)GCM(sizeof(NodeM));
765  }
766  else
767  {
768  y=FreeNodes;
769  FreeNodes=FreeNodes->left;
770  }
771 
772  y->left=y->right=NULL;
773  y->ended=NULL;
774  return y;
775 }

◆ CreateListNode()

ListNode* CreateListNode ( Poly x)

Definition at line 509 of file janet.cc.

510 {
511  ListNode* ret=(ListNode *)GCM(sizeof(ListNode));
512  ret->info=x;
513  ret->next=NULL;
514  return ret;
515 }

◆ Define()

void Define ( TreeM **  G)

Definition at line 816 of file janet.cc.

817 {
818  *G=(TreeM *)GCM(sizeof(TreeM));
819  (*G)->root=create();
820 }

◆ DestroyFreeNodes()

void DestroyFreeNodes ( )

Definition at line 777 of file janet.cc.

778 {
779  NodeM *y;
780 
781  while((y=FreeNodes)!=NULL)
782  {
783  FreeNodes=FreeNodes->left;
784  GCF(y);
785  }
786 }

◆ DestroyList()

void DestroyList ( jList x)

Definition at line 715 of file janet.cc.

716 {
717  LCI y=x->root,z;
718 
719  while(y)
720  {
721  z=y->next;
722  DestroyPoly(y->info);
723  GCF(y);
724  y=z;
725  }
726 
727  GCF(x);
728 }

◆ DestroyListNode()

void DestroyListNode ( ListNode x)

Definition at line 503 of file janet.cc.

504 {
505  DestroyPoly(x->info);
506  GCF(x);
507 }

◆ DestroyPoly()

void DestroyPoly ( Poly x)

Definition at line 384 of file janet.cc.

385 {
386  pDelete(&x->root);
387  pLmFree(&x->history);
388  if (x->lead!=NULL) pLmFree(&x->lead);
389  GCF(x->mult);
390  GCF(x);
391 }

◆ DestroyTree()

void DestroyTree ( NodeM G)

Definition at line 805 of file janet.cc.

806 {
807  if (G)
808  {
809  DestroyTree(G->left);
810  DestroyTree(G->right);
811  G->left=FreeNodes;
812  FreeNodes=G;
813  }
814 }

◆ div_l()

void div_l ( poly  item,
NodeM x,
int  from 
)

Definition at line 833 of file janet.cc.

834 {
835  if (x && !temp_l)
836  {
837  div_l(item,x->left,from);
838  if ((x->ended) && sp_div(item,x->ended->root,from))
839  {
840  temp_l=x->ended;
841  return;
842  };
843  div_l(item,x->right,from);
844  }
845 }

◆ FindMinList()

Poly* FindMinList ( jList L)

Definition at line 518 of file janet.cc.

519 {
520  LI min=&(L->root);
521  LI l;
522  LCI xl;
523  Poly *x;
524 
525  if (degree_compatible)
526  {
527  while ((*min) && ((*min)->info->root == NULL))
528  min=&((*min)->next);
529  }
530 
531  if (!(*min)) return NULL;
532 
533  l=&((*min)->next);
534 
535  while (*l)
536  {
537  if ((*l)->info->root != NULL)
538  {
539  if (ProlCompare((*l)->info,(*min)->info))
540  min=l;
541  }
542 
543  l=&((*l)->next);
544  }
545  x=(*min)->info;
546  xl=*min;
547  *min=(*min)->next;
548  GCF(xl);
549 
550  return x;
551 }

◆ ForEachControlProlong()

void ForEachControlProlong ( jList x)

Definition at line 704 of file janet.cc.

705 {
706  LCI y=x->root;
707 
708  while(y)
709  {
710  ControlProlong(y->info);
711  y=y->next;
712  }
713 }

◆ ForEachPNF()

void ForEachPNF ( jList x,
int  i 
)

Definition at line 693 of file janet.cc.

694 {
695  LCI y=x->root;
696 
697  while(y)
698  {
699  if (pow_(y->info->root) == i) PNF(y->info,G);
700  y=y->next;
701  }
702 }

◆ GB_length()

int GB_length ( )

Definition at line 741 of file janet.cc.

742 {
743  LCI iT=T->root;
744  int l=0;
745 
746  while(iT)
747  {
748  if (pow_(iT->info->lead) == pow_(iT->info->history))
749  ++l;
750  iT=iT->next;
751  }
752 
753  return l;
754 }

◆ GetMult()

int GetMult ( Poly x,
int  i 
)

Definition at line 422 of file janet.cc.

423 {
424  return x->mult[i/8] & Mask[i%8];
425 }

◆ GetProl()

int GetProl ( Poly x,
int  i 
)

Definition at line 437 of file janet.cc.

438 {
439  return (x->mult+offset)[i/8] & Mask[i%8];
440 }

◆ InitHistory()

void InitHistory ( Poly p)

Definition at line 403 of file janet.cc.

404 {
405  if (p->history) pLmFree(&p->history);
406  p->history=pLmInit(p->root);
407  p->changed=0;
408 }

◆ Initialization()

void Initialization ( char *  Ord)

Definition at line 953 of file janet.cc.

954 {
955  offset=(currRing->N % 8 == 0) ? (currRing->N/8)*8 : (currRing->N/8+1)*8;
956  if (strstr(Ord,"dp\0") || strstr(Ord,"Dp\0"))
957  {
959  jDeg=p_Deg;
961  }
962  else
963  {
967  }
968 
969  Define(&G);
970 }

◆ InitLead()

void InitLead ( Poly p)

Definition at line 410 of file janet.cc.

411 {
412  if (p->lead!=NULL) pLmFree(&p->lead);
413  p->lead=pLmInit(p->root);
414  p->prolonged=-1;
415 }

◆ InitProl()

void InitProl ( Poly p)

Definition at line 417 of file janet.cc.

418 {
419  memset(p->mult+offset,0,sizeof(char)*offset);
420 }

◆ insert_()

void insert_ ( TreeM **  tree,
Poly item 
)

Definition at line 913 of file janet.cc.

914 {
915  int power_tmp,i,i_con=currRing->N-1;
916  NodeM *curr=(*tree)->root;
917 
918  for ( ; (i_con>=0) && !pGetExp(item->root,i_con+1) ; i_con--)
919  SetMult(item,i_con);
920 
921  for (i = 0; i<= i_con; i++)
922  //<=
923  {
924  power_tmp=pGetExp(item->root,i+1);
925 
926  ClearMult(item,i);
927 
928  while (power_tmp)
929  {
930  if (!curr->left)
931  {
932  SetMult(item,i);
933  ClearMultiplicative(curr->right,i);
934  curr->left=create();
935  };
936  curr=curr->left;
937  power_tmp--;
938  };
939 
940  if (i<i_con)
941  {
942  if (!curr->left) SetMult(item,i);
943  if (!curr->right) curr->right=create();
944  curr=curr->right;
945 
946  ProlVar(item,i);
947  }
948  }
949 
950  curr->ended=item;
951 }

◆ InsertInCount()

void InsertInCount ( jList x,
Poly y 
)

Definition at line 572 of file janet.cc.

573 {
574  ListNode *ins;
575  LI ix=&(x->root);
576 
577  ins=CreateListNode(y);
578  ins->next=(ListNode *)(*ix);
579  *ix=ins;
580  return;
581 }

◆ InsertInList()

void InsertInList ( jList x,
Poly y 
)

Definition at line 553 of file janet.cc.

554 {
555  ListNode *ins;
556  LI ix=&(x->root);
557 
558  while (*ix)
559  {
560  if (pLmCmp(y->lead,(*ix)->info->lead) == -1)
561  ix=(ListNode **)&((*ix)->next);
562  else
563  break;
564  }
565 
566  ins=CreateListNode(y);
567  ins->next=(ListNode *)(*ix);
568  *ix=ins;
569  return;
570 }

◆ is_div_()

Poly* is_div_ ( TreeM tree,
poly  item 
)

Definition at line 854 of file janet.cc.

855 {
856  int power_tmp,i,i_con=currRing->N-1;
857  NodeM *curr=tree->root;
858 
859  if (!curr) return NULL;
860  if (pow_(item) == 0) return NULL;
861 
862  for ( ; i_con>=0 && !pGetExp(item,i_con+1) ; i_con--)
863  ;
864 
865  for (i=0; i <= i_con ; i++)
866  {
867  power_tmp=pGetExp(item,i+1);
868 
869  while (power_tmp)
870  {
871  if (curr->ended) return curr->ended;
872 
873  if (!curr->left)
874  {
875  if (curr->right)
876  return is_div_upper(item,curr->right,i); //??????
877  return NULL;
878  }
879 
880  curr=curr->left;
881  power_tmp--;
882  }
883 
884  if (curr->ended) return curr->ended;
885 
886  if (!curr->right) return NULL;
887 
888  curr=curr->right;
889  }
890 
891  if (curr->ended) return curr->ended;
892  else return NULL;
893 }

◆ is_div_upper()

Poly* is_div_upper ( poly  item,
NodeM x,
int  from 
)

Definition at line 847 of file janet.cc.

848 {
849  temp_l=NULL;
850  div_l(item,x,from);
851  return temp_l;
852 }

◆ is_present()

Poly* is_present ( jList F,
poly  x 
)

Definition at line 730 of file janet.cc.

731 {
732  LCI iF=F->root;
733  while(iF)
734  if (pLmCmp(iF->info->root,x) == 0)
735  return iF->info;
736  else iF=iF->next;
737 
738  return NULL;
739 }

◆ LengthCompare()

int LengthCompare ( poly  p1,
poly  p2 
)

Definition at line 452 of file janet.cc.

453 {
454  do
455  {
456  if (p1 == NULL) return 1;
457  if (p2 == NULL) return 0;
458  pIter(p1);
459  pIter(p2);
460  }while(p1 && p2);
461  return 1;
462 }

◆ ListGreatMoveDegree()

int ListGreatMoveDegree ( jList A,
jList B,
poly  x 
)

Definition at line 600 of file janet.cc.

601 {
602  LCI y=A->root;
603  int pow_x=pow_(x);
604 
605  if (!y || pow_(y->info->lead) <= pow_x) return 0;
606 
607  while(y && pow_(y->info->lead) > pow_x)
608  {
609  InsertInCount(B,y->info);
610  A->root=y->next;
611  GCF(y);
612  y=A->root;
613  }
614 
615  return 1;
616 }

◆ ListGreatMoveOrder()

int ListGreatMoveOrder ( jList A,
jList B,
poly  x 
)

Definition at line 583 of file janet.cc.

584 {
585  LCI y=A->root;
586 
587  if (!y || pLmCmp(y->info->lead,x) < 0) return 0;
588 
589  while(y && pLmCmp(y->info->lead,x) >= 0)
590  {
591  InsertInCount(B,y->info);
592  A->root=y->next;
593  GCF(y);
594  y=A->root;
595  }
596 
597  return 1;
598 }

◆ NewPoly()

Poly* NewPoly ( poly  p)

Definition at line 362 of file janet.cc.

363 {
364  Poly *beg=(Poly *)GCM(sizeof(Poly));
365 
366  beg->root=p;//(p == NULL ? pInit() : p);
367  beg->root_b=NULL;
368  beg->root_l=0;
369  beg->history=NULL;//pInit();
370  beg->lead=NULL;
371  beg->mult=(char *)GCMA(sizeof(char)*2*offset);
372 
373  for (int i=0; i < currRing->N; i++)
374  {
375  ClearMult(beg,i);
376  ClearProl(beg,i);
377  };
378 
379  beg->prolonged=-1;
380 
381  return beg;
382 }

◆ NFL()

void NFL ( Poly p,
TreeM F 
)

Definition at line 188 of file janet.cc.

189 {
190  Poly *f;
191  // int g1,f1,gg;
192 
193  if ((f=is_div_(F,p->lead))==NULL) return;
194 
195  int pX=pow_(p->lead);
196  int phX=pow_(p->history);
197 
198  if (pX!=phX)
199  {
200  int phF=pow_(f->history);
201  if (pX >= (phX+phF))
202  {
203  pDelete(&p->root);
204  //p->root=NULL;
205  return;
206  }
207 
208 /* poly p2=pInit();
209  pLcm(p->history,f->history,p2);
210  pSetm(p2);
211 
212  if (pLmCmp(p->root,p2) > 0)
213  {
214  pLmDelete(&p2);
215  pDelete(&p->root);
216  //p->root=NULL;
217  return;
218  }
219 
220  pLmDelete(&p2);
221 */
222 /* for(int i=0, gg=0 ; i<currRing->N;i++)
223  if ((g1=pGetExp(p->history,i+1)) > (f1=pGetExp(f->history,i+1)))
224  gg+=g1;
225  else gg+=f1;
226 
227  if (pX > gg)
228  {
229  pDelete(&p->root);
230  //x->root=NULL;
231  return;
232  }
233 */
234  int pF=pow_(f->lead);
235 
236  if ((pX == pF) && (pF == phF))
237  {
238  pLmFree(&f->history);
239  if (p->history!=NULL)
240  f->history=p_Copy_noCheck(p->history,currRing); /* cf of p->history is NULL */
241  }
242  }
243 
244  //if (TEST_OPT_PROT) { PrintS("R"); mflush(); }
245  int /*old_size, */count;
246  count=0;
247  while(f && p->root)
248  {
249 // PrintS("R");
250 // if (TEST_OPT_PROT) { PrintS("R"); mflush(); }
251 #if 0
252  old_size=nSize(pGetCoeff(p->root));
253 #endif
254  if (ReducePolyLead(p,f) == 0) break;
255  if (p->root!=NULL)
256  {
257  count++;
258 #if 0
259  if ((count>4) && (3<nSize(pGetCoeff(p->root)))
260  && (nSize(pGetCoeff(p->root))>old_size))
261  {
262  p_SimpleContent(p->root,old_size,currRing);
263  count=0;
264  }
265 #else
266  if (count>50)
267  {
268  kBucketClear(p->root_b,&p->root,&p->root_l);
269  p_SimpleContent(p->root,2,currRing);
270  kBucketInit(p->root_b,p->root,p->root_l);
271  count=0;
272  //PrintS(".");
273  }
274 #endif
275  f=is_div_(F,p->root);
276  }
277  }
278 #if 1
279  if (p->root_b!=NULL)
280  {
281  kBucketClear(p->root_b,&p->root,&p->root_l);
282  kBucketDestroy(&p->root_b);
283  p->root_b=NULL;
284  }
285 #endif
286 
287  if (!p->root)
288  return;
289 
290  InitHistory(p);
291  InitProl(p);
292  InitLead(p);
293  p->changed=1;
294 
295  p_ContentForGB(p->root,currRing);
296  //p_SimpleContent(p->root,-1i,currRing);
297  pTest(p->root);
298 }

◆ NFListQ()

void NFListQ ( )

Definition at line 632 of file janet.cc.

633 {
634  LCI ll;
635  int p,p1;
636  LI l;
637 
638  do
639  {
640  if (!Q->root) break;
641 
642  ll=Q->root;
643 
644  p=pow_(Q->root->info->lead);
645 
646  while (ll)
647  {
648  int ploc=pow_(ll->info->lead);
649  if (ploc < p) p=ploc;
650  ll=ll->next;
651  }
652 
653  p1=1;
654 
655  l=&(Q->root);
656 
657  while (*l)
658  {
659 // PrintS("*");
660  int ploc=pow_((*l)->info->lead);
661 
662  if (ploc == p)
663  {
664  if (!ValidatePoly((*l)->info,G))
665  {
666  ll=(*l);
667  *l=(*l)->next;
668  DestroyListNode(ll);
669  continue;
670  };
671 
672  (*l)->info->changed=0;
673 // PrintS("!");
674  NFL((*l)->info,G);
675 // PrintS("$");
676  if (!(*l)->info->root)
677  {
678  ll=(*l);
679  *l=(*l)->next;
680  DestroyListNode(ll);
681  continue;
682  };
683  p1=0;
684  }
685 
686  l=&((*l)->next);
687  }
688  }while(p1);
689 // PrintLn();
690 }

◆ PNF()

void PNF ( Poly p,
TreeM F 
)

Definition at line 144 of file janet.cc.

145 {
146  if (p->root==NULL) return;
147 
148  Poly *f;
149  BOOLEAN done=FALSE;
150  poly temp=p->root;
151 
152 // if (TEST_OPT_PROT) { PrintS("r"); mflush(); }
153  int count=0;
154  poly pp=p->root;
155  int old_size=nSize(pGetCoeff(pp));
156  p->root_l=0;
157  while(temp->next)
158  {
159  f=is_div_(F,temp->next);
160  if (f)
161  {
162  if (ReducePoly(p,temp,f)) //temp->next
163  {
164  count++;
165  //if (TEST_OPT_PROT) { PrintS("-"); mflush(); }
166  if ((f!=NULL)
167  && (count>20)
168  && (nSize(pGetCoeff(pp))>old_size)
169  )
170  {
172  //p_Content(pp,currRing);
173  count=0;
174  // old_size=nSize(pGetCoeff(pp));
175  }
176  }
177  done=TRUE;
178  }
179  else
180  temp=temp->next;
181  }
182 
183  if (done) p_ContentForGB(p->root,currRing);
184  //if (done) p_SimpleContent(p->root,-1,currRing);
185  pTest(p->root);
186 }

◆ ProlCompare()

int ProlCompare ( Poly item1,
Poly item2 
)

Definition at line 464 of file janet.cc.

465 {
466  switch(pLmCmp(item1->lead,item2->lead))
467  {
468  case -1:
469  return 1;
470 
471  case 1:
472  return 0;
473 
474  default:
475  if ((item1->root_l<=0)||(item2->root_l<=0))
476  return LengthCompare(item1->root,item2->root);
477  return item1->root_l<=item2->root_l;
478  }
479 }

◆ ProlVar()

void ProlVar ( Poly temp,
int  i 
)

Definition at line 481 of file janet.cc.

482 {
483  Poly *Pr;
484 
485  if (!GetProl(temp,i) && !GetMult(temp,i))
486  {
487  Pr=NewPoly();
488  SetProl(temp,i);
489 
490  Pr->prolonged=i;
491  Pr->history=pLmInit(temp->history);
492  Pr->lead=pLmInit(temp->lead);
493  pIncrExp(Pr->lead,i+1);
494  pSetm(Pr->lead);
495  InitProl(temp);
496 
497  Pr->changed=0;
498 // pTest(Pr->root);
499  InsertInCount(Q,Pr);
500  }
501 }

◆ ReducePoly()

int ReducePoly ( Poly x,
poly  from,
Poly y 
)

Definition at line 120 of file janet.cc.

121 {
122  if (!x->root || !y->root)
123  return 0;
124 
125 /* poly b1=pMDivide(from,y->root);
126 
127  number gcd=n_Gcd(pGetCoeff(from),pGetCoeff(y->root),currRing->cf);
128 
129  number a1=nDiv(pGetCoeff(y->root),gcd);
130  pGetCoeff(b1)=nDiv(pGetCoeff(from),gcd);
131 
132  x->root=pMult_nn(x->root,a1);
133  nDelete(&a1);*/
134 
135 // x->root=pMinus_mm_Mult_qq(x->root,b1,y->root);
136 // pDelete(&b1);
137 
138  ksOldSpolyTail(y->root,x->root,from,NULL,currRing);
139  y->root_l=0;
140 
141  return 1;
142 }

◆ ReducePolyLead()

int ReducePolyLead ( Poly x,
Poly y 
)

Definition at line 75 of file janet.cc.

76 {
77  if (!x->root || !y->root)
78  return 0;
79 
80 /* poly b1=pMDivide(x->root,y->root);
81 
82  number gcd=n_Gcd(pGetCoeff(x->root),pGetCoeff(y->root),currRing->cf);
83 
84  number a1=nDiv(pGetCoeff(y->root),gcd);
85  pGetCoeff(b1)=nDiv(pGetCoeff(x->root),gcd);
86 
87  x->root=pMult_nn(x->root,a1);
88  nDelete(&a1);
89 
90  x->root=pMinus_mm_Mult_qq(x->root,b1,y->root);
91 
92  pDelete(&b1);
93 */
94 #if 1
95  if (x->root_b==NULL)
96  {
97  if (x->root_l<=0) x->root_l=pLength(x->root);
98  x->root_b=kBucketCreate(currRing);
99  kBucketInit(x->root_b,x->root,x->root_l);
100  }
101  number coef;
102  if (y->root_l<=0) y->root_l=pLength(y->root);
103  coef=kBucketPolyRed(x->root_b,y->root,y->root_l,NULL);
104  nDelete(&coef);
105  x->root=kBucketGetLm(x->root_b);
106  if (x->root==NULL)
107  {
108  kBucketDestroy(&x->root_b);
109  x->root_b=NULL;
110  x->root_l=0;
111  }
112 #else
113  x->root=ksOldSpolyRed(y->root,x->root,NULL);
114 #endif
115 // if (x->root) p_SimpleContent(x->root,5,currRing);
116 
117  return 1;
118 }

◆ SetMult()

void SetMult ( Poly x,
int  i 
)

Definition at line 427 of file janet.cc.

428 {
429  x->mult[i/8] |= Mask[i%8];
430 }

◆ SetProl()

void SetProl ( Poly x,
int  i 
)

Definition at line 442 of file janet.cc.

443 {
444  (x->mult+offset)[i/8] |= Mask[i%8];
445 }

◆ sp_div()

int sp_div ( poly  m1,
poly  m2,
int  from 
)

Definition at line 822 of file janet.cc.

823 {
824 
825  if (pow_(m2) == 0 && pow_(m1)) return 0;
826 
827  for(int k=from; k < currRing->N; k++)
828  if (pGetExp(m1,k+1) < pGetExp(m2,k+1)) return 0;
829 
830  return 1;
831 }

◆ T2G()

void T2G ( )

Definition at line 1086 of file janet.cc.

1087 {
1088  LCI i=T->root;
1089  while (i)
1090  {
1091  insert_(&G,i->info);
1092  i=i->next;
1093  }
1094 }

◆ ValidatePoly()

int ValidatePoly ( Poly x,
TreeM  
)

Definition at line 300 of file janet.cc.

301 {
302  Poly /*f,*/*g;
303  // int g1,f1;
304 
305  if (x->root) return 1;
306 
307  g=is_present(T,x->history); //it's a prolongation - do we have a parent ?
308 
309  if (!g) return 0; //if not - kill him !
310 
311  poly lmX=pMDivide(x->lead,g->root);
312  pSetCoeff0(lmX,nInit(1));
313 
314 /* if ((f=is_div_(F,lmX)) != NULL)
315  {
316  int pX=pow_(lmX);
317  int phX=pow_(x->history);
318 
319  if (pX!=phX)
320  {
321  int phF=pow_(f->history);
322  if (pX >= (phX+phF))
323  {
324  pLmDelete(&lmX);
325  //x->root=NULL;
326  return 0;
327  }
328 
329  for(int i=0, gg=0 ; i<currRing->N;i++)
330  if ((g1=pGetExp(x->history,i+1)) > (f1=pGetExp(f->history,i+1)))
331  gg+=g1;
332  else
333  gg+=f1;
334 
335  if (pX > gg)
336  {
337  pLmDelete(&lmX);
338  return 0;
339  }
340  int pF=pow_(f->root);
341 
342  if ((pX == pF) && (pF == phF))
343  f->history=x->history;
344  }
345  }
346 
347  pLmDelete(&lmX);
348 
349 */
350  x->root=pCopy(g->root);
351  x->root_l=g->root_l;
352 
353  x->root=pMult(x->root,lmX);
354 
355  pTest(x->root);
356 
357  x->prolonged=-1;
358 
359  return 1;
360 }

Variable Documentation

◆ degree_compatible

int degree_compatible
static

Definition at line 35 of file janet.cc.

◆ FreeNodes

NodeM* FreeNodes
static

Definition at line 34 of file janet.cc.

◆ G

TreeM* G
static

Definition at line 32 of file janet.cc.

◆ h

Poly* h
static

Definition at line 972 of file janet.cc.

◆ jDeg

pFDegProc jDeg

Definition at line 43 of file janet.cc.

◆ ListGreatMove

int(* ListGreatMove) (jList *, jList *, poly)
static

Definition at line 36 of file janet.cc.

◆ Mask

int Mask[8] ={0x80,0x40,0x20,0x10,0x8,0x4,0x2,0x1}
static

Definition at line 37 of file janet.cc.

◆ offset

int offset
static

Definition at line 30 of file janet.cc.

◆ Q

jList * Q
static

Definition at line 31 of file janet.cc.

◆ T

jList* T
static

Definition at line 31 of file janet.cc.

◆ temp_l

Poly* temp_l
static

Definition at line 756 of file janet.cc.

DestroyPoly
void DestroyPoly(Poly *x)
Definition: janet.cc:384
ClearProl
void ClearProl(Poly *x, int i)
Definition: janet.cc:447
ReducePoly
int ReducePoly(Poly *x, poly from, Poly *y)
Definition: janet.cc:120
FALSE
#define FALSE
Definition: auxiliary.h:94
InitLead
void InitLead(Poly *p)
Definition: janet.cc:410
pIsConstant
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:223
temp_l
static Poly * temp_l
Definition: janet.cc:756
f
FILE * f
Definition: checklibs.c:9
Poly::changed
int changed
Definition: janet.h:22
Poly
Definition: janet.h:14
offset
static int offset
Definition: janet.cc:30
DestroyFreeNodes
void DestroyFreeNodes()
Definition: janet.cc:777
k
int k
Definition: cfEzgcd.cc:92
pLmFree
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition: polys.h:68
is_present
Poly * is_present(jList *F, poly x)
Definition: janet.cc:730
x
Variable x
Definition: cfModGcd.cc:4023
Poly::prolonged
int prolonged
Definition: janet.h:23
y
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
InsertInList
void InsertInList(jList *x, Poly *y)
Definition: janet.cc:553
ForEachPNF
void ForEachPNF(jList *x, int i)
Definition: janet.cc:693
pGetExp
#define pGetExp(p, i)
Exponent.
Definition: polys.h:40
NFListQ
void NFListQ()
Definition: janet.cc:632
Poly::root_b
kBucket_pt root_b
Definition: janet.h:17
kBucketPolyRed
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition: kbuckets.cc:1075
Poly::history
poly history
Definition: janet.h:19
create
NodeM * create()
Definition: janet.cc:758
g
g
Definition: cfModGcd.cc:4031
FreeNodes
static NodeM * FreeNodes
Definition: janet.cc:34
GetProl
int GetProl(Poly *x, int i)
Definition: janet.cc:437
kBucketGetLm
const poly kBucketGetLm(kBucket_pt bucket)
Definition: kbuckets.cc:502
pDelete
#define pDelete(p_ptr)
Definition: polys.h:174
p_SimpleContent
void p_SimpleContent(poly ph, int smax, const ring r)
Definition: p_polys.cc:2489
Variable::next
Variable next() const
Definition: factory.h:137
pMult
#define pMult(p, q)
Definition: polys.h:194
InsertInCount
void InsertInCount(jList *x, Poly *y)
Definition: janet.cc:572
pIncrExp
#define pIncrExp(p, i)
Definition: polys.h:42
InitHistory
void InitHistory(Poly *p)
Definition: janet.cc:403
TreeM
TreeM
Definition: janet.h:46
pLength
static unsigned pLength(poly a)
Definition: p_polys.h:184
SetMult
void SetMult(Poly *x, int i)
Definition: janet.cc:427
NodeM
NodeM
Definition: janet.h:40
DestroyTree
void DestroyTree(NodeM *G)
Definition: janet.cc:805
ForEachControlProlong
void ForEachControlProlong(jList *x)
Definition: janet.cc:704
ListNode
ListNode
Definition: janet.h:29
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
jList::root
ListNode * root
Definition: janet.h:36
is_div_upper
Poly * is_div_upper(poly item, NodeM *x, int from)
Definition: janet.cc:847
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
PNF
void PNF(Poly *p, TreeM *F)
Definition: janet.cc:144
kBucketDestroy
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition: kbuckets.cc:212
LCI
ListNode * LCI
Definition: janet.h:48
GCMA
#define GCMA(sz)
Definition: janet.h:7
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
pTest
#define pTest(p)
Definition: polys.h:396
pow_
#define pow_(x)
Definition: janet.cc:44
kBucketInit
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition: kbuckets.cc:489
jDeg
pFDegProc jDeg
Definition: janet.cc:43
T
static jList * T
Definition: janet.cc:31
NFL
void NFL(Poly *p, TreeM *F)
Definition: janet.cc:188
h
static Poly * h
Definition: janet.cc:972
LI
ListNode ** LI
Definition: janet.h:51
Poly::mult
char * mult
Definition: janet.h:21
Mask
static int Mask[8]
Definition: janet.cc:37
degree_compatible
static int degree_compatible
Definition: janet.cc:35
pIter
#define pIter(p)
Definition: monomials.h:35
LengthCompare
int LengthCompare(poly p1, poly p2)
Definition: janet.cc:452
SetProl
void SetProl(Poly *x, int i)
Definition: janet.cc:442
InitProl
void InitProl(Poly *p)
Definition: janet.cc:417
ListGreatMoveDegree
int ListGreatMoveDegree(jList *A, jList *B, poly x)
Definition: janet.cc:600
pp
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
kBucketClear
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition: kbuckets.cc:517
pMDivide
#define pMDivide(a, b)
Definition: polys.h:275
ProlVar
void ProlVar(Poly *temp, int i)
Definition: janet.cc:481
ksOldSpolyRed
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
Definition: kInline.h:1041
ClearMult
void ClearMult(Poly *x, int i)
Definition: janet.cc:432
pLmInit
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:62
DestroyListNode
void DestroyListNode(ListNode *x)
Definition: janet.cc:503
CreateListNode
ListNode * CreateListNode(Poly *x)
Definition: janet.cc:509
p_ContentForGB
void p_ContentForGB(poly ph, const ring r)
Definition: p_polys.cc:2280
p_Deg
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:578
ClearMultiplicative
static void ClearMultiplicative(NodeM *xx, int i)
Definition: janet.cc:895
GCF
#define GCF(x)
Definition: janet.h:8
min
static int min(int a, int b)
Definition: fast_mult.cc:268
p_Copy_noCheck
static poly p_Copy_noCheck(poly p, const ring r)
returns a copy of p (without any additional testing)
Definition: p_polys.h:788
FindMinList
Poly * FindMinList(jList *L)
Definition: janet.cc:518
Print
#define Print
Definition: emacs.cc:79
B
b *CanonicalForm B
Definition: facBivar.cc:52
ListGreatMove
static int(* ListGreatMove)(jList *, jList *, poly)
Definition: janet.cc:36
pSetCoeff0
#define pSetCoeff0(p, n)
Definition: monomials.h:57
GCM
#define GCM(sz)
Definition: janet.h:6
Poly::root
poly root
Definition: janet.h:16
WarnS
#define WarnS
Definition: emacs.cc:77
Q
static jList * Q
Definition: janet.cc:31
NULL
#define NULL
Definition: omList.c:9
is_div_
Poly * is_div_(TreeM *tree, poly item)
Definition: janet.cc:854
ControlProlong
void ControlProlong(Poly *x)
Definition: janet.cc:393
pSetm
#define pSetm(p)
Definition: polys.h:254
insert_
void insert_(TreeM **tree, Poly *item)
Definition: janet.cc:913
l
int l
Definition: cfEzgcd.cc:93
ReducePolyLead
int ReducePolyLead(Poly *x, Poly *y)
Definition: janet.cc:75
nDelete
#define nDelete(n)
Definition: numbers.h:16
ProlCompare
int ProlCompare(Poly *item1, Poly *item2)
Definition: janet.cc:464
ksOldSpolyTail
void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r)
Definition: kInline.h:1071
Poly::lead
poly lead
Definition: janet.h:20
p_Totaldegree
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1426
p
int p
Definition: cfModGcd.cc:4019
CountList
int CountList(jList *Q)
Definition: janet.cc:618
div_l
void div_l(poly item, NodeM *x, int from)
Definition: janet.cc:833
kBucketCreate
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition: kbuckets.cc:205
nInit
#define nInit(i)
Definition: numbers.h:24
pLmCmp
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition: polys.h:101
count
int status int void size_t count
Definition: si_signals.h:58
GetMult
int GetMult(Poly *x, int i)
Definition: janet.cc:422
ListGreatMoveOrder
int ListGreatMoveOrder(jList *A, jList *B, poly x)
Definition: janet.cc:583
pCopy
#define pCopy(p)
return a copy of the poly
Definition: polys.h:173
Define
void Define(TreeM **G)
Definition: janet.cc:816
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:42
G
static TreeM * G
Definition: janet.cc:32
ValidatePoly
int ValidatePoly(Poly *x, TreeM *)
Definition: janet.cc:300
A
#define A
Definition: sirandom.c:23
NewPoly
Poly * NewPoly(poly p)
Definition: janet.cc:362
Poly::root_l
int root_l
Definition: janet.h:18
T2G
void T2G()
Definition: janet.cc:1086
sp_div
int sp_div(poly m1, poly m2, int from)
Definition: janet.cc:822
nSize
#define nSize(n)
Definition: numbers.h:39