My Project  debian-1:4.1.1-p2+ds-4build3
cohomo.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT - Stainly
6 */
7 
8 #include "kernel/mod2.h"
9 
10 #include "omalloc/omalloc.h"
11 #include "misc/mylimits.h"
12 #include "libpolys/misc/intvec.h"
13 #include <assert.h>
14 #include <unistd.h>
15 
19 #include "cohomo.h"//for my thing
20 #include "kernel/GBEngine/tgb.h"//
21 #include "Singular/ipid.h"//for ggetid
22 #include "polys/monomials/ring.h"
24 #include "polys/simpleideals.h"
25 #include "Singular/lists.h"
26 #include "kernel/linear_algebra/linearAlgebra.h"//for printNumber
27 #include "kernel/GBEngine/kstd1.h"//for gb
28 
29 
30 // #include <kernel/structs.h>
31 // #include <kernel/polys.h>
32 //ADICHANGES:
33 #include <kernel/ideals.h>
34 // #include <kernel/GBEngine/kstd1.h>
35 // #include<gmp.h>
36 // #include<vector>
37 
38 //# define omsai 1
39 //#if omsai
40 //#if HAVE_STANLEYREISNER
41 #if 1
42 
46 #include <coeffs/numbers.h>
47 #include <vector>
48 #include <Singular/ipshell.h>
49 #include <Singular/libsingular.h>
50 
51 
52 
53 
54 
55 
56 
57 /******************************************************************************/
58 
59 
60 
61 
62 
63 /***************************print***********************************************/
64 //print vector
65 void listprint(std::vector<int> vec)
66 {
67  int i;
68  for(i=0;i<vec.size();i++)
69  {
70  Print(" _[%d]=%d\n",i+1,vec[i]);
71  PrintLn();
72  }
73  if(vec.size()==0)
74  {
75  PrintS(" _[1]= \n");
76  PrintLn();
77  }
78 }
79 
80 
81 //print vector of vectors
82 void listsprint(std::vector<std::vector<int> > posMat)
83 {
84  int i,j;
85  for(i=0;i<posMat.size();i++)
86  {
87  Print("[%d]:\n",i+1);
88  listprint(posMat[i]);
89  Print("\n");
90  PrintLn();
91  }
92  if(posMat.size()==0)
93  {
94  PrintS("[1]:\n");
95  PrintLn();
96  }
97 }
98 
99 
100 
101 void id_print(ideal h)
102 {
103  int i;
104  for(i=0;i<IDELEMS(h);i++)
105  {
106  Print(" [%d]\n",i+1);
107  pWrite(h->m[i]);
108  PrintLn();
109  //PrintS(",");
110  }
111 }
112 
113 
114 
115 
116 /************************only for T^2**********************************/
117 void lpprint( std::vector<poly> pv)
118 {
119  for(int i=0;i<pv.size();i++)
120  {
121  Print(" _[%d]=",i+1);
122  pWrite(pv[i]);
123  }
124  if(pv.size()==0)
125  {
126  PrintS(" _[1]= \n");
127  PrintLn();
128  }
129 }
130 
131 
132 
133 
134 void lpsprint(std::vector<std::vector<poly> > pvs)
135 {
136  for(int i=0;i<pvs.size();i++)
137  {
138  Print("[%d]:\n",i+1);
139  lpprint(pvs[i]);
140  Print("\n");
141  PrintLn();
142  }
143  if(pvs.size()==0)
144  {
145  PrintS("[1]:\n");
146  PrintLn();
147  }
148 }
149 
150 
151 
152 
153 
154 
155 /*****************************About simplicial complex and stanly-reisner ring**************************/
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 //h1 minus h2
167 ideal idMinus(ideal h1,ideal h2)
168 {
169  ideal h=idInit(1,1);
170  int i,j,eq=0;
171  for(i=0;i<IDELEMS(h1);i++)
172  {
173  eq=0;
174  for(j=0;j<IDELEMS(h2);j++)
175  {
176  if(p_EqualPolys(h1->m[i],h2->m[j], currRing))
177  {
178  eq=1;
179  break;
180  }
181  }
182  if(eq==0)
183  {
184  idInsertPoly(h, h1->m[i]);
185  }
186  }
187  idSkipZeroes(h);
188  return h;
189 }
190 
191 
192 
193 //If poly P is squarefree, returns 1
194 //returns 0 otherwise,
195 bool p_Ifsfree(poly P)
196 {
197  int i,sf=1;
198  for(i=1;i<=rVar(currRing);i++)
199  {
200  if (pGetExp(P,i)>1)
201  {
202  sf=0;
203  break;
204  }
205  }
206  return sf;
207 }
208 
209 /*find all squarefree monomials of degree deg in ideal h*/
210 ideal sfreemon(ideal h,int deg)
211 {
212  int i,j,t;
213  ideal temp;
214  temp=idInit(1,1);
215  if(!idIs0(h))
216  {
217  for(j=0;j<IDELEMS(h);j++)
218  {
219  if((p_Ifsfree(h->m[j]))&&(pTotaldegree(h->m[j])==deg))
220  {
221  idInsertPoly(temp, h->m[j]);
222  }
223  }
224  idSkipZeroes(temp);
225  }
226  return temp;
227 }
228 
229 
230 
231 
232 
233 
234 
235 
236 
237 //full simplex represented by ideal.
238 //(all the squarefree monomials over the polynomial ring)
239 ideal id_sfmon()
240 {
241  ideal asfmons,sfmons,mons,p;
242  int j;
243  mons=id_MaxIdeal(1, currRing);
244  asfmons=sfreemon(mons,1);
245  for(j=2;j<=rVar(currRing);j++)
246  {
247  mons=id_MaxIdeal(j, currRing);
248  sfmons=sfreemon(mons,j);
249  asfmons=id_Add(asfmons,sfmons,currRing);
250  }
251  return asfmons;
252 }
253 
254 
255 
256 
257 
258 
259 
260 //if the input ideal is simplicial complex, returns the stanley-reisner ideal,
261 //if the input ideal is stanley-reisner ideal, returns the monomial ideal according to simplicial complex.
262 //(nonfaces and faces).
263 //returns the complement of the ideal h
264 ideal id_complement(ideal h)
265 {
266  int j;
267  ideal i1=id_sfmon();
268  ideal i2=idMinus(i1,h);
269  return (i2);
270 }
271 
272 
273 
274 
275 
276 
277 
278 
279 
280 
281 
282 
283 //returns the monomials in the quotient ring R/(h1+h2) which have degree deg,
284 //and R is currRing
285 ideal qringadd(ideal h1, ideal h2,int deg)
286 {
287  ideal h,qrh;
288  int i;
289  h=idAdd(h1,h2);
290  qrh=scKBase(deg,h);
291  return qrh;
292 }
293 
294 
295 
296 
297 //returns the maximal degree of the monomials in ideal h
298 int id_maxdeg(ideal h)
299 {
300  int i,max;
301  max=pTotaldegree(h->m[0]);
302  for(i=1;i<IDELEMS(h);i++)
303  {
304  if(pTotaldegree(h->m[i])>max)
305  max=pTotaldegree(h->m[i]);
306  }
307  return (max);
308 }
309 
310 //input ideal h is the ideal associated to simplicial complex,
311 //and returns the Stanley-Reisner ideal(minimal generators)
312 ideal idsrRing(ideal h)
313 {
314  int max,i,j,n;
315  ideal hc=idCopy(h);
316  //Print("This is the complement generators\n");
317  //id_print(hc);
318  ideal pp,qq,rsr,ppp;
319  for(i=1;i<=rVar(currRing);i++)
320  {
321  pp=sfreemon(hc,i);
322  pp=scKBase(i,pp);//quotient ring (R/I_i)_i
323  if(!idIs0(pp))
324  {
325  pp=sfreemon(pp,i);
326  rsr=pp;
327  //Print("This is the first quotient generators %d:\n",i);
328  //id_print(rsr);
329  break;
330  }
331  }
332  for(n=i+1;n<=rVar(currRing);n++)
333  {
334  qq=sfreemon(hc,n);
335  if(!idIs0(qq))
336  {
337  pp=qringadd(qq,rsr,n);
338  ppp=sfreemon(pp,n);
339  //Print("This is the quotient generators %d:\n",n);
340  //id_print(ppp);
341  rsr=idAdd(rsr,ppp);
342  //Print("This is the current minimal set\n");
343  //id_print(rsr);
344  }
345  }
346  idSkipZeroes(rsr);
347  //PrintS("This is the minimal generators:\n");
348  //id_print(rsr);
349  return rsr;
350 }
351 
352 
353 
354 //returns the set of subset of p
355 ideal SimFacset(poly p)
356 {
357  int i,j;
358  ideal h1,mons;
359  int max=pTotaldegree(p);
360  ideal id_re=idInit(1,1);
361  for(i=1;i<max;i++)
362  {
363  mons=id_MaxIdeal(i, currRing);
364  h1=sfreemon(mons,i);
365  for(j=0;j<IDELEMS(h1);j++)
366  {
367  if(p_DivisibleBy(h1->m[j],p,currRing))
368  idInsertPoly(id_re, h1->m[j]);
369  }
370  }
371  idSkipZeroes(id_re);
372  //PrintS("This is the facset\n");
373  //id_print(id_re);
374  return id_re;
375 }
376 
377 //complicated version(print the polynomial set which can make the input to be a simplex)
378 //input h is at least part of faces
379 bool IsSimplex(ideal h)
380 {
381  int i,j,ifbreak=0;
382  ideal id_re;
383  ideal id_so=idCopy(h);
384  int max=id_maxdeg(h);
385  for(i=0;i<IDELEMS(h);i++)
386  {
387  id_re=SimFacset(h->m[i]);
388  //id_print(id_re);
389  if(!idIs0(id_re))
390  {
391  id_so=idAdd(id_so, id_re);
392  }
393  }
394  idSkipZeroes(id_so);
395  if(!idIs0(idMinus(id_so,id_re)))
396  {
397  PrintS("It is not simplex.\n");
398  PrintS("This is the simplicial complex:\n");
399  id_print(id_so);
400  return false;
401  }
402  PrintS("It is simplex.\n");
403  return true;
404 }
405 
406 
407 //input is the subset of the Stainly-Reisner ideal
408 //returns the faces
409 ideal complementsimplex(ideal h)
410 {
411  int i,j;poly p;
412  ideal h1=idInit(1,1);
413  ideal pp;
414  ideal h3=idInit(1,1);
415  for(i=1;i<=rVar(currRing);i++)
416  {
417  p = pOne(); pSetExp(p, i, 2); pSetm(p); pSetCoeff(p, nInit(1));
418  //pWrite(p);
419  idInsertPoly(h1, p);
420  }
421  idSkipZeroes(h1);
422  ideal h2=idAdd(h,h1);
423  pp=scKBase(1,h2);
424  h3=idCopy(pp);
425  for(j=2;j<=rVar(currRing);j++)
426  {
427  pp=scKBase(j,h2);
428  h3=idAdd(h3,pp);
429  }
430  PrintS("This is the simplicial complex:\n");
431  id_print(h3);
432  return (h3);
433 }
434 
435 
436 
437 
438 /*************operations for vectors(sets)*********/
439 
440 //returns true if integer n is in vector vec,
441 //otherwise returns false
442 bool IsinL(int a,std::vector<int> badset)
443 {
444  int i;
445  for(i=0;i<badset.size();i++)
446  {
447  if(a==badset[i])
448  {
449  return true;
450  }
451  }
452  return false;
453 }
454 
455 
456 
457 
458 
459 //intersection of vectors p and q, returns empty if they are disjoint
460 std::vector<int> vecIntersection(std::vector<int> p,std::vector<int> q)
461 {
462  int i;
463  std::vector<int> inte;
464  for(i=0;i<p.size();i++)
465  {
466  if(IsinL(p[i],q))
467  inte.push_back(p[i]);
468  }
469  //listprint(inte);
470  return inte;
471 }
472 
473 
474 
475 
476 
477 
478 
479 
480 
481 //returns true if vec1 is equal to vec2 (including the order)
482 bool vEv(std::vector<int> vec1,std::vector<int> vec2)
483 {
484  int i,j;
485  int lg1=vec1.size(),lg2=vec2.size();
486  if(lg1!=lg2)
487  {
488  return false;
489  }
490  else
491  {
492  for(j=0;j<vec1.size();j++)
493  {
494  if(vec1[j]!=vec2[j])
495  return false;
496  }
497  }
498  return true;
499 }
500 
501 
502 
503 
504 //returns true if vec1 is contained in vec2
505 bool vsubset(std::vector<int> vec1,std::vector<int> vec2)
506 {
507  int i;
508  if(vec1.size()>vec2.size())
509  return false;
510  for(i=0;i<vec1.size();i++)
511  {
512  if(!IsinL(vec1[i],vec2))
513  return false;
514  }
515  return true;
516 }
517 
518 //not strictly equal(order doesn't matter)
519 bool vEvl(std::vector<int> vec1,std::vector<int> vec2)
520 {
521  if(vec1.size()==0 && vec2.size()==0)
522  return true;
523  if(vsubset(vec1,vec2)&&vsubset(vec2,vec1))
524  return true;
525  return false;
526 }
527 
528 
529 //the length of vec must be same to it of the elements of vecs (not strictly same)
530 //returns false if vec is not in vecs
531 bool vInvsl(std::vector<int> vec, std::vector<std::vector<int> > vecs)
532 {
533  int i;
534  for(i=0;i<vecs.size();i++)
535  {
536  if(vEvl(vec,vecs[i]))
537  {
538  return true;
539  }
540  }
541  return false;
542 }
543 
544 
545 //the length of vec must be same to it of the elements of vecs (strictly same)
546 //returns the position of vec in vecs,
547 //returns -1 if vec is not in vecs
548 int vInvs(std::vector<int> vec, std::vector<std::vector<int> > vecs)
549 {
550  int i;
551  for(i=0;i<vecs.size();i++)
552  {
553  if(vEv(vec,vecs[i]))
554  {
555  //Print("This is the %dth variable\n",i+1);
556  return i+1;
557  }
558  }
559  //Print("This is not the new variable\n");
560  //listprint(vec);
561  return -1;
562 }
563 
564 
565 
566 //returns the union of two vectors(like the union of sets)
567 std::vector<int> vecUnion(std::vector<int> vec1, std::vector<int> vec2)
568 {
569  std::vector<int> vec=vec1;
570  int i;
571  for(i=0;i<vec2.size();i++)
572  {
573  if(!IsinL(vec2[i],vec))
574  vec.push_back(vec2[i]);
575  }
576  return vec;
577 }
578 
579 
580 
581 std::vector<int> vecMinus(std::vector<int> vec1,std::vector<int> vec2)
582 {
583  std::vector<int> vec;
584  for(int i=0;i<vec1.size();i++)
585  {
586  if(!IsinL(vec1[i],vec2))
587  {
588  vec.push_back(vec1[i]);
589  }
590  }
591  return vec;
592 }
593 
594 
595 
596 
597 /********************Procedures for T1(M method and N method) ***********/
598 
599 
600 
601 
602 
603 
604 
605 
606 
607 //P should be monomial(not used) vector version of poly support(poly p)
608 std::vector<int> support1(poly p)
609 {
610  int j;
611  std::vector<int> supset;
612  for(j=1;j<=rVar(currRing);j++)
613  {
614  if(pGetExp(p,j)>0)
615  {
616  supset.push_back(j);
617  }
618  }
619  return (supset);
620 }
621 
622 //simplicial complex(the faces set is ideal h)
623 std::vector<std::vector<int> > supports(ideal h)
624 {
625  std::vector<std::vector<int> > vecs;
626  std::vector<int> vec;
627  if(!idIs0(h))
628  {
629  for(int s=0;s<IDELEMS(h);s++)
630  {
631  //pWrite(h->m[s]);
632  vec=support1(h->m[s]);
633  vecs.push_back(vec);
634  }
635  }
636  return vecs;
637 }
638 
639 
640 
641 
642 
643 //h is ideal( monomial ideal) associated to simplicial complex
644 //returns the all the monomials x^b (x^b must be able to divide at least one monomial in Stanley-Reisner ring)
645 ideal findb(ideal h)
646 {
647  ideal ib=id_sfmon();
648  ideal nonf=id_complement(h);
649  ideal bset=idInit(1,1);
650  poly e=pOne();
651  int i,j;
652  for(i=0;i<IDELEMS(ib);i++)
653  {
654  for(j=0;j<IDELEMS(nonf);j++)
655  {
656  if(p_DivisibleBy(ib->m[i],nonf->m[j],currRing))
657  {
658  idInsertPoly(bset, ib->m[i]);
659  break;
660  }
661  }
662  }
663  idInsertPoly(bset,e);
664  idSkipZeroes(bset);
665  return bset;
666 }
667 
668 
669 
670 
671 //h is ideal(monomial ideal associated to simplicial complex
672 //1.poly S is x^b
673 //2.and deg(x^a)=deg(x^b)
674 //3.x^a and x^a have disjoint supports
675 //returns all the possible x^a according conditions 1. 2. 3.
676 ideal finda(ideal h,poly S,int ddeg)
677 {
678  ideal aset=idInit(1,1);
679  poly e=pOne();
680  ideal h2=id_complement(h);
681  poly p;
682  int i,j,deg1=pTotaldegree(S);
683  int tdeg=deg1+ddeg;
684  if(tdeg!=0)
685  {
686  std::vector<int> v,bv=support1(S),in;
687  std::vector<std::vector<int> > hvs=supports(h);
688  ideal ia=id_MaxIdeal(tdeg, currRing);
689  for(i=0;i<IDELEMS(ia);i++)
690  {
691  //p=support(ia->m[i]);
692  v=support1(ia->m[i]);
693  in=vecIntersection(v,bv);
694  if(vInvsl(v,hvs)&&in.size()==0)
695  {
696  idInsertPoly(aset, ia->m[i]);
697  }
698  }
699  //idInsertPoly(aset,e);
700  idSkipZeroes(aset);
701  }
702  else idInsertPoly(aset,e);
703  return(aset);
704 }
705 
706 
707 
708 
709 
710 
711 
712 
713 //returns true if support(p) union support(a) minus support(b) is face,
714 //otherwise returns false
715 //not be used yet, (the vector version of mabcondition)
716 bool mabconditionv(std::vector<std::vector<int> > hvs,std::vector<int> pv,std::vector<int> av,std::vector<int> bv)
717 {
718  std::vector<int> uv=vecUnion(pv,av);
719  uv=vecMinus(uv,bv);
720 //Print("this is the support of p union a minus b\n");
721 //listprint(uv);
722  //Print("this is the support of ideal\n");
723  //listsprint(hvs);
724  if(vInvsl(uv,hvs))
725  {
726  return(true);
727  }
728  return(false);
729 }
730 
731 
732 std::vector<std::vector<int> > Mabv(ideal h,poly a,poly b)
733 {
734  std::vector<int> pv;
735  std::vector<std::vector<int> > vecs;
736  //Print("this is the support of p\n");
737  //listprint(pv);
738  std::vector<int> av=support1(a);
739 //Print("this is the support of a\n");
740 //listprint(av);
741  std::vector<int> bv=support1(b);
742 //Print("this is the support of b\n");
743 //listprint(bv);
744  ideal h2=id_complement(h);
745  std::vector<std::vector<int> > hvs=supports(h);
746  std::vector<std::vector<int> > h2v=supports(h2);
747  std::vector<int> vec;
748  for(int i=0;i<h2v.size();i++)
749  {
750  pv=h2v[i];
751  if(mabconditionv(hvs,pv,av,bv))
752  {
753  vecs.push_back(pv);
754  }
755  }
756  return vecs;
757 }
758 
759 
760 
761 
762 
763 
764 
765 
766 
767 
768 
769 /***************************************************************************/
770 //For solving the equations which has form of x_i-x_j.(equations got by T_1)
771 /***************************************************************************/
772 
773 
774 
775 //subroutine for soleli1
776 std::vector<int> eli1(std::vector<int> eq1,std::vector<int> eq2)
777 {
778  int i,j;
779  std::vector<int> eq;
780  if(eq1[0]==eq2[0])
781  {
782  i=eq1[1];j=eq2[1];
783  eq.push_back(i);
784  eq.push_back(j);
785  }
786  else
787  {
788  eq=eq2;
789  }
790  return(eq);
791 }
792 
793 
794 //get triangular form(eqs.size()>0)
795 std::vector<std::vector<int> > soleli1( std::vector<std::vector<int> > eqs)
796 {
797  int i,j;std::vector<std::vector<int> > re;
798  std::vector<std::vector<int> > pre=eqs,ppre;
799  if(eqs.size()>0)
800  {
801  re.push_back(eqs[0]);
802  pre.erase(pre.begin());
803  }
804  //listsprint(pre);
805  std::vector<int> yaya;
806  for(i=0;i<re.size(),pre.size()>0;i++)
807  {
808  yaya=eli1(re[i],pre[0]);
809  //listprint(yaya);
810  re.push_back(yaya);
811  for(j=1;j<pre.size();j++)
812  {
813  //listprint(pre[j]);
814  ppre.push_back(eli1(re[i],pre[j]));
815  }
816  pre=ppre;
817  ppre.resize(0);
818  }
819  return re;
820 }
821 
822 
823 // input is a set of equations who is of triangular form(every equations has a form of x_i-x_j) n is the number of variables
824 //get the free variables and the dimension
825 std::vector<int> freevars(int n, std::vector<int> bset, std::vector<std::vector<int> > gset)
826 {
827  int ql=gset.size();
828  int bl=bset.size();
829  std::vector<int> mvar;
830  std::vector<int> fvar;
831  int i;
832  for(i=0;i<bl;i++)
833  {
834  mvar.push_back(bset[i]);
835  }
836  for(i=0;i<ql;i++)
837  {
838  mvar.push_back(gset[i][0]);
839  }
840  for(i=1;i<=n;i++)
841  {
842  if(!IsinL(i,mvar))
843  {
844  fvar.push_back(i);
845  }
846  }
847  return fvar;
848 }
849 
850 
851 //return the set of free variables except vnum
852 std::vector<int> fvarsvalue(int vnum, std::vector<int> fvars)
853 {
854  int i;std::vector<int> fset=fvars;
855  for(i=0;i<fset.size();i++)
856  {
857  if(fset[i]==vnum)
858  {
859  fset.erase(fset.begin()+i);
860  return fset;
861  }
862  }
863 }
864 
865 
866 
867 
868 
869 std::vector<std::vector<int> > vAbsorb( std::vector<int> bset,std::vector<std::vector<int> > gset)
870 {
871  int i,j,m;
872  std::vector<int> badset=bset;
873  int bl=badset.size();
874  int gl=gset.size();
875  for(i=0;i<bl;i++)
876  {
877  m=badset[i];
878  for(j=0;j<gl;j++)
879  {
880  if(gset[j][0]==m && !IsinL(gset[j][1],badset))
881  {
882  badset.push_back(gset[j][1]);
883  gset.erase(gset.begin()+j);
884  j--;
885  gl--;
886  bl++;
887  }
888  else if(!IsinL(gset[j][0],badset) && gset[j][1]==m)
889  {
890  badset.push_back(gset[j][0]);
891  gset.erase(gset.begin()+j);
892  j--;
893  gl--;
894  bl++;
895  }
896  else if(IsinL(gset[j][0],badset) && IsinL(gset[j][1],badset))
897  {
898  gset.erase(gset.begin()+j);
899  j--;
900  gl--;
901  }
902  else
903  {
904  ;
905  }
906  }
907  }
908  if(badset.size()==0) badset.push_back(0);
909  gset.push_back(badset);
910  return gset;
911 }
912 
913 
914 
915 
916 
917 
918 //the new variables are started from 1
919 std::vector<int> vecbase1(int num, std::vector<int> oset)
920 {
921  int i;
922  std::vector<int> base;
923  for(i=0;i<num;i++)
924  {
925  if(IsinL(i+1,oset))
926  base.push_back(1);
927  else
928  base.push_back(0);
929  }
930  return base;
931 }
932 
933 
934 
935 //returns a vector which has length of n,
936 //and all the entries are 0.
937 std::vector<int> make0(int n)
938 {
939  int i;
940  std::vector<int> vec;
941  for(i=0;i<n;i++)
942  {
943  vec.push_back(0);
944  }
945  return vec;
946 }
947 
948 
949 //returns a vector which has length of n,
950 //and all the entries are 1.
951 std::vector<int> make1(int n)
952 {
953  int i;
954  std::vector<int> vec;
955  for(i=0;i<n;i++)
956  {
957  vec.push_back(1);
958  }
959  return vec;
960 }
961 
962 
963 
964 
965 //input gset must be the triangular form after zero absorbing according to the badset,
966 //bset must be the zero set after absorbing.
967 std::vector<int> ofindbases1(int num, int vnum, std::vector<int> bset,std::vector<std::vector<int> > gset)
968 {
969  int i,j,m;std::vector<std::vector<int> > goodset;
970  std::vector<int> fvars=freevars(num, bset, gset);
971  std::vector<int> zset=fvarsvalue(vnum, fvars);
972  zset=vecUnion(zset,bset);
973  std::vector<int> oset;
974  oset.push_back(vnum);
975  goodset=vAbsorb(oset, gset);
976  oset=goodset[goodset.size()-1];
977  goodset.erase(goodset.end());
978  //PrintS("This is the 1 set:\n");
979  //listprint(oset);
980  //goodset=vAbsorb(zset, goodset);
981  //zset=goodset[goodset.size()-1];
982  //goodset.erase(goodset.end());
983  //PrintS("This is the 0 set:\n");
984  //listprint(zset);
985  //Print("thet size of goodset is %ld\n", goodset.size());
986  std::vector<int> base= vecbase1(num, oset);
987  return base;
988 }
989 
990 
991 
992 
993 
994 
995 
996 
997 //input gset must be the triangular form after zero absorbing according to the badset
998 //bset must be the zero set after absorbing
999 std::vector<std::vector<int> > ofindbases(int num, std::vector<int> bset,std::vector<std::vector<int> > gset)
1000 {
1001  int i,j,m;
1002  std::vector<int> base1;
1003  std::vector<std::vector<int> > bases;
1004  std::vector<int> fvars=freevars(num, bset, gset);
1005  if (fvars.size()==0)
1006  {
1007  base1=make0(num);
1008  bases.push_back(base1);
1009  }
1010  else
1011  {
1012  for(i=0;i<fvars.size();i++)
1013  {
1014  m=fvars[i];
1015  base1=ofindbases1(num, m, bset, gset);
1016  bases.push_back(base1);
1017  }
1018  }
1019  //PrintS("They are the bases for the solution space:\n");
1020  //listsprint(bases);
1021  return bases;
1022 }
1023 
1024 
1025 
1026 
1027 
1028 
1029 
1030 
1031 //gset is a set of equations which have forms of x_i-x_j
1032 //num is the number of varialbes also the length of the set which we need to consider
1033 //output is trigular form of gset and badset where x_i=0
1034 std::vector<std::vector<int> > eli2(int num,std::vector<int> bset,std::vector<std::vector<int> > gset)
1035 {
1036  int i,j;
1037  std::vector<int> badset;
1038  std::vector<std::vector<int> > goodset;
1039  std::vector<std::vector<int> > solve;
1040  if(gset.size()!=0)//gset is not empty
1041  {
1042 //find all the variables which are zeroes
1043 
1044  if(bset.size()!=0)//bset is not empty
1045  {
1046  goodset=vAbsorb(bset, gset);//e.g. x_1=0, put x_i into the badset if x_i-x_1=0 or x_1-x_i=0
1047  int m=goodset.size();
1048  badset=goodset[m-1];
1049  goodset.erase(goodset.end());
1050  }
1051  else //bset is empty
1052  {
1053  goodset=gset;//badset is empty
1054  }//goodset is already the set which doesn't contain zero variables
1055 
1056  goodset=soleli1(goodset);//get the triangular form of goodset
1057  //PrintS("the triangular form of the good set is:\n");
1058  solve=ofindbases(num,badset,goodset);
1059  // goodset.push_back(badset);
1060  //listsprint(goodset);
1061  }
1062  else
1063  {
1064  solve=ofindbases(num,bset,gset);
1065  }
1066  return solve;
1067 }
1068 
1069 
1070 /********************************************************************/
1071 
1072 
1073 //convert the vector to a polynomial w.r.t. current ring
1074 //vector vbase has length of currRing->N.
1075 poly pMake(std::vector<int> vbase)
1076 {
1077  int n=vbase.size();poly p,q=0;
1078  for(int i=0;i<n;i++)
1079  {
1080  if(vbase[i]!=0)
1081  {
1082  p = pOne();pSetExp(p, i+1, 1);pSetm(p);pSetCoeff(p, nInit(vbase[i]));
1083  q = pAdd(q, p);
1084  }
1085 
1086  }
1087  return q;
1088 }
1089 
1090 
1091 
1092 
1093 //convert the vectors to a ideal(for T^1)
1094 ideal idMake(std::vector<std::vector<int> > vecs)
1095 {
1096  int lv=vecs.size();poly p;
1097  int i,j;
1098  ideal id_re=idInit(1,1);
1099  for(i=0;i<lv;i++)
1100  {
1101  p=pMake(vecs[i]);
1102  idInsertPoly(id_re, p);
1103  }
1104  idSkipZeroes(id_re);
1105  return id_re;
1106 }
1107 
1108 
1109 
1110 /*****************************quotient ring of two ideals*********************/
1111 
1112 //the quotient ring of h1 respect to h2
1113 ideal idmodulo(ideal h1,ideal h2)
1114 {
1115  int i;
1116  ideal gb=kStd(h2,NULL,testHomog,NULL,NULL,0,0,NULL);
1117  ideal idq=kNF(gb,NULL,h1);
1118  idSkipZeroes(idq);
1119  return idq;
1120 }
1121 
1122 //returns the coeff of the monomial of polynomial p which involves the mth varialbe
1123 //assume the polynomial p has form of y1+y2+...
1124 int pcoef(poly p, int m)
1125 {
1126  int i,j,co;poly q=pCopy(p);
1127  for(i=1;i<=currRing->N;i++)
1128  {
1129  if(p_GetExp(q,m,currRing)!=0)
1130  {
1131  co=n_Int(pGetCoeff(q),currRing->cf);
1132  return co;
1133  }
1134  else
1135  q=pNext(q);
1136  }
1137  if(q!=NULL)
1138  co=0;
1139  return co;
1140 }
1141 
1142 //returns true if p involves the mth variable of the current ring
1143 bool vInp(int m,poly p)
1144 {
1145  int i;
1146  poly q=pCopy(p);
1147  while (q!=NULL)
1148  {
1149  if(p_GetExp(q,m,currRing)!=0)
1150  {
1151  return true;
1152  }
1153  q=pNext(q);
1154  }
1155  return false;
1156 }
1157 
1158 
1159 
1160 //returns the vector w.r.t. polynomial p
1161 std::vector<int> vMake(poly p)
1162 {
1163  int i;poly q=pCopy(p);
1164  std::vector<int> vbase;
1165  for(i=1;i<=currRing->N;i++)
1166  {
1167  if(vInp(i,p))
1168  {
1169  vbase.push_back(pcoef(p,i));
1170  }
1171  else
1172  {
1173  vbase.push_back(0);
1174  }
1175  }
1176  return (vbase);
1177 }
1178 
1179 
1180 //returns the vectors w.r.t. ideal h
1181 std::vector<std::vector<int> > vsMake(ideal h)
1182 {
1183  std::vector<int> vec;
1184  std::vector<std::vector<int> > vecs;
1185  int i;
1186  for(i=0;i<IDELEMS(h);i++)
1187  {
1188  vec=vMake(h->m[i]);
1189  vecs.push_back(vec);
1190  }
1191  return vecs;
1192 }
1193 
1194 
1195 //the quotient ring of two ideals which are represented by vectors,
1196 //the result is also represented by vector.
1197 std::vector<std::vector<int> > vecqring(std::vector<std::vector<int> > vec1, std::vector<std::vector<int> > vec2)
1198 {
1199  int i,j;
1200  ideal h1=idMake(vec1);
1201  //id_print(h1);
1202  ideal h2=idMake(vec2);
1203  //id_print(h2);
1204  ideal h=idmodulo(h1,h2);
1205  std::vector<std::vector<int> > vecs= vsMake(h);
1206  return vecs;
1207 }
1208 
1209 /***********************************************************/
1210 
1211 
1212 
1213 
1214 //returns the link of face a in simplicial complex X
1215 std::vector<std::vector<int> > links(poly a, ideal h)
1216 {
1217  int i;
1218  std::vector<std::vector<int> > lk,X=supports(h);
1219  std::vector<int> U,In,av=support1(a);
1220  for(i=0;i<X.size();i++)
1221  {
1222  U=vecUnion(av,X[i]);
1223  //PrintS("**********************\n");
1224  //listprint(X[i]);
1225  //PrintS("The union of them is:\n");
1226  //listprint(U);
1227  In=vecIntersection(av,X[i]);
1228  //PrintS("The intersection of them is:\n");
1229  //listprint(In);
1230  if( In.size()==0 && vInvsl(U,X))
1231  {
1232  //PrintS("The union of them is FACE and intersection is EMPTY!\n");
1233  lk.push_back(X[i]);
1234  }
1235  else
1236  {
1237  ;
1238  }
1239  }
1240  return lk;
1241 }
1242 
1243 
1244 
1245 
1246 /*vector version
1247 //returns the link of face a in simplicial complex X
1248 std::vector<std::vector<int> > links(std::vector<int> a, std::vector<std::vector<int> > X)
1249 {
1250  int i;
1251  std::vector<std::vector<int> > lk;
1252  std::vector<int> U;
1253  std::vector<int> In;
1254  for(i=0;i<X.size();i++)
1255  {
1256  U=vecUnion(a,X[i]);
1257  //PrintS("**********************\n");
1258  //listprint(X[i]);
1259  //PrintS("The union of them is:\n");
1260  //listprint(U);
1261  In=vecIntersection(a,X[i]);
1262  //PrintS("The intersection of them is:\n");
1263  //listprint(In);
1264  if( In.size()==0 && vInvsl(U,X))
1265  {
1266  //PrintS("The union of them is FACE and intersection is EMPTY!\n");
1267  lk.push_back(X[i]);
1268  }
1269  else
1270  {
1271  ;
1272  }
1273  }
1274  return lk;
1275 }
1276 */
1277 
1278 
1279 
1280 //input is a squarefree monomial p
1281 //output is all the squarefree monomials which could divid p(including p itself?)
1282 ideal psubset(poly p)
1283 {
1284  int i,j;
1285  ideal h1,mons;
1286  int max=pTotaldegree(p);
1287  ideal id_re=idInit(1,1);
1288  for(i=1;i<max;i++)
1289  {
1290  mons=id_MaxIdeal(i, currRing);
1291  h1=sfreemon(mons,i);
1292  for(j=0;j<IDELEMS(h1);j++)
1293  {
1294  if(p_DivisibleBy(h1->m[j],p,currRing))
1295  idInsertPoly(id_re, h1->m[j]);
1296  }
1297  }
1298  idSkipZeroes(id_re);
1299  //PrintS("This is the facset\n");
1300  //id_print(id_re);
1301  return id_re;
1302 }
1303 
1304 
1305 
1306 //inserts a new vector which has two elements a and b into vector gset (which is a vector of vectors)
1307 //(especially for gradedpiece1 and gradedpiece1n)
1308 std::vector<std::vector<int> > listsinsertlist(std::vector<std::vector<int> > gset, int a, int b)
1309 {
1310  std::vector<int> eq;
1311  eq.push_back(a);
1312  eq.push_back(b);
1313  gset.push_back(eq);
1314  return gset;
1315 }
1316 
1317 
1318 
1319 
1320 
1321 std::vector<int> makeequation(int i,int j, int t)
1322 {
1323  std::vector<int> equation;
1324  equation.push_back(i);
1325  equation.push_back(j);
1326  equation.push_back(t);
1327  //listprint(equation);
1328  return equation;
1329 }
1330 
1331 
1332 
1333 
1334 
1335 /****************************************************************/
1336 //only for solving the equations obtained from T^2
1337 //input should be a vector which has only 3 entries
1338 poly pMake3(std::vector<int> vbase)
1339 {
1340  int n=vbase.size();poly p,q=0;
1341  int co=1;
1342  //equmab(n);
1343  for(int i=0;i<3;i++)
1344  {
1345  if(vbase[i]!=0)
1346  {
1347  if(i==1) co=-1;
1348  p = pOne();pSetExp(p, vbase[i], 1);pSetm(p);pSetCoeff(p, nInit(co));
1349  //Print("attention! ");pWrite(p);
1350  }
1351  else p=0;
1352  q = pAdd(q, p);
1353  co=1;
1354  }
1355  //PrintS("the polynomial according to the metrix M is:\n");
1356  //listprint(vbase);
1357  //pWrite(q);
1358  return q;
1359 }
1360 
1361 
1362 ideal idMake3(std::vector<std::vector<int> > vecs)
1363 {
1364  ideal id_re=idInit(1,1);
1365  poly p;
1366  int i,lv=vecs.size();
1367  for(i=0;i<lv;i++)
1368  {
1369  //Print("The vector is: ");
1370  //listprint(vecs[i]);
1371  p=pMake3(vecs[i]);
1372  //Print("The polynomial is: ");
1373  //pWrite(p);
1374  idInsertPoly(id_re, p);
1375  }
1376  //PrintS("This is the metrix M:\n");
1377  //listsprint(vecs);
1378  //PrintS("the ideal according to metrix M is:\n");
1379  idSkipZeroes(id_re);
1380  return id_re;
1381 }
1382 
1383 /****************************************************************/
1384 
1385 //change the current ring to a new ring which is in num new variables
1386 void equmab(int num)
1387 {
1388  int i,j;
1389  //Print("There are %d variables in total.\n",num);
1390  ring r=currRing;
1391  char** tt;
1392  coeffs cf=nCopyCoeff(r->cf);
1393  tt=(char**)omAlloc(num*sizeof(char *));
1394  for(i=0; i <num; i++)
1395  {
1396  tt[i] = (char*)omalloc(10); //if required enlarge it later
1397  sprintf (tt[i], "t(%d)", i+1);
1398  tt[i]=omStrDup(tt[i]);
1399  //Print("%s\n",tt[i]);
1400  }
1401  ring R=rDefault(cf,num,tt,ringorder_lp);
1403  IDRING(h)=rCopy(R);
1404  rSetHdl(h);
1405 }
1406 
1407 
1408 //returns the trivial case of T^1
1409 //b must only contain one variable
1410 std::vector<int> subspace1(std::vector<std::vector<int> > mv, std::vector<int> bv)
1411 {
1412  int i;
1413  int num=mv.size();
1414  std::vector<int> base;
1415  std::vector<int> pv;
1416  for(i=0;i<num;i++)
1417  {
1418  if(IsinL(bv[0],mv[i]))
1419  base.push_back(1);
1420  else
1421  base.push_back(0);
1422  }
1423  return base;
1424 }
1425 
1426 
1427 
1428 
1429 
1430 
1431 /****************************************************************/
1432 //construct a monomial based on the support of it
1433 //returns a squarefree monomial
1434 poly pMaken(std::vector<int> vbase)
1435 {
1436  int n=vbase.size();
1437  poly p,q=pOne();
1438  //equmab(n);
1439  for(int i=0;i<n;i++)
1440  {
1441  p = pOne();pSetExp(p, vbase[i], 1);pSetm(p);pSetCoeff(p, nInit(1));
1442  //Print("attention! ");pWrite(p);
1443  q=pp_Mult_mm(q,p,currRing);
1444  }
1445  //PrintS("the polynomial according to the metrix M is:\n");
1446  //listprint(vbase);
1447  //pWrite(q);
1448  return q;
1449 }
1450 
1451 // returns a ideal according to a set of supports
1452 ideal idMaken(std::vector<std::vector<int> > vecs)
1453 {
1454  ideal id_re=idInit(1,1);
1455  poly p;
1456  int i,lv=vecs.size();
1457  for(i=0;i<lv;i++)
1458  {
1459  //Print("The vector is: ");
1460  //listprint(vecs[i]);
1461 
1462  p=pMaken(vecs[i]);
1463  //Print("The polynomial is: ");
1464  //pWrite(p);
1465  idInsertPoly(id_re, p);
1466  }
1467  //PrintS("This is the metrix M:\n");
1468  //listsprint(vecs);
1469  //PrintS("the ideal according to metrix M is:\n");
1470  idSkipZeroes(id_re);
1471  //id_print(id_re);
1472  return id_re;
1473 }
1474 
1475 
1476 
1477 
1478 
1479 /***************************only for T^2*************************************/
1480 //vbase only has two elements which records the position of the monomials in mv
1481 
1482 
1483 std::vector<poly> pMakei(std::vector<std::vector<int> > mv,std::vector<int> vbase)
1484 {
1485  poly p;
1486  std::vector<poly> h1;
1487  int n=vbase.size();
1488  for(int i=0;i<n;i++)
1489  {
1490  p=pMaken(mv[vbase[i]]);
1491  h1.push_back(p);
1492  }
1493  return h1;
1494 }
1495 
1496 // returns a ideal according to a set of supports
1497  std::vector<std::vector<poly> > idMakei(std::vector<std::vector<int> > mv,std::vector<std::vector<int> > vecs)
1498 {
1499  int i,lv=vecs.size();
1500  std::vector<std::vector<poly> > re;
1501  std::vector<poly> h;
1502  for(i=0;i<lv;i++)
1503  {
1504  h=pMakei(mv,vecs[i]);
1505  re.push_back(h);
1506  }
1507  //PrintS("This is the metrix M:\n");
1508  //listsprint(vecs);
1509  //PrintS("the ideal according to metrix M is:\n");
1510  return re;
1511 }
1512 
1513 /****************************************************************/
1514 
1515 
1516 
1517 
1518 
1519 
1520 
1521 
1522 //return the graded pieces of cohomology T^1 according to a,b
1523 void gradedpiece1(ideal h,poly a,poly b)
1524 {
1525  int i,j;
1526  std::vector<std::vector<int> > hvs=supports(h);
1527  std::vector<int> av=support1(a);
1528  std::vector<int> bv=support1(b);
1529  ideal sub=psubset(b);
1530  std::vector<std::vector<int> > sbv=supports(sub);
1531  //ideal M=Mab(h,a,b);
1532  std::vector<std::vector<int> > mv=Mabv(h,a,b);
1533  PrintS("The homophisim is map onto the set:\n");
1534  id_print(idMaken(mv));
1535  int m=mv.size();
1536  std::vector<std::vector<int> > good;
1537  std::vector<int> bad,vv;
1538  ring r=currRing;
1539  if( m > 0 )
1540  {
1541  for(i=0;i<m;i++)
1542  {
1543  if(!vsubset(bv,mv[i]))
1544  {
1545  bad.push_back(i+1);
1546  }
1547  }
1548  for(i=0;i<m;i++)
1549  {
1550  for(j=i+1;j<m;j++)
1551  {
1552  vv=vecUnion(mv[i],mv[j]);
1553  if(mabconditionv(hvs,vv,av,bv))
1554  {
1555  good=listsinsertlist(good,i+1,j+1);
1556  }
1557  else
1558  {
1559  //PrintS("They are not in Mabt!\n");
1560  ;
1561  }
1562  }
1563  }
1564  std::vector<std::vector<int> > solve=eli2(m,bad,good);
1565  if(bv.size()!=1)
1566  {
1567  PrintS("This is the solution of coefficients:\n");
1568  listsprint(solve);
1569  }
1570  else
1571  {
1572  std::vector<int> su=subspace1(mv,bv);
1573  //PrintS("This is the solution of subspace:\n");
1574  //listprint(su);
1575  std::vector<std::vector<int> > suu;
1576  suu.push_back(su);
1577  equmab(solve[0].size());
1578  std::vector<std::vector<int> > solves=vecqring(solve,suu);
1579  PrintS("This is the solution of coefficients:\n");
1580  listsprint(solves);
1581  rChangeCurrRing(r);
1582  }
1583  }
1584  else
1585  {
1586  PrintS("No element considered!\n");
1587  }
1588 }
1589 
1590 
1591 
1592 
1593 
1594 
1595 
1596 
1597 
1598 
1599 
1600 
1601 
1602 
1603 
1604 
1605 
1606 //Returns true if b can divide p*q
1607 bool condition1for2(std::vector<int > pv,std::vector<int > qv,std::vector<int > bv)
1608 {
1609  std::vector<int > vec=vecUnion(pv,qv);
1610  if(vsubset(bv,vec))
1611  {
1612  //PrintS("condition1for2 yes\n");
1613  return true;
1614  }
1615  //PrintS("condition1for2 no\n");
1616  return false;
1617 }
1618 
1619 
1620 
1621 //Returns true if support(p) union support(q) union support(s) union support(a) minus support(b) is face
1622 bool condition2for2(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> qv, std::vector<int> sv, std::vector<int> av, std::vector<int> bv)
1623 {
1624  std::vector<int> vec=vecUnion(pv,qv);
1625  vec=vecUnion(vec,sv);
1626  if(mabconditionv(hvs,vec,av,bv))
1627  {
1628  //PrintS("condition2for2 yes\n");
1629  return (true);
1630  }
1631  //PrintS("condition2for2 no\n");
1632  return (false);
1633 }
1634 
1635 
1636 
1637 
1638 
1639 
1640 bool condition3for2(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> qv, std::vector<int> av, std::vector<int> bv)
1641 {
1642  std::vector<int> v1,v2,v3;
1643  v1=vecIntersection(pv,qv);//intersection
1644  v2=vecUnion(pv,qv);
1645  v2=vecUnion(v2,av);
1646  v2=vecMinus(v2,bv);
1647  v3=vecUnion(v1,v2);
1648  if(vInvsl(v3,hvs))
1649  {
1650  //PrintS("condition3for2 yes\n");
1651  return(true);
1652  }
1653  //PrintS("condition3for2 no\n");
1654  return(false);
1655 }
1656 
1657 
1658 
1659 
1660 
1661 
1662 
1663 
1664 
1665 /****************solve the equations got from T^2*********************/
1666 
1667 ideal getpresolve(ideal h)
1668 {
1669  //ring r=currRing;
1670  int i;
1671  //assume (LIB "presolve.lib");
1672  sleftv a;a.Init();
1673  a.rtyp=IDEAL_CMD;a.data=(void*)h;
1674  idhdl solve=ggetid("elimlinearpart");
1675  if(solve==NULL)
1676  {
1677  WerrorS("presolve.lib are not loaded!");
1678  return NULL;
1679  }
1680  BOOLEAN sl=iiMake_proc(solve,NULL,&a);
1681  //PrintS("no errors here\n");
1682  if(sl)
1683  {
1684  WerrorS("error in solve!");
1685  }
1686  lists L=(lists) iiRETURNEXPR.Data();
1687  ideal re=(ideal)L->m[4].CopyD();
1688  //iiRETURNEXPR.CleanUp();
1689  iiRETURNEXPR.Init();
1690  //PrintS("no errors here\n");
1691  //idSkipZeroes(re);
1692  //id_print(re);
1693  return re;
1694 }
1695 
1696 
1697 
1698 std::vector<int> numfree(ideal h)
1699 {
1700  int i,j,num=0;poly p;
1701  std::vector<int> fvar;
1702  for(j=1;j<=currRing->N;j++)
1703  {
1704  for(i=0;i<IDELEMS(h);i++)
1705  {
1706  if(vInp(j,h->m[i]))
1707  {
1708  fvar.push_back(j);
1709  break;
1710  }
1711  }
1712  }
1713  //Print("There are %d free variables in total\n",num);
1714  return fvar;
1715 }
1716 
1717 
1718 
1719 
1720 
1721 std::vector<std::vector<int> > canonicalbase(int n)
1722 {
1723  std::vector<std::vector<int> > vecs;
1724  std::vector<int> vec;
1725  int i,j;
1726  for(i=0;i<n;i++)
1727  {
1728  for(j=0;j<n;j++)
1729  {
1730  if(i==j)
1731  vec.push_back(1);
1732  else
1733  vec.push_back(0);
1734  }
1735  vecs.push_back(vec);
1736  vec.clear();
1737  }
1738  return vecs;
1739 }
1740 
1741 
1742 
1743 
1744 
1745 std::vector<std::vector<int> > getvector(ideal h,int n)
1746 {
1747  std::vector<int> vec;
1748  std::vector<std::vector<int> > vecs;
1749  ideal h2=idCopy(h);
1750  if(!idIs0(h))
1751  {
1752  ideal h1=getpresolve(h2);
1753  poly q,e=pOne();
1754  int lg=IDELEMS(h1);
1755  std::vector<int> fvar=numfree(h1);
1756  int n=fvar.size();
1757  //Print("*************&&&&&&&&&&&*******************There are %d free variables in total\n",n);
1758  int i,j,t;
1759  //Print("lg is %d\n",lg);
1760  if(n==0)
1761  {
1762  vec=make0(IDELEMS(h1));vecs.push_back(vec);//listsprint(vecs);
1763  }
1764  else
1765  {
1766  for(t=0;t<n;t++)
1767  {
1768  vec.clear();
1769  for(i=0;i<lg;i++)
1770  {
1771  //Print("The polynomial is the %dth one:\n",i+1);
1772  q=pCopy(h1->m[i]);
1773  //pWrite(q);
1774  if(q==0)
1775  {
1776  vec.push_back(0);
1777  }
1778  else
1779  {
1780  q=p_Subst(q, fvar[t], e,currRing);
1781  //Print("the %dth variable was substituted by 1:\n",fvar[t]);
1782  //pWrite(q);
1783  for(j=0;j<n;j++)
1784  {
1785  //Print("the %dth variable was substituted by 0:\n",fvar[j]);
1786  q=p_Subst(q, fvar[j],0,currRing);
1787  //pWrite(q);
1788  }
1789  if(q==0)
1790  {
1791  vec.push_back(0);
1792  }
1793  else
1794  {
1795  //Print("aiyamaya is %d \n",n_Int(pGetCoeff(q),currRing->cf));
1796  vec.push_back(n_Int(pGetCoeff(q),currRing->cf));
1797  }
1798  }
1799  }
1800  //listprint(vec);
1801  vecs.push_back(vec);
1802  }
1803  }
1804  }
1805  else
1806  {vecs=canonicalbase(n);}
1807  //listsprint(vecs);
1808  return vecs;
1809 }
1810 
1811 
1812 
1813 /**************************************************************************/
1814 
1815 
1816 
1817 
1818 
1819 
1820 
1821 
1822 
1823 //subspace of T2(find all the possible values of alpha)
1824 std::vector<int> findalpha(std::vector<std::vector<int> > mv, std::vector<int> bv)
1825 {
1826  std::vector<int> alset;
1827  for(int i=0;i<mv.size();i++)
1828  {
1829  if(vsubset(bv,mv[i]))
1830  {
1831  alset.push_back(i);
1832  }
1833  }
1834  //Print("This is the alpha set, and the subspace is dim-%ld\n",alset.size());
1835  //listprint(alset);
1836  return alset;
1837 }
1838 
1839 
1840 
1841 
1842 
1843 
1844 
1845 
1846 std::vector<int> subspacet1(int num, std::vector<std::vector<int> > ntvs)
1847 {
1848  int i,j,t;
1849  int n=ntvs.size();
1850  std::vector<int> subase;
1851  for(t=0;t<n;t++)
1852  {
1853  i=ntvs[t][0];
1854  j=ntvs[t][1];
1855  if(i==(num))
1856  {
1857  subase.push_back(1);
1858  }
1859  else if(j==num)
1860  {
1861  subase.push_back(-1);
1862  }
1863  else
1864  {
1865  subase.push_back(0);
1866  }
1867  }
1868  //Print("This is the basis w.r.t. %dth polynomial in alpha set\n",num);
1869  //listprint(subase);
1870  return subase;
1871 }
1872 
1873 
1874 
1875 
1876 //subspace for T^2(mab method)
1877 std::vector<std::vector<int> > subspacet(std::vector<std::vector<int> > mv, std::vector<int> bv,std::vector<std::vector<int> > ntvs)
1878 {
1879  int i,j;
1880  std::vector<int> alset=findalpha(mv,bv);
1881  std::vector<int> subase;
1882  std::vector<std::vector<int> > subases;
1883  for(i=0;i<alset.size();i++)
1884  {
1885  subase=subspacet1(alset[i],ntvs);
1886  subases.push_back(subase);
1887  }
1888  //PrintS("These are the bases for the subspace:\n");
1889  //listsprint(subases);
1890  return subases;
1891 }
1892 
1893 
1894 
1895 
1896 
1897 std::vector<std::vector<int> > mabtv(std::vector<std::vector<int> > hvs, std::vector<std::vector<int> > Mv, std::vector<int> av, std::vector<int> bv)
1898 {
1899  std::vector<int> v1,var;
1900  std::vector<std::vector<int> > vars;
1901  for(int i=0;i<Mv.size();i++)
1902  {
1903  for(int j=i+1;j<Mv.size();j++)
1904  {
1905  var.clear();
1906  v1=vecUnion(Mv[i],Mv[j]);
1907  if(mabconditionv(hvs, v1, av, bv))
1908  {
1909  var.push_back(i);
1910  var.push_back(j);
1911  vars.push_back(var);
1912  }
1913  }
1914  }
1915  return vars;
1916 }
1917 
1918 
1919 
1920 
1921 //fix the problem of the number of the new variables
1922 void gradedpiece2(ideal h,poly a,poly b)
1923 {
1924  int t0,t1,t2,i,j,t;
1925  ring r=rCopy(currRing);
1926  std::vector<std::vector<int> > hvs=supports(h);
1927  std::vector<int> av=support1(a);
1928  std::vector<int> bv=support1(b);
1929  ideal sub=psubset(b);
1930  std::vector<std::vector<int> > mv=Mabv(h,a,b);
1931  std::vector<std::vector<int> > mts=mabtv(hvs,mv,av,bv);
1932  PrintS("The homomorphism should map onto:\n");
1933  lpsprint(idMakei(mv,mts));
1934  int m=mv.size();
1935  //ideal M=Mab(h,a,b);
1936  std::vector<std::vector<int> > vecs,vars;
1937  std::vector<int> vec,var;
1938  if(m > 0)
1939  {
1940  vars=mabtv(hvs,mv,av,bv);
1941  int vn=vars.size();
1942  for(t0=0;t0<vars.size();t0++)
1943  {
1944  i=vars[t0][0];
1945  j=vars[t0][1];
1946  if(!condition1for2(mv[i],mv[j],bv))//condition 1
1947  {
1948  //PrintS("And they satisfy the condition 1.\n");
1949  vec=makeequation(t0+1,0,0);
1950  //PrintS("So the equation:\n");
1951  //pWrite(p);
1952  //PrintS("holds.\n");
1953  vecs.push_back(vec);
1954  vec.clear();
1955  }
1956  if(condition3for2(hvs,mv[i],mv[j],av,bv))//condition 3
1957  {
1958  //PrintS("And they satisfy the condition 3.\n");
1959  vec=makeequation(t0+1,0,0);
1960  //PrintS("So the equation: \n");
1961  //pWrite(p);
1962  //PrintS("holds.\n");
1963  vecs.push_back(vec);
1964  vec.clear();
1965  }
1966  for(t1=t0+1;t1<vars.size();t1++)
1967  {
1968  for(t2=t1+1;t2<vars.size();t2++)
1969  {
1970  if(vars[t0][0]==vars[t1][0]&&vars[t1][1]==vars[t2][1]&&vars[t0][1]==vars[t2][0])
1971  {
1972  i=vars[t0][0];
1973  j=vars[t0][1];
1974  t=vars[t1][1];
1975  if(condition2for2(hvs,mv[i],mv[j],mv[t],av,bv))//condition 2
1976  {
1977  vec=makeequation(t0+1,t1+1,t2+1);
1978  vecs.push_back(vec);
1979  vec.clear();
1980  }
1981  }
1982  }
1983  }
1984  }
1985  //PrintS("this is EQUATIONS:\n");
1986  //listsprint(vecs);
1987  equmab(vn);
1988  ideal id_re=idMake3(vecs);
1989  //id_print(id_re);
1990  std::vector<std::vector<int> > re=getvector(id_re,vn);
1991  PrintS("this is the solution for ideal :\n");
1992  listsprint(re);
1993  rChangeCurrRing(r);
1994  std::vector<std::vector<int> > sub=subspacet(mv, bv,vars);
1995  PrintS("this is the solution for subspace:\n");
1996  listsprint(sub);
1997  equmab(vn);
1998  std::vector<std::vector<int> > solve=vecqring(re, sub);
1999  PrintS("This is the solution of coefficients:\n");
2000  listsprint(solve);
2001  rChangeCurrRing(r);
2002  }
2003  else
2004  {
2005  PrintS("No element considered!");
2006  }
2007 }
2008 
2009 
2010 
2011 
2012 
2013 
2014 
2015 
2016 
2017 
2018 
2019 
2020 
2021 
2022 
2023 
2024 
2025 
2026 
2027 
2028 
2029 
2030 
2031 
2032 
2033 
2034 
2035 
2036 
2037 
2038 
2039 
2040 
2041 
2042 
2043 
2044 
2045 
2046 
2047 
2048 /**********************************************************************/
2049 //For the method of N_{a-b}
2050 
2051 
2052 
2053 
2054 //returns true if pv(support of monomial) satisfies pv union av minus bv is in hvs
2055 bool nabconditionv(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> av, std::vector<int> bv)
2056 {
2057  std::vector<int> vec1=vecIntersection(pv,bv);
2058  std::vector<int> vec2=vecUnion(pv,bv);
2059  int s1=vec1.size();
2060  if(!vInvsl(vec2,hvs) && s1==0 && vsubset(av,pv))
2061  {
2062  //PrintS("nab condition satisfied\n");
2063  return(true);
2064  }
2065  //PrintS("nab condition not satisfied\n");
2066  return(false);
2067 }
2068 
2069 
2070 
2071 
2072 
2073 
2074 //returns N_{a-b}
2075 std::vector<std::vector<int> > Nabv(std::vector<std::vector<int> > hvs, std::vector<int> av, std::vector<int> bv)
2076 {
2077  std::vector<std::vector<int> > vecs;
2078  int num=hvs.size();
2079  for(int i=0;i<num;i++)
2080  {
2081  if(nabconditionv(hvs,hvs[i],av,bv))
2082  vecs.push_back(hvs[i]);
2083  }
2084  return vecs;
2085 }
2086 
2087 
2088 
2089 
2090 
2091 
2092 //returns true if pv union qv union av minus bv is in hvs
2093 //hvs is simplicial complex
2094 bool nabtconditionv(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> qv, std::vector<int> av, std::vector<int> bv)
2095 {
2096  std::vector<int> v1;
2097  v1=vecUnion(pv,qv);
2098  if(vInvsl(v1,hvs))
2099  {
2100  //PrintS("They are in Nab2\n");
2101  return (true);
2102  }
2103  //PrintS("They are not in Nab2\n");
2104  return (false);
2105 }
2106 
2107 
2108 //returns N_{a-b}^(2)
2109 std::vector<std::vector<int> > nabtv(std::vector<std::vector<int> > hvs, std::vector<std::vector<int> > Nv, std::vector<int> av, std::vector<int> bv)
2110 {
2111  std::vector<int> v1,var;
2112  std::vector<std::vector<int> > vars;
2113  for(int i=0;i<Nv.size();i++)
2114  {
2115  for(int j=i+1;j<Nv.size();j++)
2116  {
2117  var.clear();
2118  if(nabtconditionv(hvs, Nv[i], Nv[j], av, bv))
2119  {
2120  var.push_back(i);
2121  var.push_back(j);
2122  vars.push_back(var);
2123  }
2124  }
2125  }
2126  return vars;
2127 }
2128 
2129 
2130 
2131 
2132 
2133 
2134 
2135 
2136 
2137 
2138 //p must be the monomial which is a face
2139 // ideal sub=psubset(b); bvs=supports(sub);
2140 bool tNab(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<std::vector<int> > bvs)
2141 {
2142  std::vector<int> sv;
2143  if(bvs.size()<=1) return false;
2144  for(int i=0;i<bvs.size();i++)
2145  {
2146  sv=vecUnion(pv,bvs[i]);
2147  if(!vInvsl(sv,hvs))
2148  {
2149  //PrintS("TRUE! It is in tilde Nab!\n");
2150  return true;
2151  }
2152  }
2153  //PrintS("FALSE! It is not in tilde Nab!\n");
2154  return false;
2155 }
2156 
2157 
2158 
2159 
2160 
2161 
2162 
2163 std::vector<int> tnab(std::vector<std::vector<int> > hvs,std::vector<std::vector<int> > nvs,std::vector<std::vector<int> > bvs)
2164 {
2165  std::vector<int> pv;
2166  std::vector<int> vec;
2167  for(int j=0;j<nvs.size();j++)
2168  {
2169  pv=nvs[j];
2170  if(tNab(hvs, pv, bvs))
2171  {
2172  vec.push_back(j);
2173  }
2174  }
2175  return vec;
2176 }
2177 
2178 
2179 
2180 
2181 
2182 
2183 
2184 
2185 //the image phi(pv)=pv union av minus bv
2186 std::vector<int> phimage(std::vector<int> pv, std::vector<int> av, std::vector<int> bv)
2187 {
2188  std::vector<int> qv=vecUnion(pv,av);
2189  qv=vecMinus(qv,bv);
2190  return qv;
2191 }
2192 
2193 
2194 
2195 //mvs and nvs are the supports of ideal Mab and Nab
2196 //vecs is the solution of nab
2197 std::vector<std::vector<int> > value1(std::vector<std::vector<int> > mvs, std::vector<std::vector<int> > nvs, std::vector<std::vector<int> > vecs,std::vector<int> av, std::vector<int> bv)
2198 {
2199  std::vector<int> pv;
2200  std::vector<int> base;
2201  std::vector<std::vector<int> > bases;
2202  for(int t=0;t<vecs.size();t++)
2203  {
2204  for(int i=0;i<mvs.size();i++)
2205  {
2206  pv=phimage(mvs[i],av,bv);
2207  for(int j=0;j<nvs.size();j++)
2208  {
2209  if(vEvl(pv,nvs[j]))
2210  base.push_back(vecs[t][j]);
2211  }
2212  }
2213  if(base.size()!=mvs.size())
2214  {
2215  WerrorS("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
2216  usleep(1000000);
2217  assert(false);
2218  WerrorS("Errors in Nab set!");
2219  }
2220 
2221  bases.push_back(base);
2222  base.clear();
2223  }
2224  return bases;
2225 }
2226 
2227 
2228 
2229 
2230 
2231 
2232 
2233 
2234 
2235 intvec *Tmat(std::vector<std::vector<int> > vecs)
2236 {
2237  //std::vector<std::vector<int> > solve=gradedpiece1n(h,a,b);
2238  //Print("the size of solve is: %ld\n",solve.size());
2239  //vtm(solve);
2240  intvec *m;
2241  int i,j;
2242  int a=vecs.size();
2243  if(a==0)
2244  {
2245  m=new intvec(1,1,10);
2246  }
2247  else
2248  {
2249  int b=vecs[0].size();
2250  m=new intvec(a,b,0);
2251  for(i=1;i<=a;i++)
2252  {
2253  for(j=1;j<=b;j++)
2254  {
2255  IMATELEM(*m,i,j)=vecs[i-1][j-1];
2256  }
2257  }
2258  }
2259 return (m);
2260 }
2261 
2262 
2263 
2264 
2265 
2266 
2267 /*void ppppp(int l)
2268 {
2269  int i;
2270 std::vector<std::vector<int> > vecs;
2271 std::vector<int> vec;
2272  for(i=0;i<l;i++)
2273  {
2274  for(int j=i*l;j<i*l+l;j++)
2275  {
2276  vec.push_back(j);
2277  }
2278  vecs.push_back(vec);
2279  vec.clear();
2280  }
2281 PrintS("May I have your attention please!\n");
2282 listsprint(vecs);
2283  intvec *m=T1mat(vecs);
2284 PrintS("May I have your attention again!\n");
2285  m->show(0,0);
2286 }*/
2287 
2288 
2289 
2290 
2291 
2292 std::vector<int> gensindex(ideal M, ideal ids)
2293 {
2294  int i;
2295  std::vector<int> vec,index;
2296  if(!idIs0(M))
2297  {
2298  std::vector<std::vector<int> > vecs=supports(ids);
2299  for(i=0;i<IDELEMS(M);i++)
2300  {
2301  vec=support1(M->m[i]);
2302  if(vInvsl(vec,vecs))
2303  index.push_back(i);
2304  }
2305  }
2306  return (index);
2307 }
2308 
2309 
2310 
2311 ideal mingens(ideal h, poly a, poly b)
2312 {
2313  int i;
2314  ideal hi=idInit(1,1);
2315  std::vector<std::vector<int> > mv=Mabv(h,a,b);
2316  ideal M=idMaken(mv);
2317 //PrintS("mab\n");
2318  //id_print(M);
2319  //PrintS("idsrRing\n");
2320  //id_print(idsrRing(h));
2321  std::vector<int> index = gensindex(M, idsrRing(h));
2322 //PrintS("index\n");
2323  //listprint(index);
2324  for(i=0;i<index.size();i++)
2325  {
2326  idInsertPoly(hi,M->m[index[i]]);
2327  }
2328  idSkipZeroes(hi);
2329 //PrintS("over\n");
2330  // id_print(hi);
2331  return (hi);
2332 }
2333 
2334 
2335 
2336 std::vector<std::vector<int> > minisolve(std::vector<std::vector<int> > solve, std::vector<int> index)
2337 {
2338  int i,j;
2339  std::vector<int> vec;
2340  std::vector<std::vector<int> > solsm;
2341  std::vector<int> solm;
2342  for(i=0;i<solve.size();i++)
2343  {
2344  vec=solve[i];
2345  for(j=0;j<vec.size();j++)
2346  {
2347  if(IsinL(j,index))
2348  solm.push_back(vec[j]);
2349  }
2350  solsm.push_back(solm);
2351  solm.clear();
2352  }
2353  return (solsm);
2354 }
2355 
2356 
2357 //T_1 graded piece(N method)
2358 
2359 intvec * gradedpiece1n(ideal h,poly a,poly b)
2360 {
2361  int i,j,co;
2362  std::vector<std::vector<int> > hvs=supports(h);
2363  std::vector<int> av=support1(a);
2364  //listprint(av);
2365  std::vector<int> bv=support1(b);
2366  //listprint(bv);
2367  ideal sub=psubset(b);
2368 //id_print(sub);
2369  std::vector<std::vector<int> > sbv=supports(sub);
2370 //listsprint(sbv);
2371  std::vector<std::vector<int> > nv=Nabv(hvs,av,bv);
2372  //PrintS("The N set is:\n");
2373  //listsprint(nv);
2374  std::vector<std::vector<int> > mv=Mabv(h,a,b);
2375  //listsprint(mv);
2376  ideal M=idMaken(mv);
2377  std::vector<int> index = gensindex(M, idsrRing(h));
2378  //ideal gens=mingens(M,index);
2379  int n=nv.size();
2380  //PrintS("The homophisim is map onto the set:\n");
2381  //id_print(M);
2382  std::vector<std::vector<int> > good,solve;
2383  std::vector<int> bad;
2384  ring r=currRing;
2385  std::vector<int> tnv;
2386  if(n > 0)
2387  {
2388  tnv=tnab(hvs,nv,sbv);
2389  for(i=0;i<tnv.size();i++)
2390  {
2391  co=tnv[i];
2392  bad.push_back(co+1);
2393  }
2394  for(i=0;i<n;i++)
2395  {
2396  for(j=i+1;j<n;j++)
2397  {
2398  if(nabtconditionv(hvs,nv[i],nv[j],av,bv))
2399  {
2400  good=listsinsertlist(good,i+1,j+1);
2401  }
2402  else
2403  {
2404  ;
2405  }
2406  }
2407  }
2408  solve=eli2(n,bad,good);
2409  if(bv.size()!=1)
2410  {;
2411  //PrintS("This is the solution of coefficients:\n");
2412  //listsprint(solve);
2413  }
2414  else
2415  {
2416  std::vector<int> su=make1(n);
2417  std::vector<std::vector<int> > suu;
2418  suu.push_back(su);
2419  equmab(n);
2420  solve=vecqring(solve,suu);
2421  //PrintS("This is the solution of coefficients:\n");
2422  //listsprint(solve);
2423  rChangeCurrRing(r);
2424  }
2425  solve=value1(mv,nv,solve,av,bv);
2426  }
2427  else
2428  {
2429  //PrintS("No element considered here!\n");
2430  solve.clear();
2431  }
2432  //PrintS("This is the solution of final coefficients:\n");
2433  //listsprint(solve);
2435  intvec *sl=Tmat(solve);
2436  //sl->show(0,0);
2437  return sl;
2438 }
2439 
2440 
2441 
2442 /*
2443 void vtm(std::vector<std::vector<int> > vecs)
2444 {
2445  int i,j;
2446 
2447  intvec *m;
2448 
2449  int r=vecs.size();
2450  Print("r is %d\n",r);
2451  // c=(vecs[0]).size();
2452 
2453  PrintS("no error yet:\n");
2454  m=new intvec(r);
2455 
2456 for(i=0;i<r;i++)
2457  {
2458 
2459  for(j=0;j<r;j++)
2460  {
2461  (*m)[i]=*(vecs[i]);
2462  Print("%d",IMATELEM(*m,i,j));
2463  }
2464  }
2465  // return matt;
2466 }
2467 */
2468 
2469 
2470 
2471 
2472 
2473 void T1(ideal h)
2474 {
2475  ideal bi=findb(h),ai;
2476  int mm=0,index=0;
2477  id_print(bi);
2478  poly a,b;
2479  std::vector<std::vector<int> > solve;
2480  for(int i=0;i<IDELEMS(bi);i++)
2481  {
2482  PrintS("This is aset according to:");
2483  b=pCopy(bi->m[i]);
2484  pWrite(b);
2485  ai=finda(h,b,0);
2486  if(!idIs0(ai))
2487  {
2488  id_print(ai);
2489  for(int j=0;j<IDELEMS(ai);j++)
2490  {
2491  //PrintS("This is a:");
2492  a=pCopy(ai->m[j]);
2493  //pWrite(a);
2494  intvec * solve=gradedpiece1n(h, a, b);
2495  if (IMATELEM(*solve,1,1)!=10)
2496  mm++;
2497  }
2498  }
2499 
2500  }
2501  Print("Finished %d!\n",mm);
2502 
2503 }
2504 
2505 
2506 
2507 
2508 
2509 
2510 bool condition2for2nv(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> qv, std::vector<int> fv)
2511 {
2512  std::vector<int> vec=vecUnion(pv,qv);
2513  vec=vecUnion(vec,fv);
2514  if(vInvsl(vec,hvs))
2515  {
2516  //PrintS("condition2for2 yes\n");
2517  return (true);
2518  }
2519  //PrintS("condition2for2 no\n");
2520  return (false);
2521 }
2522 
2523 
2524 
2525 
2526 
2527 //for subspace of T2(find all the possible values of alpha)
2528 std::vector<int> findalphan(std::vector<std::vector<int> > N, std::vector<int> tN)
2529 {
2530  int i;std::vector<int> alset,vec;
2531  for(i=0;i<N.size();i++)
2532  {
2533  // vec=N[i];
2534  if(!IsinL(i,tN))
2535  {
2536  alset.push_back(i);
2537  }
2538  }
2539  //listprint(alset);
2540  return alset;
2541 }
2542 
2543 
2544 
2545 
2546 //subspace of T^2 (nab method)
2547 std::vector<std::vector<int> > subspacetn(std::vector<std::vector<int> > N, std::vector<int> tN, std::vector<std::vector<int> > ntvs)
2548 {
2549  int i,j;
2550  std::vector<int> alset=findalphan(N,tN);
2551  std::vector<int> subase;
2552  std::vector<std::vector<int> > subases;
2553  for(i=0;i<alset.size();i++)
2554  {
2555  subase=subspacet1(alset[i],ntvs);
2556  subases.push_back(subase);
2557  }
2558  //PrintS("These are the bases for the subspace:\n");
2559  //listsprint(subases);
2560  return subases;
2561 }
2562 
2563 
2564 
2565 //mts Mabt
2566 //nts Nabt
2567 //mvs Mab
2568 //nvs Nab
2569 std::vector<std::vector<int> > value2(std::vector<std::vector<int> > mvs, std::vector<std::vector<int> > nvs, std::vector<std::vector<int> > mts, std::vector<std::vector<int> > nts, std::vector<std::vector<int> > vecs,std::vector<int> av, std::vector<int> bv)
2570 {
2571  std::vector<int> pv,qv;
2572  std::vector<int> base;
2573  int row,col;
2574  std::vector<std::vector<int> > bases;
2575  //PrintS("This is the nabt:\n");
2576  //listsprint(nts);
2577  //PrintS("nabt ends:\n");
2578  //PrintS("This is the mabt:\n");
2579  //listsprint(mts);
2580  //PrintS("mabt ends:\n");
2581 
2582  for(int t=0;t<vecs.size();t++)
2583  {
2584  for(int i=0;i<mts.size();i++)
2585  {
2586  row=mts[i][0];
2587  col=mts[i][1];
2588  pv=phimage(mvs[row],av,bv);
2589  qv=phimage(mvs[col],av,bv);
2590  if(vEvl(pv,qv))
2591  base.push_back(0);
2592  //PrintS("This is image of p and q:\n");
2593  //listprint(pv); PrintS("*********************\n");listprint(qv);
2594  //PrintS("nabt ends:\n");
2595  else
2596  {
2597  for(int j=0;j<nts.size();j++)
2598  {
2599  row=nts[j][0];
2600  col=nts[j][1];
2601  //PrintS("This is nvs:\n");
2602  //listprint(nvs[row]); PrintS("*********************\n");listprint(nvs[col]);
2603  //PrintS("nabt ends:\n");
2604  if(vEvl(pv,nvs[row])&&vEvl(qv,nvs[col]))
2605  {
2606  base.push_back(vecs[t][j]);break;
2607  //PrintS("This is nvs,they are the same:\n");
2608  //listprint(nvs[row]); listprint(nvs[col]);
2609  //PrintS("nabt ends:\n");
2610  }
2611  else
2612  {
2613  base.push_back(-vecs[t][j]);break;
2614  //PrintS("This is nvs,they are the same:\n");
2615  //listprint(nvs[row]); listprint(nvs[col]);
2616  //PrintS("nabt ends:\n");
2617  }
2618  }
2619  }
2620  }
2621  if(base.size()!=mts.size())
2622  {
2623  WerrorS("Errors in Nab set!");
2624  //WerrorS("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
2625  usleep(1000000);
2626  assert(false);
2627  }
2628  bases.push_back(base);
2629  base.clear();
2630  }
2631  return bases;
2632 }
2633 
2634 
2635 
2636 
2637 ideal genst(ideal h, poly a, poly b)
2638 {
2639  int i,j;
2640  std::vector<std::vector<int> > hvs=supports(h);
2641  std::vector<int> av=support1(a), bv=support1(b);
2642  std::vector<std::vector<int> > mv=Mabv(h,a,b), mts=mabtv(hvs,mv,av,bv);
2643  std::vector<std::vector<poly> > pvs=idMakei(mv,mts);
2644  ideal gens=idInit(1,1);
2645  for(i=0;i<pvs.size();i++)
2646  {
2647  idInsertPoly(gens,pvs[i][0]);
2648  idInsertPoly(gens,pvs[i][1]);
2649  }
2650  idSkipZeroes(gens);
2651 //PrintS("This is the mix set of mab2!\n");
2652 //id_print(gens);
2653  return (gens);
2654 }
2655 
2656 
2657 
2658 
2659 
2660 
2661 
2662 
2663 intvec * gradedpiece2n(ideal h,poly a,poly b)
2664 {
2665  int i,j,t;
2666  std::vector<std::vector<int> > hvs=supports(h);
2667  std::vector<int> av=support1(a);
2668  std::vector<int> bv=support1(b);
2669  ideal sub=psubset(b);
2670  std::vector<std::vector<int> > sbv=supports(sub);
2671  std::vector<std::vector<int> > nv=Nabv(hvs,av,bv);
2672  int n=nv.size();
2673  std::vector<int> tnv=tnab(hvs,nv,sbv);
2674  ring r=currRing;
2675  std::vector<std::vector<int> > mv=Mabv(h,a,b);
2676  std::vector<std::vector<int> > mts=mabtv(hvs,mv,av,bv);
2677  //PrintS("The relations are:\n");
2678  //listsprint(mts);
2679  //PrintS("The homomorphism should map onto:\n");
2680  //lpsprint(idMakei(mv,mts));
2681  std::vector<std::vector<int> > vecs,vars,ntvs;
2682  std::vector<int> vec,var;
2683  std::vector<std::vector<int> > solve;
2684  if(n>0)
2685  {
2686  ntvs=nabtv( hvs, nv, av, bv);
2687  //PrintS("The current homomorphism map onto###:\n");
2688  //lpsprint(idMakei(nv,ntvs));
2689  int l=ntvs.size();
2690  for(int t0=0;t0<l;t0++)
2691  {
2692  i=ntvs[t0][0];
2693  j=ntvs[t0][1];
2694  if(tNab(hvs,nv[i],sbv)&&tNab(hvs,nv[j],sbv))//condition 1
2695  {
2696  //pWrite(pMaken(nv[i]));pWrite(pMaken(nv[j]));
2697  //PrintS("They are both in tilde N.\n");
2698  //PrintS("tilde N is:\n"); listprint(tnv);
2699  vec=makeequation(t0+1,0,0);
2700  vecs.push_back(vec);
2701  vec.clear();
2702  }
2703  for(int t1=t0+1;t1<ntvs.size();t1++)
2704  {
2705  for(int t2=t1+1;t2<ntvs.size();t2++)
2706  {
2707  if(ntvs[t0][0]==ntvs[t1][0]&&ntvs[t1][1]==ntvs[t2][1]&&ntvs[t0][1]==ntvs[t2][0])
2708  {
2709  i=ntvs[t0][0];
2710  j=ntvs[t0][1];
2711  t=ntvs[t1][1];
2712  if(condition2for2nv(hvs,nv[i],nv[j],nv[t]))
2713  {
2714  vec=makeequation(t0+1,t1+1,t2+1);
2715  vecs.push_back(vec);
2716  vec.clear();
2717  }
2718  }
2719  }
2720  }
2721  }
2722  //PrintS("this is EQUATIONS:\n");
2723  //listsprint(vecs);
2724  if(n==1) l=1;
2725  equmab(l);
2726  ideal id_re=idMake3(vecs);
2727  //id_print(id_re);
2728  std::vector<std::vector<int> > re=getvector(id_re,l);
2729  //PrintS("this is the solution for ideal :\n");
2730  //listsprint(re);
2731  rChangeCurrRing(r);
2732  std::vector<std::vector<int> > sub=subspacetn(nv, tnv,ntvs);
2733  //PrintS("this is the solution for subspace:\n");
2734  //listsprint(sub);
2735  equmab(l);
2736  solve=vecqring(re, sub);
2737  //PrintS("This is the solution of coefficients:\n");
2738  //listsprint(solve);
2739  rChangeCurrRing(r);
2740  solve=value2(mv,nv,mts,ntvs,solve,av,bv);
2741  }
2742  else
2743  solve.clear();
2744  intvec *sl=Tmat(solve);
2745  return sl;
2746 }
2747 
2748 
2749 
2750 
2751 
2752 
2753 
2754 void T2(ideal h)
2755 {
2756  ideal bi=findb(h),ai;
2757  id_print(bi);
2758  poly a,b;
2759  int mm=0,gp=0;
2760 std::vector<int> bv,av;
2761  std::vector<std::vector<int> > solve;
2762  for(int i=0;i<IDELEMS(bi);i++)
2763  {
2764  b=pCopy(bi->m[i]);
2765  //bv=support1(b);
2766  //PrintS("This is aset according to:");
2767  pWrite(b);
2768 //if(bv.size()==2)
2769  //{
2770  ai=finda(h,b,0);
2771  if(!idIs0(ai))
2772  {
2773  PrintS("This is a set according to current b:\n");
2774  id_print(ai);
2775  for(int j=0;j<IDELEMS(ai);j++)
2776  {
2777  PrintS("This is a:");
2778  a=pCopy(ai->m[j]);
2779  pWrite(a);
2780  PrintS("This is b:");
2781  pWrite(b);
2782  intvec *solve=gradedpiece2n(h, a, b);
2783  gp++;
2784  }
2785  }
2786  mm=mm+1;
2787  }
2788  if(mm==IDELEMS(bi))
2789  PrintS("Finished!\n");
2790  Print("There are %d graded pieces in total.\n",gp);
2791 }
2792 
2793 
2794 
2795 
2796 
2797 
2798 void Tlink(ideal h,poly a,poly b,int n)
2799 {
2800  std::vector<std::vector<int> > hvs=supports(h);
2801  std::vector<int> av=support1(a);
2802  std::vector<int> bv=support1(b);
2803  std::vector<std::vector<int> > vec=links(a, h);
2804  PrintS("This is the links of a:\n");
2805  listsprint(vec);
2806  ideal li=idMaken(vec);
2807  PrintS("This is the links of a(ideal version):\n");
2808  id_print(li);
2809  poly p=pOne();
2810  PrintS("1************************************************\n");
2811  PrintS("This is T_1 (m):\n");
2812  gradedpiece1(li,p,b);
2813  PrintS("2************************************************\n");
2814  PrintS("This is T_2 (m):\n");
2815  gradedpiece2(li,p,b);
2816  PrintS("3************************************************\n");
2817  PrintS("This is T_1 (n):\n");
2818  gradedpiece1n(li,p,b);
2819  PrintS("4************************************************\n");
2820  PrintS("This is T_2 (n):\n");
2821  gradedpiece2n(li,p,b);
2822 }
2823 
2824 
2825 
2826 
2827 
2828 
2829 
2830 
2831 
2832 
2833 
2834 
2835 
2836 
2837 
2838 
2839 /****************************for the interface of .lib*********************************/
2840 
2841 ideal makemab(ideal h, poly a, poly b)
2842 {
2843  std::vector<std::vector<int> > mv=Mabv(h,a,b);
2844  ideal M=idMaken(mv);
2845  return M;
2846 }
2847 
2848 
2849 std::vector<int> v_minus(std::vector<int> v1, std::vector<int> v2)
2850 {
2851  std::vector<int> vec;
2852  for(int i=0;i<v1.size();i++)
2853  {
2854  vec.push_back(v1[i]-v2[i]);
2855  }
2856  return vec;
2857 }
2858 
2859 
2860 std::vector<int> gdegree(poly a, poly b)
2861 {
2862  int i,j;
2863  std::vector<int> av,bv;
2864  for(i=1;i<=currRing->N;i++)
2865  {
2866  av.push_back(pGetExp(a,i));
2867  bv.push_back(pGetExp(b,i));
2868  }
2869  std::vector<int> vec=v_minus(av,bv);
2870 //PrintS("the degree is:\n");
2871 //listprint(vec);
2872  return vec;
2873 }
2874 
2875 
2876 
2877 
2878 /**************************************interface T1****************************************/
2879 /*
2880 BOOLEAN makeqring(leftv res, leftv args)
2881 {
2882  leftv h=args;
2883  ideal h2= id_complement( hh);
2884  if((h != NULL)&&(h->Typ() == POLY_CMD))
2885  {
2886  poly p= (poly)h->Data();
2887  h = h->next;
2888  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
2889  {
2890  ideal hh=(ideal)h->Data();
2891  ideal h2=id_complement(hh);
2892  ideal h1=id_Init(1,1);
2893  idInsertPoly(h1,p);
2894  ideal gb=kStd(h2,NULL,testHomog,NULL,NULL,0,0,NULL);
2895  ideal idq=kNF(gb,NULL,h1);
2896  idSkipZeroes(h1);
2897  res->rtyp =POLY_CMD;
2898  res->data =h1->m[0];
2899  }
2900  }
2901  }
2902  return false;
2903 }*/
2904 
2905 
2906 
2907 
2909 {
2910  leftv h=args;
2911  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
2912  {
2913  ideal hh=(ideal)h->Data();
2914  ideal h2= id_complement(hh);
2915  res->rtyp =IDEAL_CMD;
2916  res->data =h2;
2917  }
2918  return false;
2919 }
2920 
2921 
2922 
2924 {
2925  leftv h=args;
2926  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
2927  {
2928  ideal h1= (ideal)h->Data();
2929 //T1(h1);
2930  h = h->next;
2931  if((h != NULL)&&(h->Typ() == POLY_CMD))
2932  {
2933  poly p= (poly)h->Data();
2934  h = h->next;
2935  if((h != NULL)&&(h->Typ() == POLY_CMD))
2936  {
2937  poly q= (poly)h->Data();
2938  res->rtyp =IDEAL_CMD;
2939  res->data =mingens(h1,p,q);
2940  }
2941  }
2942  }
2943  return false;
2944 }
2945 
2946 intvec *dmat(poly a, poly b)
2947 {
2948  intvec *m;
2949  int i,j;
2950  std::vector<int> dg=gdegree(a,b);
2951 //PrintS("This is the degree of a and b\n");
2952 //listprint(dg);
2953  int lg=dg.size();
2954  m=new intvec(lg);
2955  if(lg!=0)
2956  {
2957  m=new intvec(lg);
2958  for(i=0;i<lg;i++)
2959  {
2960  (*m)[i]=dg[i];
2961  //Print("This is the %dth degree of a and b: %d, and %d is copied\n",i,dg[i],(*m)[i]);
2962  }
2963  }
2964  /*for(j=0;j<lg;j++)
2965  {
2966  Print("[%d]: %d\n",j+1,(*m)[j]);
2967  }*/
2968  //(m)->show(1,1);
2969 return (m);
2970 }
2971 
2972 
2973 
2975 {
2976  leftv h=args;
2977  if((h != NULL)&&(h->Typ() == POLY_CMD))
2978  {
2979  poly p= (poly)h->Data();
2980  h = h->next;
2981  if((h != NULL)&&(h->Typ() == POLY_CMD))
2982  {
2983  poly q= (poly)h->Data();
2984  res->rtyp =INTVEC_CMD;
2985  res->data =dmat(p,q);
2986  }
2987  }
2988  return false;
2989 }
2990 
2991 
2992 
2994 {
2995  leftv h=args;
2996  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
2997  {
2998  ideal h1= (ideal)h->Data();
2999  res->rtyp =IDEAL_CMD;
3000  res->data =findb(h1);
3001  }
3002  return false;
3003 }
3004 
3005 
3006 
3008 {
3009  leftv h=args;
3010  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3011  {
3012  ideal h1= (ideal)h->Data();
3013  h = h->next;
3014  if((h != NULL)&&(h->Typ() == POLY_CMD))
3015  {
3016  poly q= (poly)h->Data();
3017  h = h->next;
3018  if((h != NULL)&&(h->Typ() == INT_CMD))
3019  {
3020  int d= (int)(long)h->Data();
3021  res->rtyp =IDEAL_CMD;
3022  res->data =finda(h1,q,d);
3023  }
3024  }
3025  }
3026  return false;
3027 }
3028 
3029 
3031 {
3032  leftv h=args;
3033  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3034  {
3035  ideal h1= (ideal)h->Data();
3036  h = h->next;
3037  if((h != NULL)&&(h->Typ() == POLY_CMD))
3038  {
3039  poly p= (poly)h->Data();
3040  h = h->next;
3041  if((h != NULL)&&(h->Typ() == POLY_CMD))
3042  {
3043  poly q= (poly)h->Data();
3044  res->rtyp =INTVEC_CMD;
3045  res->data =gradedpiece1n(h1,p,q);
3046  }
3047  }
3048  }
3049  return false;
3050 }
3051 
3052 
3053 
3055 {
3056  leftv h=args;
3057  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3058  {
3059  ideal h1= (ideal)h->Data();
3060  h = h->next;
3061  if((h != NULL)&&(h->Typ() == POLY_CMD))
3062  {
3063  poly p= (poly)h->Data();
3064  h = h->next;
3065  if((h != NULL)&&(h->Typ() == POLY_CMD))
3066  {
3067  poly q= (poly)h->Data();
3068  res->rtyp =IDEAL_CMD;
3069  res->data =genst(h1,p,q);
3070  }
3071  }
3072  }
3073  return false;
3074 }
3075 
3076 
3078 {
3079  leftv h=args;
3080  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3081  {
3082  ideal h1= (ideal)h->Data();
3083  h = h->next;
3084  if((h != NULL)&&(h->Typ() == POLY_CMD))
3085  {
3086  poly p= (poly)h->Data();
3087  h = h->next;
3088  if((h != NULL)&&(h->Typ() == POLY_CMD))
3089  {
3090  poly q= (poly)h->Data();
3091  res->rtyp =INTVEC_CMD;
3092  res->data =gradedpiece2n(h1,p,q);
3093  }
3094  }
3095  }
3096  return false;
3097 }
3098 
3099 
3101 {
3102  leftv h=args;
3103  if((h != NULL)&&(h->Typ() == POLY_CMD))
3104  {
3105  poly p= (poly)h->Data();
3106  h = h->next;
3107  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3108  {
3109  ideal h1= (ideal)h->Data();
3110  res->rtyp =IDEAL_CMD;
3111  std::vector<std::vector<int> > vecs=links(p,h1);
3112  res->data =idMaken(vecs);
3113  }
3114  }
3115  return false;
3116 }
3117 
3118 
3119 /**************************************interface T2****************************************/
3120 
3121 
3122 
3124 {
3125  p->iiAddCproc("","mg",FALSE,idsr);
3126  p->iiAddCproc("","gd",FALSE,gd);
3127  p->iiAddCproc("","findbset",FALSE,fb);
3128  p->iiAddCproc("","findaset",FALSE,fa);
3129  p->iiAddCproc("","fgp",FALSE,fgp);
3130  p->iiAddCproc("","idcomplement",FALSE,idcomplement);
3131  p->iiAddCproc("","genst",FALSE,genstt);
3132  p->iiAddCproc("","sgp",FALSE,sgp);
3133  p->iiAddCproc("","Links",FALSE,Links);
3134 }
3135 
3136 
3137 
3138 extern "C" int SI_MOD_INIT(stanleyreisnerlib)(SModulFunctions* p)
3139 {
3141  return MAX_TOK;
3142 }
3143 
3144 
3145 #endif
3146 
3147 
FALSE
#define FALSE
Definition: auxiliary.h:94
idCopy
ideal idCopy(ideal A)
Definition: ideals.h:60
subspacet1
std::vector< int > subspacet1(int num, std::vector< std::vector< int > > ntvs)
Definition: cohomo.cc:1846
omalloc.h
hutil.h
sleftv::Data
void * Data()
Definition: subexpr.cc:1134
idMake
ideal idMake(std::vector< std::vector< int > > vecs)
Definition: cohomo.cc:1094
idsrRing
ideal idsrRing(ideal h)
Definition: cohomo.cc:312
vEv
bool vEv(std::vector< int > vec1, std::vector< int > vec2)
Definition: cohomo.cc:482
p_Subst
poly p_Subst(poly p, int n, poly e, const ring r)
Definition: p_polys.cc:3851
p_GetExp
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469
gradedpiece2n
intvec * gradedpiece2n(ideal h, poly a, poly b)
Definition: cohomo.cc:2663
listprint
void listprint(std::vector< int > vec)
Definition: cohomo.cc:65
j
int j
Definition: facHensel.cc:105
idcomplement
BOOLEAN idcomplement(leftv res, leftv args)
Definition: cohomo.cc:2908
assert
#define assert(A)
Definition: svd_si.h:3
equmab
void equmab(int num)
Definition: cohomo.cc:1386
makemab
ideal makemab(ideal h, poly a, poly b)
Definition: cohomo.cc:2841
IsSimplex
bool IsSimplex(ideal h)
Definition: cohomo.cc:379
cohomo.h
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition: polys.cc:15
v_minus
std::vector< int > v_minus(std::vector< int > v1, std::vector< int > v2)
Definition: cohomo.cc:2849
iiMake_proc
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:485
pGetExp
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
idAdd
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition: ideals.h:68
lists.h
pMaken
poly pMaken(std::vector< int > vbase)
Definition: cohomo.cc:1434
enterid
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:257
num
CanonicalForm num(const CanonicalForm &f)
Definition: canonicalform.h:330
CxxTest::base
char N base
Definition: ValueTraits.h:144
Tmat
intvec * Tmat(std::vector< std::vector< int > > vecs)
Definition: cohomo.cc:2235
scKBase
ideal scKBase(int deg, ideal s, ideal Q, intvec *mv)
Definition: hdegree.cc:1353
ofindbases
std::vector< std::vector< int > > ofindbases(int num, std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition: cohomo.cc:999
tdeg
int tdeg(poly p)
Definition: walkSupport.cc:35
cf
CanonicalForm cf
Definition: cfModGcd.cc:4024
getpresolve
ideal getpresolve(ideal h)
Definition: cohomo.cc:1667
findb
ideal findb(ideal h)
Definition: cohomo.cc:645
MAX_TOK
@ MAX_TOK
Definition: tok.h:215
id_MaxIdeal
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
Definition: simpleideals.cc:100
simpleideals.h
vecqring
std::vector< std::vector< int > > vecqring(std::vector< std::vector< int > > vec1, std::vector< std::vector< int > > vec2)
Definition: cohomo.cc:1197
phimage
std::vector< int > phimage(std::vector< int > pv, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:2186
gensindex
std::vector< int > gensindex(ideal M, ideal ids)
Definition: cohomo.cc:2292
idInsertPoly
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
Definition: simpleideals.cc:640
genst
ideal genst(ideal h, poly a, poly b)
Definition: cohomo.cc:2637
vInvs
int vInvs(std::vector< int > vec, std::vector< std::vector< int > > vecs)
Definition: cohomo.cc:548
tgb.h
eli2
std::vector< std::vector< int > > eli2(int num, std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition: cohomo.cc:1034
lpsprint
void lpsprint(std::vector< std::vector< poly > > pvs)
Definition: cohomo.cc:134
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
bad
bool bad
Definition: facFactorize.cc:65
mvar
Variable mvar(const CanonicalForm &f)
Definition: canonicalform.h:327
vecUnion
std::vector< int > vecUnion(std::vector< int > vec1, std::vector< int > vec2)
Definition: cohomo.cc:567
Tlink
void Tlink(ideal h, poly a, poly b, int n)
Definition: cohomo.cc:2798
pp_Mult_mm
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:987
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
makeequation
std::vector< int > makeequation(int i, int j, int t)
Definition: cohomo.cc:1321
pMake3
poly pMake3(std::vector< int > vbase)
Definition: cohomo.cc:1338
testHomog
@ testHomog
Definition: structs.h:41
Links
BOOLEAN Links(leftv res, leftv args)
Definition: cohomo.cc:3100
id_maxdeg
int id_maxdeg(ideal h)
Definition: cohomo.cc:298
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition: simpleideals.cc:768
eli1
std::vector< int > eli1(std::vector< int > eq1, std::vector< int > eq2)
Definition: cohomo.cc:776
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
RING_CMD
@ RING_CMD
Definition: grammar.cc:281
b
CanonicalForm b
Definition: cfModGcd.cc:4044
dmat
intvec * dmat(poly a, poly b)
Definition: cohomo.cc:2946
IsinL
bool IsinL(int a, std::vector< int > badset)
Definition: cohomo.cc:442
nabconditionv
bool nabconditionv(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:2055
pTotaldegree
static long pTotaldegree(poly p)
Definition: polys.h:268
condition3for2
bool condition3for2(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > qv, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:1640
condition1for2
bool condition1for2(std::vector< int > pv, std::vector< int > qv, std::vector< int > bv)
Definition: cohomo.cc:1607
pMakei
std::vector< poly > pMakei(std::vector< std::vector< int > > mv, std::vector< int > vbase)
Definition: cohomo.cc:1483
finda
ideal finda(ideal h, poly S, int ddeg)
Definition: cohomo.cc:676
idMakei
std::vector< std::vector< poly > > idMakei(std::vector< std::vector< int > > mv, std::vector< std::vector< int > > vecs)
Definition: cohomo.cc:1497
make1
std::vector< int > make1(int n)
Definition: cohomo.cc:951
vecIntersection
std::vector< int > vecIntersection(std::vector< int > p, std::vector< int > q)
Definition: cohomo.cc:460
rDefault
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition: ring.cc:103
links
std::vector< std::vector< int > > links(poly a, ideal h)
Definition: cohomo.cc:1215
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
stairc.h
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
i
int i
Definition: cfEzgcd.cc:125
res
CanonicalForm res
Definition: facAbsFact.cc:64
INT_CMD
@ INT_CMD
Definition: tok.h:96
fvarsvalue
std::vector< int > fvarsvalue(int vnum, std::vector< int > fvars)
Definition: cohomo.cc:852
gd
BOOLEAN gd(leftv res, leftv args)
Definition: cohomo.cc:2974
M
#define M
Definition: sirandom.c:24
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
firstorderdef_setup
void firstorderdef_setup(SModulFunctions *p)
Definition: cohomo.cc:3123
hilb.h
Mabv
std::vector< std::vector< int > > Mabv(ideal h, poly a, poly b)
Definition: cohomo.cc:732
condition2for2
bool condition2for2(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > qv, std::vector< int > sv, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:1622
subspacetn
std::vector< std::vector< int > > subspacetn(std::vector< std::vector< int > > N, std::vector< int > tN, std::vector< std::vector< int > > ntvs)
Definition: cohomo.cc:2547
gradedpiece1
void gradedpiece1(ideal h, poly a, poly b)
Definition: cohomo.cc:1523
id_complement
ideal id_complement(ideal h)
Definition: cohomo.cc:264
nabtv
std::vector< std::vector< int > > nabtv(std::vector< std::vector< int > > hvs, std::vector< std::vector< int > > Nv, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:2109
listsinsertlist
std::vector< std::vector< int > > listsinsertlist(std::vector< std::vector< int > > gset, int a, int b)
Definition: cohomo.cc:1308
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition: simpleideals.cc:172
idMinus
ideal idMinus(ideal h1, ideal h2)
Definition: cohomo.cc:167
IDROOT
#define IDROOT
Definition: ipid.h:18
sleftv::Init
void Init()
Definition: subexpr.h:107
sfreemon
ideal sfreemon(ideal h, int deg)
Definition: cohomo.cc:210
IDEAL_CMD
@ IDEAL_CMD
Definition: grammar.cc:283
h
static Poly * h
Definition: janet.cc:972
gp
CanonicalForm gp
Definition: cfModGcd.cc:4043
mod2.h
idMake3
ideal idMake3(std::vector< std::vector< int > > vecs)
Definition: cohomo.cc:1362
max
static int max(int a, int b)
Definition: fast_mult.cc:264
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
coeffs
pOne
#define pOne()
Definition: polys.h:301
T2
void T2(ideal h)
Definition: cohomo.cc:2754
sgp
BOOLEAN sgp(leftv res, leftv args)
Definition: cohomo.cc:3077
pMake
poly pMake(std::vector< int > vbase)
Definition: cohomo.cc:1075
intvec
Definition: intvec.h:21
vsMake
std::vector< std::vector< int > > vsMake(ideal h)
Definition: cohomo.cc:1181
fa
BOOLEAN fa(leftv res, leftv args)
Definition: cohomo.cc:3007
sleftv::data
void * data
Definition: subexpr.h:88
id_print
void id_print(ideal h)
Definition: cohomo.cc:101
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
p_polys.h
psubset
ideal psubset(poly p)
Definition: cohomo.cc:1282
subspace1
std::vector< int > subspace1(std::vector< std::vector< int > > mv, std::vector< int > bv)
Definition: cohomo.cc:1410
mabconditionv
bool mabconditionv(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:716
p_DivisibleBy
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1824
vecMinus
std::vector< int > vecMinus(std::vector< int > vec1, std::vector< int > vec2)
Definition: cohomo.cc:581
subspacet
std::vector< std::vector< int > > subspacet(std::vector< std::vector< int > > mv, std::vector< int > bv, std::vector< std::vector< int > > ntvs)
Definition: cohomo.cc:1877
lpprint
void lpprint(std::vector< poly > pv)
Definition: cohomo.cc:117
genstt
BOOLEAN genstt(leftv res, leftv args)
Definition: cohomo.cc:3054
pp
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
slists::m
sleftv * m
Definition: lists.h:45
pcoef
int pcoef(poly p, int m)
Definition: cohomo.cc:1124
vsubset
bool vsubset(std::vector< int > vec1, std::vector< int > vec2)
Definition: cohomo.cc:505
intvec.h
complementsimplex
ideal complementsimplex(ideal h)
Definition: cohomo.cc:409
support1
std::vector< int > support1(poly p)
Definition: cohomo.cc:608
tNab
bool tNab(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< std::vector< int > > bvs)
Definition: cohomo.cc:2140
kNF
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2813
pAdd
#define pAdd(p, q)
Definition: polys.h:190
soleli1
std::vector< std::vector< int > > soleli1(std::vector< std::vector< int > > eqs)
Definition: cohomo.cc:795
ringorder_lp
@ ringorder_lp
Definition: ring.h:84
freevars
std::vector< int > freevars(int n, std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition: cohomo.cc:825
IDRING
#define IDRING(a)
Definition: ipid.h:122
fgp
BOOLEAN fgp(leftv res, leftv args)
Definition: cohomo.cc:3030
pSetCoeff
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
slists
Definition: lists.h:23
SimFacset
ideal SimFacset(poly p)
Definition: cohomo.cc:355
INTVEC_CMD
@ INTVEC_CMD
Definition: tok.h:101
IMATELEM
#define IMATELEM(M, I, J)
Definition: intvec.h:85
ring.h
idrec
Definition: idrec.h:35
transext.h
kstd1.h
vInvsl
bool vInvsl(std::vector< int > vec, std::vector< std::vector< int > > vecs)
Definition: cohomo.cc:531
minisolve
std::vector< std::vector< int > > minisolve(std::vector< std::vector< int > > solve, std::vector< int > index)
Definition: cohomo.cc:2336
canonicalbase
std::vector< std::vector< int > > canonicalbase(int n)
Definition: cohomo.cc:1721
nCopyCoeff
static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
"copy" coeffs, i.e. increment ref
Definition: coeffs.h:430
p_EqualPolys
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4396
supports
std::vector< std::vector< int > > supports(ideal h)
Definition: cohomo.cc:623
idmodulo
ideal idmodulo(ideal h1, ideal h2)
Definition: cohomo.cc:1113
make0
std::vector< int > make0(int n)
Definition: cohomo.cc:937
mabtv
std::vector< std::vector< int > > mabtv(std::vector< std::vector< int > > hvs, std::vector< std::vector< int > > Mv, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:1897
libsingular.h
Print
#define Print
Definition: emacs.cc:80
omalloc
#define omalloc(size)
Definition: omAllocDecl.h:228
mylimits.h
iiRETURNEXPR
sleftv iiRETURNEXPR
Definition: iplib.cc:455
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
listsprint
void listsprint(std::vector< std::vector< int > > posMat)
Definition: cohomo.cc:82
solve
bool solve(int **extmat, int nrows, int ncols)
Definition: cf_linsys.cc:504
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
nabtconditionv
bool nabtconditionv(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > qv, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:2094
m
int m
Definition: cfEzgcd.cc:121
gradedpiece2
void gradedpiece2(ideal h, poly a, poly b)
Definition: cohomo.cc:1922
getvector
std::vector< std::vector< int > > getvector(ideal h, int n)
Definition: cohomo.cc:1745
SModulFunctions
Definition: ipid.h:68
sleftv::rtyp
int rtyp
Definition: subexpr.h:91
NULL
#define NULL
Definition: omList.c:10
sleftv::CopyD
void * CopyD(int t)
Definition: subexpr.cc:703
lists
slists * lists
Definition: mpr_numeric.h:146
pSetm
#define pSetm(p)
Definition: polys.h:257
ideals.h
idsr
BOOLEAN idsr(leftv res, leftv args)
Definition: cohomo.cc:2923
tnab
std::vector< int > tnab(std::vector< std::vector< int > > hvs, std::vector< std::vector< int > > nvs, std::vector< std::vector< int > > bvs)
Definition: cohomo.cc:2163
l
int l
Definition: cfEzgcd.cc:93
n_Int
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition: coeffs.h:548
R
#define R
Definition: sirandom.c:26
id_sfmon
ideal id_sfmon()
Definition: cohomo.cc:239
condition2for2nv
bool condition2for2nv(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > qv, std::vector< int > fv)
Definition: cohomo.cc:2510
pSetExp
#define pSetExp(p, i, v)
Definition: polys.h:42
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
p
int p
Definition: cfModGcd.cc:4019
idMaken
ideal idMaken(std::vector< std::vector< int > > vecs)
Definition: cohomo.cc:1452
ggetid
idhdl ggetid(const char *n)
Definition: ipid.cc:513
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
vecbase1
std::vector< int > vecbase1(int num, std::vector< int > oset)
Definition: cohomo.cc:919
qringadd
ideal qringadd(ideal h1, ideal h2, int deg)
Definition: cohomo.cc:285
nInit
#define nInit(i)
Definition: numbers.h:25
findalpha
std::vector< int > findalpha(std::vector< std::vector< int > > mv, std::vector< int > bv)
Definition: cohomo.cc:1824
POLY_CMD
@ POLY_CMD
Definition: grammar.cc:288
numfree
std::vector< int > numfree(ideal h)
Definition: cohomo.cc:1698
pCopy
#define pCopy(p)
return a copy of the poly
Definition: polys.h:172
vMake
std::vector< int > vMake(poly p)
Definition: cohomo.cc:1161
ipshell.h
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:26
kStd
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2096
value2
std::vector< std::vector< int > > value2(std::vector< std::vector< int > > mvs, std::vector< std::vector< int > > nvs, std::vector< std::vector< int > > mts, std::vector< std::vector< int > > nts, std::vector< std::vector< int > > vecs, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:2569
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:51
id_Add
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
Definition: simpleideals.cc:714
rCopy
ring rCopy(ring r)
Definition: ring.cc:1605
PrintLn
void PrintLn()
Definition: reporter.cc:310
gdegree
std::vector< int > gdegree(poly a, poly b)
Definition: cohomo.cc:2860
p_Ifsfree
bool p_Ifsfree(poly P)
Definition: cohomo.cc:195
vEvl
bool vEvl(std::vector< int > vec1, std::vector< int > vec2)
Definition: cohomo.cc:519
Nabv
std::vector< std::vector< int > > Nabv(std::vector< std::vector< int > > hvs, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:2075
index
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
ofindbases1
std::vector< int > ofindbases1(int num, int vnum, std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition: cohomo.cc:967
findalphan
std::vector< int > findalphan(std::vector< std::vector< int > > N, std::vector< int > tN)
Definition: cohomo.cc:2528
numbers.h
stanleyreisnerlib
int SI_MOD_INIT() stanleyreisnerlib(SModulFunctions *p)
Definition: cohomo.cc:3138
pNext
#define pNext(p)
Definition: monomials.h:43
ipid.h
mingens
ideal mingens(ideal h, poly a, poly b)
Definition: cohomo.cc:2311
rSetHdl
void rSetHdl(idhdl h)
Definition: ipshell.cc:5050
vAbsorb
std::vector< std::vector< int > > vAbsorb(std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition: cohomo.cc:869
gradedpiece1n
intvec * gradedpiece1n(ideal h, poly a, poly b)
Definition: cohomo.cc:2359
T1
void T1(ideal h)
Definition: cohomo.cc:2473
vInp
bool vInp(int m, poly p)
Definition: cohomo.cc:1143
fb
BOOLEAN fb(leftv res, leftv args)
Definition: cohomo.cc:2993
coeffs.h
linearAlgebra.h
vec
fq_nmod_poly_t * vec
Definition: facHensel.cc:103
value1
std::vector< std::vector< int > > value1(std::vector< std::vector< int > > mvs, std::vector< std::vector< int > > nvs, std::vector< std::vector< int > > vecs, std::vector< int > av, std::vector< int > bv)
Definition: cohomo.cc:2197
pWrite
void pWrite(poly p)
Definition: polys.h:294