My Project
Loading...
Searching...
No Matches
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#if !defined(__CYGWIN__) || defined(STATIC_VERSION)
11// acces from a module to routines from the main program
12// does not work on windows (restrict of the dynamic linker),
13// a static version is required:
14// ./configure --with-builtinmodules=cohomo,...
15
16
17#include "omalloc/omalloc.h"
18#include "misc/mylimits.h"
20#include <assert.h>
21#include <unistd.h>
22
26#include "cohomo.h"//for my thing
27#include "kernel/GBEngine/tgb.h"//
28#include "Singular/ipid.h"//for ggetid
31#include "polys/simpleideals.h"
32#include "Singular/lists.h"
33#include "kernel/linear_algebra/linearAlgebra.h"//for printNumber
34#include "kernel/GBEngine/kstd1.h"//for gb
35#include <kernel/ideals.h>
36#if 1
37
41#include <coeffs/numbers.h>
42#include <vector>
43#include <Singular/ipshell.h>
45#include <time.h>
46
47/***************************print(only for debugging)***********************************************/
48//print vector of integers.
49static void listprint(std::vector<int> vec)
50{
51 unsigned i;
52 for(i=0;i<vec.size();i++)
53 {
54 Print(" _[%d]=%d\n",i+1,vec[i]);
55 PrintLn();
56 }
57 if(vec.size()==0)
58 {
59 PrintS(" _[1]= \n");
60 PrintLn();
61 }
62}
63
64//print vector of vectors of integers.
65static void listsprint(std::vector<std::vector<int> > posMat)
66{
67 unsigned i;
68 for(i=0;i<posMat.size();i++)
69 {
70 Print("[%d]:\n",i+1);
72 Print("\n");
73 PrintLn();
74 }
75 if(posMat.size()==0)
76 {
77 PrintS("[1]:\n");
78 PrintLn();
79 }
80}
81
82
83//print ideal.
84static void id_print(ideal h)
85{
86 int i;
87 for(i=0;i<IDELEMS(h);i++)
88 {
89 Print(" [%d]\n",i+1);
90 pWrite(h->m[i]);
91 PrintLn();
92 }
93}
94
95//only for T^2,
96//print vector of polynomials.
97static void lpprint( std::vector<poly> pv)
98{
99 for(unsigned i=0;i<pv.size();i++)
100 {
101 Print(" _[%d]=",i+1);
102 pWrite(pv[i]);
103 }
104 if(pv.size()==0)
105 {
106 PrintS(" _[1]= \n");
107 PrintLn();
108 }
109}
110
111//print vector of vectors of polynomials.
112static void lpsprint(std::vector<std::vector<poly> > pvs)
113{
114 for(unsigned i=0;i<pvs.size();i++)
115 {
116 Print("[%d]:\n",i+1);
117 lpprint(pvs[i]);
118 Print("\n");
119 PrintLn();
120 }
121 if(pvs.size()==0)
122 {
123 PrintS("[1]:\n");
124 PrintLn();
125 }
126}
127
128/*************operations for vectors (regard vectors as sets)*********/
129
130//returns true if integer n is in vector vec,
131//otherwise, returns false
132static bool IsinL(int a, std::vector<int> vec)
133{
134 unsigned i;
135 for(i=0;i<vec.size();i++)
136 {
137 if(a==vec[i])
138 {
139 return true;
140 }
141 }
142 return false;
143}
144
145//returns intersection of vectors p and q,
146//returns empty if they are disjoint
147static std::vector<int> vecIntersection(std::vector<int> p, std::vector<int> q)
148{
149 unsigned i;
150 std::vector<int> inte;
151 for(i=0;i<p.size();i++)
152 {
153 if(IsinL(p[i],q))
154 inte.push_back(p[i]);
155 }
156 return inte;
157}
158
159//returns true if vec1 is contained in vec2
160static bool vsubset(std::vector<int> vec1, std::vector<int> vec2)
161{
162 int i;
163 if(vec1.size()>vec2.size())
164 return false;
165 for(i=0;i<vec1.size();i++)
166 {
167 if(!IsinL(vec1[i],vec2))
168 return false;
169 }
170 return true;
171}
172
173//not strictly equal(order doesn't matter)
174static bool vEvl(std::vector<int> vec1, std::vector<int> vec2)
175{
176 if(vec1.size()==0 && vec2.size()==0)
177 return true;
179 return true;
180 return false;
181}
182
183//the length of vec must be same to it of the elements of vecs
184//returns true if vec is as same as some element of vecs ((not strictly same))
185//returns false if vec is not in vecs
186static bool vInvsl(std::vector<int> vec, std::vector<std::vector<int> > vecs)
187{
188 int i;
189 for(i=0;i<vecs.size();i++)
190 {
191 if(vEvl(vec,vecs[i]))
192 {
193 return true;
194 }
195 }
196 return false;
197}
198
199//returns the union of two vectors(as the union of sets)
200static std::vector<int> vecUnion(std::vector<int> vec1, std::vector<int> vec2)
201{
202 std::vector<int> vec=vec1;
203 unsigned i;
204 for(i=0;i<vec2.size();i++)
205 {
206 if(!IsinL(vec2[i],vec))
207 vec.push_back(vec2[i]);
208 }
209 return vec;
210}
211
212static std::vector<int> vecMinus(std::vector<int> vec1,std::vector<int> vec2)
213{
214 std::vector<int> vec;
215 for(unsigned i=0;i<vec1.size();i++)
216 {
217 if(!IsinL(vec1[i],vec2))
218 {
219 vec.push_back(vec1[i]);
220 }
221 }
222 return vec;
223}
224
225static std::vector<std::vector<int> > vsMinusv(std::vector<std::vector<int> > vecs, std::vector<int> vec)
226{
227 int i;
228 std::vector<std::vector<int> > rem;
229 for(i=0;i<vecs.size();i++)
230 {
231 if(!vEvl(vecs[i],vec))
232 {
233 rem.push_back(vecs[i]);
234 }
235 }
236 return (rem);
237}
238
239static std::vector<std::vector<int> > vsUnion(std::vector<std::vector<int> > vs1, std::vector<std::vector<int> > vs2)
240{
241 int i;
242 std::vector<std::vector<int> > vs=vs1;
243 for(i=0;i<vs2.size();i++)
244 {
245 if(!vInvsl(vs2[i],vs))
246 {
247 vs.push_back(vs2[i]);
248 }
249 }
250 return vs;
251}
252
253static std::vector<std::vector<int> > vsIntersection(std::vector<std::vector<int> > vs1, std::vector<std::vector<int> > vs2)
254{
255 int i;
256 std::vector<std::vector<int> > vs;
257 for(i=0;i<vs2.size();i++)
258 {
259 if(vInvsl(vs2[i],vs1))
260 {
261 vs.push_back(vs2[i]);
262 }
263 }
264 return vs;
265}
266
267/*************************************for transition between ideal and vectors******************************************/
268
269//P should be monomial,
270// vector version of poly support(poly p)
271static std::vector<int> support1(poly p)
272{
273 int j;
274 std::vector<int> supset;
275 if(p==0) return supset;
276 for(j=1;j<=rVar(currRing);j++)
277 {
278 if(pGetExp(p,j)>0)
279 {
280 supset.push_back(j);
281 }
282 }
283 return (supset);
284}
285
286//simplicial complex(the faces set is ideal h)
287static std::vector<std::vector<int> > supports(ideal h)
288{
289 std::vector<std::vector<int> > vecs;
290 std::vector<int> vec;
291 if(!idIs0(h))
292 {
293 for(int s=0;s<IDELEMS(h);s++)
294 {
295 vec=support1(h->m[s]);
296 vecs.push_back(vec);
297 }
298 }
299 return vecs;
300}
301
302// only for eqsolve1
303// p could be any polynomial
304static std::vector<int> support2(poly p)
305{
306 int j;
307 poly q;
308 std::vector<int> supset;
309 for(j=1;j<=rVar(currRing);j++)
310 {
311 q=pCopy(p);
312 while (q!=NULL)
313 {
314 if(p_GetExp(q,j,currRing)!=0)
315 {
316 supset.push_back(j);
317 break;
318 }
319 q=pNext(q);
320 }
321 }
322 return (supset);
323}
324
325//the supports of ideal
326static std::vector<std::vector<int> > supports2(ideal h)
327{
328 std::vector<std::vector<int> > vecs;
329 std::vector<int> vec;
330 if(!idIs0(h))
331 {
332 for(int s=0;s<IDELEMS(h);s++)
333 {
334 vec=support2(h->m[s]);
335 vecs.push_back(vec);
336 }
337 }
338 return vecs;
339}
340
341//convert the vector(vbase[i] are the coefficients of x_{i+1}) to a polynomial w.r.t. current ring
342//vector vbase has length of currRing->N.
343static poly pMake(std::vector<int> vbase)
344{
345 int n=vbase.size(); poly p,q=0;
346 for(int i=0;i<n;i++)
347 {
348 if(vbase[i]!=0)
349 {
350 p = pOne();pSetExp(p, i+1, 1);pSetm(p);pSetCoeff(p, nInit(vbase[i]));
351 q = pAdd(q, p);
352 }
353 }
354 return q;
355}
356
357//convert the vectors to a ideal(for T^1)
358static ideal idMake(std::vector<std::vector<int> > vecs)
359{
360 int lv=vecs.size(), i;
361 poly p;
362 ideal id_re=idInit(1,1);
363 for(i=0;i<lv;i++)
364 {
365 p=pMake(vecs[i]);
367 }
369 return id_re;
370}
371
372/*****************************quotient ring of two ideals*********************/
373
374//the quotient ring of h1 respect to h2
376{
381 return idq;
382}
383
384//returns the coeff of the monomial of polynomial p which involves the mth varialbe
385//assume the polynomial p has form of y1+y2+...
386static int pcoef(poly p, int m)
387{
388 int i,co; poly q=pCopy(p);
389 for(i=1;i<=currRing->N;i++)
390 {
391 if(p_GetExp(q,m,currRing)!=0)
392 {
393 co=n_Int(pGetCoeff(q),currRing->cf);
394 return co;
395 }
396 else
397 q=pNext(q);
398 }
399 if(q!=NULL)
400 co=0;
401 return co;
402}
403
404//returns true if p involves the mth variable of the current ring
405static bool vInp(int m,poly p)
406{
407 poly q=pCopy(p);
408 while (q!=NULL)
409 {
410 if(p_GetExp(q,m,currRing)!=0)
411 {
412 return true;
413 }
414 q=pNext(q);
415 }
416 return false;
417}
418
419//returns the vector w.r.t. polynomial p
420static std::vector<int> vMake(poly p)
421{
422 int i;
423 std::vector<int> vbase;
424 for(i=1;i<=currRing->N;i++)
425 {
426 if(vInp(i,p))
427 {
428 vbase.push_back(pcoef(p,i));
429 }
430 else
431 {
432 vbase.push_back(0);
433 }
434 }
435 return (vbase);
436}
437
438//returns the vectors w.r.t. ideal h
439static std::vector<std::vector<int> > vsMake(ideal h)
440{
441 std::vector<int> vec;
442 std::vector<std::vector<int> > vecs;
443 int i;
444 for(i=0;i<IDELEMS(h);i++)
445 {
446 vec=vMake(h->m[i]);
447 vecs.push_back(vec);
448 }
449 return vecs;
450}
451
452//the quotient ring of two ideals which are represented by vectors,
453//the result is also represented by vector.
454static std::vector<std::vector<int> > vecqring(std::vector<std::vector<int> > vec1, std::vector<std::vector<int> > vec2)
455{
458 std::vector<std::vector<int> > vecs= vsMake(h);
459 return vecs;
460}
461
462/****************************************************************/
463//construct a monomial based on the support of it
464//returns a squarefree monomial
465static poly pMaken(std::vector<int> vbase)
466{
467 int n=vbase.size();
468 poly p,q=pOne();
469 for(int i=0;i<n;i++)
470 {
471 p = pOne();pSetExp(p, vbase[i], 1);pSetm(p);pSetCoeff(p, nInit(1));
472 //pWrite(p);
473 q=pp_Mult_mm(q,p,currRing);
474 }
475 return q;
476}
477
478// returns a ideal according to a set of supports
479static ideal idMaken(std::vector<std::vector<int> > vecs)
480{
481 ideal id_re=idInit(1,1);
482 poly p;
483 int i,lv=vecs.size();
484 for(i=0;i<lv;i++)
485 {
486 p=pMaken(vecs[i]);
488 }
490 //id_print(id_re);
491 return id_re;
492}
493
494/********************************new version for stanley reisner ideal ***********************************************/
495
496static std::vector<std::vector<int> > b_subsets(std::vector<int> vec)
497{
498 int i,j;
499 std::vector<int> bv;
500 std::vector<std::vector<int> > vecs;
501 for(i=0;i<vec.size();i++)
502 {
503 bv.push_back(vec[i]);
504 vecs.push_back(bv);
505 bv.clear();
506 }
507 //listsprint(vecs);
508 for(i=0;i<vecs.size();i++)
509 {
510 for(j=i+1;j<vecs.size();j++)
511 {
512 bv=vecUnion(vecs[i], vecs[j]);
513 if(!vInvsl(bv,vecs))
514 vecs.push_back(bv);
515 }
516 }
517 //listsprint(vecs);
518 return(vecs);
519}
520
521//the number of the variables
522static int idvert(ideal h)
523{
524 int i, j, vert=0;
525 if(idIs0(h))
526 return vert;
527 for(i=currRing->N;i>0;i--)
528 {
529 for(j=0;j<IDELEMS(h);j++)
530 {
531 if(pGetExp(h->m[j],i)>0)
532 {
533 vert=i;
534 return vert;
535 }
536 }
537 }
538 return vert;
539}
540
541static int pvert(poly p)
542{
543 int i, vert=0;
544 for(i=currRing->N;i>0;i--)
545 {
546 if(pGetExp(p,i)>0)
547 {
548 vert=i;
549 return vert;
550 }
551 }
552 return vert;
553}
554
555/*
556//full complex
557static std::vector<std::vector<int> > fullcomplex(ideal h)
558{
559 int vert=vertnum(h), i, j;
560 //Print("there are %d vertices\n", vert);
561 std::vector<std::vector<int> > fmons;
562 std::vector<int> pre;
563 for(i=1;i<=vert;i++)
564 {
565 pre.push_back(i);
566 }
567 fmons=b_subsets(pre);
568 return fmons;
569}*/
570
571/*
572//all the squarefree monomials whose degree is less or equal to n
573static std::vector<std::vector<int> > sfrmons(ideal h, int n)
574{
575 int vert=vertnum(h), i, j, time=0;
576 std::vector<std::vector<int> > fmons, pres, pres0, pres1;
577 std::vector<int> pre;
578 for(i=1;i<=vert;i++)
579 {
580 pre.push_back(i);
581 pres0.push_back(pre);
582 }
583 pres=pres0;
584 for(i=0;i<size(pres),time<=n;i++)
585 {
586 time++;
587 pre=pres[i];
588 for(j=0;j<size(pres0);j++)
589 {
590 pre=vecUnion(pre, pres0[j]);
591 if(pre.)
592 }
593 }
594 return fmons;
595}
596*/
597
598/*
599static ideal id_complement(ideal h)
600{
601 int i,j;
602 std::vector<std::vector<int> > full=fullcomplex(h), hvs=supports(h), res;
603 for(i=0;i<full.size();i++)
604 {
605 if(!vInvsl(full[i], hvs))
606 {
607 res.push_back(full[i]);
608 }
609 }
610 return idMaken(res);
611}*/
612
613
614/*****************About simplicial complex and stanley-reisner ideal and ring **************************/
615
616//h1 minus h2
618{
619 ideal h=idInit(1,1);
620 int i,j,eq=0;
621 for(i=0;i<IDELEMS(h1);i++)
622 {
623 eq=0;
624 for(j=0;j<IDELEMS(h2);j++)
625 {
626 if(p_EqualPolys(pCopy(h1->m[i]),pCopy(h2->m[j]), currRing))
627 {
628 eq=1;
629 break;
630 }
631 }
632 if(eq==0)
633 {
634 idInsertPoly(h, pCopy(h1->m[i]));
635 }
636 }
638 return h;
639}
640
641//If poly P is squarefree, returns 1
642//returns 0 otherwise,
643static bool p_Ifsfree(poly P)
644{
645 int i,sf=1;
646 for(i=1;i<=rVar(currRing);i++)
647 {
648 if (pGetExp(P,i)>1)
649 {
650 sf=0;
651 break;
652 }
653 }
654 return sf;
655}
656
657//returns the set of all squarefree monomials of degree deg in ideal h
658static ideal sfreemon(ideal h,int deg)
659{
660 int j;
661 ideal temp;
662 temp=idInit(1,1);
663 if(!idIs0(h))
664 {
665 for(j=0;j<IDELEMS(h);j++)
666 {
667 if((p_Ifsfree(h->m[j]))&&(pTotaldegree(h->m[j])==deg))
668 {
669 idInsertPoly(temp, h->m[j]);
670 }
671 }
673 }
674 return temp;
675}
676
677//full simplex represented by ideal.
678//(all the squarefree monomials over the polynomial ring)
680{
682 int j, vert=idvert(h);
685 for(j=2;j<=vert;j++)
686 {
690 }
691 return asfmons;
692}
693
694//if the input ideal is simplicial complex, returns the stanley-reisner ideal,
695//if the input ideal is stanley-reisner ideal, returns the monomial ideal according to simplicial complex.
696//(nonfaces and faces).
697//returns the complement of the ideal h (consisting of only squarefree polynomials)
699{
700 int j, vert=idvert(h);
702 ideal i3=idInit(1,1);
703 poly p;
704 for(j=0;j<IDELEMS(i1);j++)
705 {
706 p=pCopy(i1->m[j]);
707 if(pvert(p)<=vert)
708 {
709 idInsertPoly(i3, p);
710 }
711 }
714 return (i2);
715}
716
717//Returns true if p is one of the generators of ideal X
718//returns false otherwise
719static bool IsInX(poly p,ideal X)
720{
721 int i;
722 for(i=0;i<IDELEMS(X);i++)
723 {
724 if(pEqualPolys(p,X->m[i]))
725 {
726 //PrintS("yes\n");
727 return(true);
728 }
729 }
730 //PrintS("no\n");
731 return(false);
732}
733
734//returns the monomials in the quotient ring R/(h1+h2) which have degree deg.
735static ideal qringadd(ideal h1, ideal h2, int deg)
736{
737 ideal h,qrh;
738 h=idAdd(h1,h2);
739 qrh=scKBase(deg,h);
740 return qrh;
741}
742
743//returns the maximal degree of the monomials in ideal h
744static int id_maxdeg(ideal h)
745{
746 int i,max;
747 max=pTotaldegree(h->m[0]);
748 for(i=1;i<IDELEMS(h);i++)
749 {
750 if(pTotaldegree(h->m[i]) > max)
751 max=pTotaldegree(h->m[i]);
752 }
753 return (max);
754}
755
756//input ideal h (a squarefree monomial ideal) is the ideal associated to simplicial complex,
757//and returns the Stanley-Reisner ideal(minimal generators)
759{
760 int i,n;
762 for(i=1;i<=rVar(currRing);i++)
763 {
764 pp=sfreemon(hc,i);
765 pp=scKBase(i,pp);//quotient ring (R/I_i)_i
766 if(!idIs0(pp))
767 {
768 pp=sfreemon(pp,i);
769 rsr=pp;
770 //Print("This is the first quotient generators %d:\n",i);
771 //id_print(rsr);
772 break;
773 }
774 }
775 for(n=i+1;n<=rVar(currRing);n++)
776 {
777 qq=sfreemon(hc,n);
778 pp=qringadd(qq,rsr,n);
779 ppp=sfreemon(pp,n);
780 rsr=idAdd(rsr,ppp);
781 }
783 return rsr;
784}
785
786//returns the set of all the polynomials could divide p
787static ideal SimFacset(poly p)
788{
789 int i,j,max=pTotaldegree(p);
790 ideal h1,mons,id_re=idInit(1,1);
791 for(i=1;i<max;i++)
792 {
794 h1=sfreemon(mons,i);
795
796 for(j=0;j<IDELEMS(h1);j++)
797 {
798 if(p_DivisibleBy(h1->m[j],p,currRing))
799 {
800 idInsertPoly(id_re, h1->m[j]);
801 }
802 }
803 }
805 return id_re;
806}
807
809{
810 ideal h=idInit(1,1);
811 for(int i=0;i<IDELEMS(h1);i++)
812 {
813 if(!IsInX(h1->m[i],h))
814 {
815 idInsertPoly(h, h1->m[i]);
816 }
817 }
818 for(int i=0;i<IDELEMS(h2);i++)
819 {
820 if(!IsInX(h2->m[i],h))
821 {
822 idInsertPoly(h, h2->m[i]);
823 }
824 }
826 return h;
827}
828
829//complicated version
830//(returns false if it is not a simplicial complex and print the simplex)
831//input h is need to be at least part of faces
833{
834 int i,max=id_maxdeg(h);
835 poly e=pOne();
837 for(i=0;i<IDELEMS(h);i++)
838 {
839 id_re=SimFacset(h->m[i]);
840 if(!idIs0(id_re))
841 {
842 id_so=idadda(id_so, id_re);//idAdd(id_so,id_re);
843 }
844 }
847 return (idMinus(id_so,h));
848}
849
850//input is the subset of the Stainley-Reisner ideal
851//returns the faces
852//is not used
854{
855 int i,j;poly p,e=pOne();
856 ideal h1=idInit(1,1), pp, h3;
857 for(i=1;i<=rVar(currRing);i++)
858 {
859 p = pOne(); pSetExp(p, i, 2); pSetm(p); pSetCoeff(p, nInit(1));
860 idInsertPoly(h1, p);
861 }
863 ideal h2=idAdd(h,h1);
864 pp=scKBase(1,h2);
865 h3=idCopy(pp);
866 for(j=2;j<=rVar(currRing);j++)
867 {
868 pp=scKBase(j,h2);
869 h3=idAdd(h3,pp);
870 }
871 idInsertPoly(h3, e);
873 return (h3);
874}
875
876static int dim_sim(ideal h)
877{
878 int dim=pTotaldegree(h->m[0]), i;
879 for(i=1; i<IDELEMS(h);i++)
880 {
881 if(dim<pTotaldegree(h->m[i]))
882 {
883 dim=pTotaldegree(h->m[i]);
884 }
885 }
886 return dim;
887}
888
889static int num4dim(ideal h, int n)
890{
891 int num=0;
892 for(int i=0; i<IDELEMS(h); i++)
893 {
894 if(pTotaldegree(h->m[i])==n)
895 {
896 num++;
897 }
898 }
899 return num;
900}
901
902/********************Procedures for T1(M method and N method) ***********/
903
904//h is ideal( monomial ideal) associated to simplicial complex
905//returns the all the monomials x^b (x^b must be able to divide
906//at least one monomial in Stanley-Reisner ring)
907//not so efficient
909{
911 poly e=pOne();
912 int i,j;
913 for(i=0;i<IDELEMS(ib);i++)
914 {
915 for(j=0;j<IDELEMS(nonf);j++)
916 {
917 if(p_DivisibleBy(ib->m[i],nonf->m[j],currRing))
918 {
919 idInsertPoly(bset, ib->m[i]);
920 break;
921 }
922 }
923 }
926 return bset;
927}
928
929//h is ideal(monomial ideal associated to simplicial complex
930//1.poly S is x^b
931//2.and deg(x^a)=deg(x^b)
932//3.x^a and x^a have disjoint supports
933//returns all the possible x^a according conditions 1. 2. 3.
934static ideal finda(ideal h,poly S,int ddeg)
935{
936 poly e=pOne();
938 int i,deg1=pTotaldegree(S);
939 int tdeg=deg1+ddeg;
940 if(tdeg!=0)
941 {
942 std::vector<int> v,bv=support1(S),in;
943 std::vector<std::vector<int> > hvs=supports(h);
945 for(i=0;i<IDELEMS(ia);i++)
946 {
947 v=support1(ia->m[i]);
949 if(vInvsl(v,hvs)&&in.size()==0)
950 {
951 idInsertPoly(aset, ia->m[i]);
952 }
953 }
955 }
956 else idInsertPoly(aset,e);
957 return(aset);
958}
959
960//returns true if support(p) union support(a) minus support(b) is face,
961//otherwise returns false
962//(the vector version of mabcondition)
963static bool mabconditionv(std::vector<std::vector<int> > hvs,std::vector<int> pv,std::vector<int> av,std::vector<int> bv)
964{
965 std::vector<int> uv=vecUnion(pv,av);
966 uv=vecMinus(uv,bv);
967 if(vInvsl(uv,hvs))
968 {
969 return(true);
970 }
971 return(false);
972}
973
974// returns the set of nonfaces p where mabconditionv(h, p, a, b) is true
975static std::vector<std::vector<int> > Mabv(ideal h,poly a,poly b)
976{
977 std::vector<int> av=support1(a), bv=support1(b), pv, vec;
979 std::vector<std::vector<int> > hvs=supports(h), h2v=supports(h2), vecs;
980 for(unsigned i=0;i<h2v.size();i++)
981 {
982 pv=h2v[i];
984 {
985 vecs.push_back(pv);
986 }
987 }
988 return vecs;
989}
990
991/***************************************************************************/
992//For solving the equations which has form of x_i-x_j.(equations got from T_1)
993/***************************************************************************/
994
995//subroutine for soleli1
996static std::vector<int> eli1(std::vector<int> eq1,std::vector<int> eq2)
997{
998 int i,j;
999 std::vector<int> eq;
1000 if(eq1[0]==eq2[0])
1001 {
1002 i=eq1[1];j=eq2[1];
1003 eq.push_back(i);
1004 eq.push_back(j);
1005 }
1006 else
1007 {
1008 eq=eq2;
1009 }
1010 return(eq);
1011}
1012
1013/*
1014//get triangular form(eqs.size()>0)
1015static std::vector<std::vector<int> > soleli1( std::vector<std::vector<int> > eqs)
1016{
1017 int i,j;
1018 std::vector<int> yaya;
1019 std::vector<std::vector<int> > pre=eqs, ppre, re;
1020 if(eqs.size()>0)
1021 {
1022 re.push_back(eqs[0]);
1023 pre.erase(pre.begin());
1024 }
1025 for(i=0;i<re.size(),pre.size()>0;i++)
1026 {
1027 yaya=eli1(re[i],pre[0]);
1028 re.push_back(yaya);
1029 for(j=1;j<pre.size();j++)
1030 {
1031 ppre.push_back(eli1(re[i],pre[j]));
1032 }
1033 pre=ppre;
1034 ppre.resize(0);
1035 }
1036 return re;
1037}*/
1038//make sure the first element is smaller that the second one
1039static std::vector<int> keeporder( std::vector<int> vec)
1040{
1041 std::vector<int> yaya;
1042 int n;
1043 if(vec[0]>vec[1])
1044 {
1045 n=vec[0];
1046 vec[0]=vec[1];
1047 vec[1]=n;
1048 }
1049 return vec;
1050}
1051
1052static std::vector<std::vector<int> > soleli1( std::vector<std::vector<int> > eqs)
1053{
1054 int i;
1055 std::vector<int> yaya;
1056 std::vector<std::vector<int> > pre=eqs, ppre, re;
1057 if(eqs.size()>0)
1058 {
1059 re.push_back(eqs[0]);
1060 pre.erase(pre.begin());
1061 }
1062 while(pre.size()>0)
1063 {
1064 yaya=keeporder(eli1(re[0],pre[0]));
1065 for(i=1;i<re.size();i++)
1066 {
1067 if(!vInvsl(yaya, re))
1068 {
1069 yaya=eli1(re[i],yaya);
1071 }
1072 }
1073 if(!vInvsl(yaya, re))
1074 {
1075 re.push_back(yaya);
1076 }
1077 pre.erase(pre.begin());
1078 }
1079 return re;
1080}
1081
1082// input is a set of equations who is of triangular form(every equations has a form of x_i-x_j)
1083// n is the number of variables
1084//get the free variables and the dimension
1085static std::vector<int> freevars(int n, std::vector<int> bset, std::vector<std::vector<int> > gset)
1086{
1087 int ql=gset.size(), bl=bset.size(), i;
1088 std::vector<int> mvar, fvar;
1089 for(i=0;i<bl;i++)
1090 {
1091 mvar.push_back(bset[i]);
1092 }
1093 for(i=0;i<ql;i++)
1094 {
1095 mvar.push_back(gset[i][0]);
1096 }
1097 for(i=1;i<=n;i++)
1098 {
1099 if(!IsinL(i,mvar))
1100 {
1101 fvar.push_back(i);
1102 }
1103 }
1104 return fvar;
1105}
1106
1107//return the set of free variables except the vnum one
1108static std::vector<int> fvarsvalue(int vnum, std::vector<int> fvars)
1109{
1110 int i;
1111 std::vector<int> fset=fvars;
1112 for(i=0;i<fset.size();i++)
1113 {
1114 if(fset[i]==vnum)
1115 {
1116 fset.erase(fset.begin()+i);
1117 break;
1118 }
1119 }
1120 return fset;
1121}
1122
1123//returns the simplified bset and gset
1124//enlarge bset, simplify gset
1125static std::vector<std::vector<int> > vAbsorb( std::vector<int> bset,std::vector<std::vector<int> > gset)
1126{
1127 std::vector<int> badset=bset;
1128 int i,j,m, bl=bset.size(), gl=gset.size();
1129 for(i=0;i<bl;i++)
1130 {
1131 m=badset[i];
1132 for(j=0;j<gl;j++)
1133 {
1134 if(gset[j][0]==m && !IsinL(gset[j][1],badset))
1135 {
1136 badset.push_back(gset[j][1]);
1137 gset.erase(gset.begin()+j);
1138 j--;
1139 gl--;
1140 bl++;
1141 }
1142 else if(!IsinL(gset[j][0],badset) && gset[j][1]==m)
1143 {
1144 badset.push_back(gset[j][0]);
1145 gset.erase(gset.begin()+j);
1146 j--;
1147 gl--;
1148 bl++;
1149 }
1150 else if(IsinL(gset[j][0],badset) && IsinL(gset[j][1],badset))
1151 {
1152 gset.erase(gset.begin()+j);
1153 j--;
1154 gl--;
1155 }
1156 else
1157 {
1158 ;
1159 }
1160 }
1161 }
1162 if(badset.size()==0) badset.push_back(0);
1163 gset.push_back(badset);
1164 return gset;
1165}
1166
1167//the labels of new variables are started with 1
1168//returns a vector of solution space according to index
1169static std::vector<int> vecbase1(int num, std::vector<int> oset)
1170{
1171 int i;
1172 std::vector<int> base;
1173 for(i=0;i<num;i++)
1174 {
1175 if(IsinL(i+1,oset))
1176 base.push_back(1);
1177 else
1178 base.push_back(0);
1179 }
1180 return base;
1181}
1182
1183//returns a vector which has length of n,
1184//and all the entries are 0.
1185static std::vector<int> make0(int n)
1186{
1187 int i;
1188 std::vector<int> vec;
1189 for(i=0;i<n;i++)
1190 {
1191 vec.push_back(0);
1192 }
1193 return vec;
1194}
1195
1196//returns a vector which has length of n,
1197//and all the entries are 1.
1198static std::vector<int> make1(int n)
1199{
1200 int i;
1201 std::vector<int> vec;
1202 for(i=0;i<n;i++)
1203 {
1204 vec.push_back(1);
1205 }
1206 return vec;
1207}
1208
1209//input gset must be the triangular form after zero absorbing according to the badset,
1210//bset must be the zero set after absorbing.
1211static std::vector<int> ofindbases1(int num, int vnum, std::vector<int> bset,std::vector<std::vector<int> > gset)
1212{
1213 std::vector<std::vector<int> > goodset;
1214 std::vector<int> fvars=freevars(num, bset, gset), oset, base;
1215 std::vector<int> zset=fvarsvalue(vnum, fvars);
1217 oset.push_back(vnum);
1219 oset=goodset[goodset.size()-1];
1220 goodset.erase(goodset.end());
1221 base= vecbase1(num, oset);
1222 return base;
1223}
1224
1225//input gset must be the triangular form after zero absorbing according to the badset
1226//bset must be the zero set after absorbing
1227static std::vector<std::vector<int> > ofindbases(int num, std::vector<int> bset,std::vector<std::vector<int> > gset)
1228{
1229 int i,m;
1230 std::vector<std::vector<int> > bases;
1231 std::vector<int> fvars=freevars(num, bset, gset), base1;
1232 if (fvars.size()==0)
1233 {
1234 base1=make0(num);
1235 bases.push_back(base1);
1236 }
1237 else
1238 {
1239 for(i=0;i<fvars.size();i++)
1240 {
1241 m=fvars[i];
1243 bases.push_back(base1);
1244 }
1245 }
1246 //PrintS("They are the bases for the solution space:\n");
1247 //listsprint(bases);
1248 return bases;
1249}
1250
1251//gset is a set of equations which have forms of x_i-x_j
1252//num is the number of varialbes also the length of the set which we need to consider
1253//output is trigular form of gset and badset where x_i=0
1254static std::vector<std::vector<int> > eli2(int num, std::vector<int> bset,std::vector<std::vector<int> > gset)
1255{
1256 std::vector<int> badset;
1257 std::vector<std::vector<int> > goodset, solve;
1258//PrintS("This is the input bset\n");listprint(bset);
1259//PrintS("This is the input gset\n");listsprint(gset);
1260 if(gset.size()!=0)//gset is not empty
1261 {
1262 //find all the variables which are zeroes
1263
1264 if(bset.size()!=0)//bset is not empty
1265 {
1266 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
1267 int m=goodset.size();
1268 badset=goodset[m-1];
1269 goodset.erase(goodset.end());
1270 }
1271 else //bset is empty
1272 {
1273 goodset=gset;//badset is empty
1274 }//goodset is already the set which doesn't contain zero variables
1275//PrintS("This is the badset after absorb \n");listprint(badset);
1276//PrintS("This is the goodset after absorb \n");listsprint(goodset);
1277 goodset=soleli1(goodset);//get the triangular form of goodset
1278//PrintS("This is the goodset after triangulization \n");listsprint(goodset);
1280 }
1281 else
1282 {
1284 }
1285//PrintS("This is the solution\n");listsprint(solve);
1286 return solve;
1287}
1288
1289/********************************************************************/
1290/************************links***********************************/
1291
1292//returns the links of face a in simplicial complex X
1293static std::vector<std::vector<int> > links(poly a, ideal h)
1294{
1295 int i;
1296 std::vector<std::vector<int> > lk,X=supports(h);
1297 std::vector<int> U,In,av=support1(a);
1298 for(i=0;i<X.size();i++)
1299 {
1300 U=vecUnion(av,X[i]);
1302 if( In.size()==0 && vInvsl(U,X))
1303 {
1304 //PrintS("The union of them is FACE and intersection is EMPTY!\n");
1305 lk.push_back(X[i]);
1306 }
1307 else
1308 {
1309 ;
1310 }
1311 }
1312 return lk;
1313}
1314
1315static int redefinedeg(poly p, int num)
1316{
1317 int deg=0, deg0;
1318 for(int i=1;i<=currRing->N;i++)
1319 {
1320 deg0=pGetExp(p, i);
1321 if(i>num)
1322 {
1323 deg= deg+2*deg0;
1324 }
1325 else
1326 {
1327 deg=deg+deg0;
1328 }
1329 }
1330 //Print("the new degree is: %d\n", deg);
1331 return (deg);
1332}
1333
1334// the degree of variables should be same
1336{
1337 poly p;
1338 int i,j,deg=0,deg0;
1339 ideal aset=idCopy(h),ia,h1=idsrRing(h);
1340//PrintS("idsrRing is:\n");id_print(h1);
1341 std::vector<int> as;
1342 std::vector<std::vector<int> > hvs=supports(h);
1343 for(i=0;i<IDELEMS(h1);i++)
1344 {
1345 deg0=pTotaldegree(h1->m[i]);
1346 if(deg < deg0)
1347 deg=deg0;
1348 }
1349 for(i=2;i<=deg;i++)
1350 {
1351 ia=id_MaxIdeal(i, currRing);
1352 for(j=0;j<IDELEMS(ia);j++)
1353 {
1354 p=pCopy(ia->m[j]);
1355 if(!IsInX(p,h))
1356 {
1357 as=support1(p);
1358 if(vInvsl(as,hvs))
1359 {
1361 }
1362 }
1363 }
1364 }
1366 return(aset);
1367}
1368
1369/*only for the exampels whose variables has degree more than 1*/
1370/*ideal p_a(ideal h)
1371{
1372 poly e=pOne(), p;
1373 int i,j,deg=0,deg0, ord=4;
1374 ideal aset=idCopy(h),ia,h1=idsrRing(h);
1375//PrintS("idsrRing is:\n");id_print(h1);
1376 std::vector<int> as;
1377 std::vector<std::vector<int> > hvs=supports(h);
1378 for(i=0;i<IDELEMS(h1);i++)
1379 {
1380 deg0=redefinedeg(h1->m[i],ord);
1381 if(deg < deg0)
1382 deg=deg0;
1383 }
1384 for(i=2;i<=deg;i++)
1385 {
1386 ia=id_MaxIdeal(i, currRing);
1387 for(j=0;j<IDELEMS(ia);j++)
1388 {
1389 p=pCopy(ia->m[j]);
1390 if(!IsInX(p,h))
1391 {
1392 as=support1(p);
1393 if(vInvsl(as,hvs))
1394 {
1395 idInsertPoly(aset, p);
1396 }
1397 }
1398 }
1399 }
1400 idSkipZeroes(aset);
1401 return(aset);
1402}*/
1403
1404static std::vector<int> vertset(std::vector<std::vector<int> > vecs)
1405{
1406 int i,j;
1407 std::vector<int> vert;
1408 std::vector<std::vector<int> > vvs;
1409 for(i=1;i<=currRing->N;i++)
1410 {
1411 for(j=0;j<vecs.size();j++)
1412 {
1413 if(IsinL(i, vecs[j]))
1414 {
1415 if(!IsinL(i , vert))
1416 {
1417 vert.push_back(i);
1418 }
1419 break;
1420 }
1421 }
1422 }
1423 return (vert);
1424}
1425
1426//smarter way
1427static ideal p_b(ideal h, poly a)
1428{
1429 std::vector<std::vector<int> > pbv,lk=links(a,h), res;
1430 std::vector<int> vert=vertset(lk), bv;
1432 int i, adg=pTotaldegree(a);
1433 poly e=pOne();
1434 ideal idd=idInit(1,1);
1435 for(i=0;i<res.size();i++)
1436 {
1437 if(res[i].size()==adg)
1438 pbv.push_back(res[i]);
1439 }
1440 if(pEqualPolys(a,e))
1441 {
1442 idInsertPoly(idd, e);
1444 return (idd);
1445 }
1446 idd=idMaken(pbv);
1447 return(idd);
1448}
1449
1450/*//dump way to get pb
1451// the degree of variables should be same
1452static ideal p_b(ideal h, poly a)
1453{
1454 std::vector<std::vector<int> > pbv,lk=links(a,h),res;
1455// PrintS("Its links are :\n");id_print(idMaken(lk));
1456 res=id_subsets(lk);
1457 //PrintS("res is :\n");listsprint(res);
1458 std::vector<int> bv;
1459 ideal bset=findb(h);
1460 int i,j,nu=res.size(),adg=pTotaldegree(a);
1461 poly e=pOne();ideal idd=idInit(1,1);
1462 for(i=0;i<res.size();i++)
1463 {
1464 if(res[i].size()==adg)
1465 pbv.push_back(res[i]);
1466 }
1467 if(pEqualPolys(a,e)){idInsertPoly(idd, e); idSkipZeroes(idd); return (idd);}
1468 for(i=0;i<nu;i++)
1469 {
1470 for(j=i+1;j<nu;j++)
1471 {
1472 if(res[i].size()!=0 && res[j].size()!=0)
1473 {
1474 bv = vecUnion(res[i], res[j]);
1475 if(IsInX(pMaken(bv),bset) && bv.size()==adg && !vInvsl(bv,pbv))
1476 {pbv.push_back(bv);}
1477 }
1478 }
1479 }
1480 idd=idMaken(pbv);
1481 //id_print(idd);
1482 return(idd);
1483}*/
1484
1485// also only for the examples whose variables have degree more than 1(ndegreeb and p_b)
1486/*int ndegreeb(std::vector<int> vec, int num)
1487{
1488 int deg, deg0=0;
1489 for(int i=0;i<vec.size();i++)
1490 {
1491 if(vec[i]>num)
1492 {
1493 deg0++;
1494 }
1495 }
1496 deg=vec.size()+deg0;
1497 return(deg);
1498}
1499
1500static ideal p_b(ideal h, poly a)
1501{
1502 std::vector<std::vector<int> > pbv,lk=links(a,h),res;
1503// PrintS("Its links are :\n");id_print(idMaken(lk));
1504 res=id_subsets(lk);
1505 //PrintS("res is :\n");listsprint(res);
1506 std::vector<int> bv;
1507 ideal bset=findb(h);
1508 int i,j,nu=res.size(),ord=4,adg=redefinedeg(a, ord);
1509 poly e=pOne();ideal idd=idInit(1,1);
1510 for(i=0;i<res.size();i++)
1511 {
1512 if(ndegreeb(res[i],ord)==adg)
1513 pbv.push_back(res[i]);
1514 }
1515 if(pEqualPolys(a,e)){idInsertPoly(idd, e); idSkipZeroes(idd); return (idd);}
1516 for(i=0;i<nu;i++)
1517 {
1518 for(j=i+1;j<nu;j++)
1519 {
1520 if(res[i].size()!=0 && res[j].size()!=0)
1521 {
1522 bv = vecUnion(res[i], res[j]);
1523 //PrintS("bv is :\n");listprint(bv);
1524 //Print("bv's degree is : %d\n", ndegreeb(bv,ord));
1525 if(IsInX(pMaken(bv),bset) && ndegreeb(bv,ord)==adg && !vInvsl(bv,pbv))
1526 {
1527 pbv.push_back(bv);
1528 }
1529 }
1530 }
1531 }
1532 idd=idMaken(pbv);
1533 //id_print(idd);
1534 return(idd);
1535}*/
1536
1537//input is a squarefree monomial p
1538//output is all the squarefree monomials which could divid p(including p itself?)
1539static ideal psubset(poly p)
1540{
1541 int i,j,max=pTotaldegree(p);
1542 ideal h1,mons, id_re=idInit(1,1);
1543 for(i=1;i<max;i++)
1544 {
1546 h1=sfreemon(mons,i);
1547 for(j=0;j<IDELEMS(h1);j++)
1548 {
1549 if(p_DivisibleBy(h1->m[j],p,currRing))
1550 idInsertPoly(id_re, h1->m[j]);
1551 }
1552 }
1554 //PrintS("This is the facset\n");
1555 //id_print(id_re);
1556 return id_re;
1557}
1558
1559//inserts a new vector which has two elements a and b into vector gset (which is a vector of vectors)
1560//(especially for gradedpiece1 and gradedpiece1n)
1561static std::vector<std::vector<int> > listsinsertlist(std::vector<std::vector<int> > gset, int a, int b)
1562{
1563 std::vector<int> eq;
1564 eq.push_back(a);
1565 eq.push_back(b);
1566 gset.push_back(eq);
1567 return gset;
1568}
1569
1570static std::vector<int> makeequation(int i,int j, int t)
1571{
1572 std::vector<int> equation;
1573 equation.push_back(i);
1574 equation.push_back(j);
1575 equation.push_back(t);
1576 //listprint(equation);
1577 return equation;
1578}
1579
1580/****************************************************************/
1581//only for solving the equations obtained from T^2
1582//input should be a vector which has only 3 entries
1583static poly pMake3(std::vector<int> vbase)
1584{
1585 int co=1;
1586 poly p,q=0;
1587 for(int i=0;i<3;i++)
1588 {
1589 if(vbase[i]!=0)
1590 {
1591 if(i==1) co=-1;
1592 p = pOne();pSetExp(p, vbase[i], 1);pSetm(p);pSetCoeff(p, nInit(co));
1593 }
1594 else p=0;
1595 q = pAdd(q, p);
1596 co=1;
1597 }
1598 return q;
1599}
1600
1601static ideal idMake3(std::vector<std::vector<int> > vecs)
1602{
1603 ideal id_re=idInit(1,1);
1604 poly p;
1605 int i,lv=vecs.size();
1606 for(i=0;i<lv;i++)
1607 {
1608 p=pMake3(vecs[i]);
1610 }
1612 return id_re;
1613}
1614
1615/****************************************************************/
1616
1617//change the current ring to a new ring which is in num new variables
1618static void equmab(int num)
1619{
1620 int i;
1621 //Print("There are %d new variables for equations solving.\n",num);
1622 ring r=currRing;
1623 char** tt;
1624 coeffs cf=nCopyCoeff(r->cf);
1625 tt=(char**)omAlloc(num*sizeof(char *));
1626 for(i=0; i <num; i++)
1627 {
1628 tt[i] = (char*)omalloc(10); //if required enlarge it later
1629 snprintf (tt[i],10, "t(%d)", i+1);
1630 }
1633 IDRING(h)=rCopy(R);
1634 rSetHdl(h);
1635}
1636
1637//returns the trivial case of T^1
1638//b must only contain one variable
1639static std::vector<int> subspace1(std::vector<std::vector<int> > mv, std::vector<int> bv)
1640{
1641 int i, num=mv.size();
1642 std::vector<int> base;
1643 for(i=0;i<num;i++)
1644 {
1645 if(IsinL(bv[0],mv[i]))
1646 base.push_back(1);
1647 else
1648 base.push_back(0);
1649 }
1650 return base;
1651}
1652
1653/***************************only for T^2*************************************/
1654//vbase only has two elements which records the position of the monomials in mv
1655
1656static std::vector<poly> pMakei(std::vector<std::vector<int> > mv,std::vector<int> vbase)
1657{
1658 poly p;
1659 std::vector<poly> h1;
1660 int n=vbase.size();
1661 for(int i=0;i<n;i++)
1662 {
1663 p=pMaken(mv[vbase[i]]);
1664 h1.push_back(p);
1665 }
1666 return h1;
1667}
1668
1669// returns a ideal according to a set of supports
1670static std::vector<std::vector<poly> > idMakei(std::vector<std::vector<int> > mv,std::vector<std::vector<int> > vecs)
1671{
1672 int i,lv=vecs.size();
1673 std::vector<std::vector<poly> > re;
1674 std::vector<poly> h;
1675 for(i=0;i<lv;i++)
1676 {
1677 h=pMakei(mv,vecs[i]);
1678 re.push_back(h);
1679 }
1680 //PrintS("This is the metrix M:\n");
1681 //listsprint(vecs);
1682 //PrintS("the ideal according to metrix M is:\n");
1683 return re;
1684}
1685
1686/****************************************************************/
1687
1688//return the graded pieces of cohomology T^1 according to a,b
1689//original method (only for debugging)
1690static void gradedpiece1(ideal h,poly a,poly b)
1691{
1692 int i,j,m;
1693 ideal sub=psubset(b);
1694 std::vector<int> av=support1(a), bv=support1(b), bad, vv;
1695 std::vector<std::vector<int> > hvs=supports(h), sbv=supports(sub), mv=Mabv(h,a,b),good;
1696 m=mv.size();
1697 ring r=currRing;
1698 if( m > 0 )
1699 {
1700 for(i=0;i<m;i++)
1701 {
1702 if(!vsubset(bv,mv[i]))
1703 {
1704 bad.push_back(i+1);
1705 }
1706 }
1707 for(i=0;i<m;i++)
1708 {
1709 for(j=i+1;j<m;j++)
1710 {
1711 vv=vecUnion(mv[i],mv[j]);
1712 if(mabconditionv(hvs,vv,av,bv))
1713 {
1715 }
1716 else
1717 {
1718 //PrintS("They are not in Mabt!\n");
1719 ;
1720 }
1721 }
1722 }
1723 std::vector<std::vector<int> > solve=eli2(m,bad,good);
1724 if(bv.size()!=1)
1725 {
1726 //PrintS("This is the solution of coefficients:\n");
1728 }
1729 else
1730 {
1731 std::vector<int> su=subspace1(mv,bv);
1732 //PrintS("This is the solution of subspace:\n");
1733 //listprint(su);
1734 std::vector<std::vector<int> > suu;
1735 suu.push_back(su);
1736 equmab(solve[0].size());
1737 std::vector<std::vector<int> > solves=vecqring(solve,suu);
1738 //PrintS("This is the solution of coefficients:\n");
1740 rChangeCurrRing(r);
1741 }
1742 }
1743 else
1744 {
1745 PrintS("No element considered!\n");
1746 }
1747}
1748
1749//Returns true if b can divide p*q
1750static bool condition1for2(std::vector<int > pv,std::vector<int > qv,std::vector<int > bv)
1751{
1752 std::vector<int > vec=vecUnion(pv,qv);
1753 if(vsubset(bv,vec))
1754 {
1755 //PrintS("condition1for2 yes\n");
1756 return true;
1757 }
1758 //PrintS("condition1for2 no\n");
1759 return false;
1760}
1761
1762//Returns true if support(p) union support(q) union support(s) union support(a) minus support(b) is face
1763static 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)
1764{
1765 std::vector<int> vec=vecUnion(pv,qv);
1766 vec=vecUnion(vec,sv);
1768 {
1769 //PrintS("condition2for2 yes\n");
1770 return (true);
1771 }
1772 //PrintS("condition2for2 no\n");
1773 return (false);
1774}
1775
1776static bool condition3for2(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> qv, std::vector<int> av, std::vector<int> bv)
1777{
1778 std::vector<int> v1,v2,v3;
1779 v1=vecIntersection(pv,qv);//intersection
1780 v2=vecUnion(pv,qv);
1781 v2=vecUnion(v2,av);
1782 v2=vecMinus(v2,bv);
1783 v3=vecUnion(v1,v2);
1784 if(vInvsl(v3,hvs))
1785 {
1786 //PrintS("condition3for2 yes\n");
1787 return(true);
1788 }
1789 //PrintS("condition3for2 no\n");
1790 return(false);
1791}
1792
1793/****************solve the equations got from T^2*********************/
1794
1796{
1797 //ring r=currRing;
1798 //assume (LIB "presolve.lib");
1799 sleftv a;a.Init();
1800 a.rtyp=IDEAL_CMD;a.data=(void*)h;
1801 idhdl solve=ggetid("elimlinearpart");
1802 if(solve==NULL)
1803 {
1804 WerrorS("presolve.lib are not loaded!");
1805 return NULL;
1806 }
1808 //PrintS("no errors here\n");
1809 if(sl)
1810 {
1811 WerrorS("error in solve!");
1812 }
1814 ideal re=(ideal)L->m[4].CopyD();
1815 //iiRETURNEXPR.CleanUp();
1817 //PrintS("no errors here\n");
1818 //idSkipZeroes(re);
1819 //id_print(re);
1820 return re;
1821}
1822
1823static std::vector<int> numfree(ideal h)
1824{
1825 int i,j;
1826 std::vector<int> fvar;
1827 for(j=1;j<=currRing->N;j++)
1828 {
1829 for(i=0;i<IDELEMS(h);i++)
1830 {
1831 if(vInp(j,h->m[i]))
1832 {
1833 fvar.push_back(j);
1834 break;
1835 }
1836 }
1837 }
1838 //Print("There are %d free variables in total\n",num);
1839 return fvar;
1840}
1841
1842static std::vector<std::vector<int> > canonicalbase(int n)
1843{
1844 std::vector<std::vector<int> > vecs;
1845 std::vector<int> vec;
1846 int i,j;
1847 for(i=0;i<n;i++)
1848 {
1849 for(j=0;j<n;j++)
1850 {
1851 if(i==j)
1852 vec.push_back(1);
1853 else
1854 vec.push_back(0);
1855 }
1856 vecs.push_back(vec);
1857 vec.clear();
1858 }
1859 return vecs;
1860}
1861
1862static std::vector<std::vector<int> > getvector(ideal h,int n)
1863{
1864 std::vector<int> vec;
1865 std::vector<std::vector<int> > vecs;
1866 ideal h2=idCopy(h);
1867 if(!idIs0(h))
1868 {
1870 poly q,e=pOne();
1871 int lg=IDELEMS(h1),n,i,j,t;
1872 std::vector<int> fvar=numfree(h1);
1873 n=fvar.size();
1874 if(n==0)
1875 {
1876 vec=make0(IDELEMS(h1));vecs.push_back(vec);//listsprint(vecs);
1877 }
1878 else
1879 {
1880 for(t=0;t<n;t++)
1881 {
1882 vec.clear();
1883 for(i=0;i<lg;i++)
1884 {
1885 q=pCopy(h1->m[i]);
1886 //pWrite(q);
1887 if(q==0)
1888 {
1889 vec.push_back(0);
1890 }
1891 else
1892 {
1893 q=p_Subst(q, fvar[t], e,currRing);
1894 //Print("the %dth variable was substituted by 1:\n",fvar[t]);
1895 //pWrite(q);
1896 for(j=0;j<n;j++)
1897 {
1898 //Print("the %dth variable was substituted by 0:\n",fvar[j]);
1899 q=p_Subst(q, fvar[j],0,currRing);
1900 //pWrite(q);
1901 }
1902 if(q==0)
1903 {
1904 vec.push_back(0);
1905 }
1906 else
1907 {
1908 vec.push_back(n_Int(pGetCoeff(q),currRing->cf));
1909 }
1910 }
1911 }
1912 //listprint(vec);
1913 vecs.push_back(vec);
1914 }
1915 }
1916 }
1917 else
1918 {vecs=canonicalbase(n);}
1919 //listsprint(vecs);
1920 return vecs;
1921}
1922
1923/**************************************************************************/
1924
1925//subspace of T2(find all the possible values of alpha)
1926static std::vector<int> findalpha(std::vector<std::vector<int> > mv, std::vector<int> bv)
1927{
1928 std::vector<int> alset;
1929 for(unsigned i=0;i<mv.size();i++)
1930 {
1931 if(vsubset(bv,mv[i]))
1932 {
1933 alset.push_back(i);
1934 }
1935 }
1936 //Print("This is the alpha set, and the subspace is dim-%ld\n",alset.size());
1937 //listprint(alset);
1938 return alset;
1939}
1940
1941static std::vector<int> subspacet1(int num, std::vector<std::vector<int> > ntvs)
1942{
1943 int i, j, t, n=ntvs.size();
1944 std::vector<int> subase;
1945 for(t=0;t<n;t++)
1946 {
1947 i=ntvs[t][0];
1948 j=ntvs[t][1];
1949 if(i==(num))
1950 {
1951 subase.push_back(1);
1952 }
1953 else if(j==num)
1954 {
1955 subase.push_back(-1);
1956 }
1957 else
1958 {
1959 subase.push_back(0);
1960 }
1961 }
1962 //Print("This is the basis w.r.t. %dth polynomial in alpha set\n",num);
1963 //listprint(subase);
1964 return subase;
1965}
1966
1967//subspace for T^2(mab method)
1968static std::vector<std::vector<int> > subspacet(std::vector<std::vector<int> > mv, std::vector<int> bv,std::vector<std::vector<int> > ntvs)
1969{
1970 std::vector<int> alset=findalpha(mv,bv), subase;
1971 std::vector<std::vector<int> > subases;
1972 for(unsigned i=0;i<alset.size();i++)
1973 {
1975 subases.push_back(subase);
1976 }
1977 //PrintS("These are the bases for the subspace:\n");
1978 //listsprint(subases);
1979 return subases;
1980}
1981
1982static 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)
1983{
1984 std::vector<int> v1,var;
1985 std::vector<std::vector<int> > vars;
1986 for(unsigned i=0;i<Mv.size();i++)
1987 {
1988 for(unsigned j=i+1;j<Mv.size();j++)
1989 {
1990 var.clear();
1991 v1=vecUnion(Mv[i],Mv[j]);
1992 if(mabconditionv(hvs, v1, av, bv))
1993 {
1994 var.push_back(i);
1995 var.push_back(j);
1996 vars.push_back(var);
1997 }
1998 }
1999 }
2000 return vars;
2001}
2002
2003//fix the problem of the number of the new variables
2004//original method for T^2(only for debugging)
2005static void gradedpiece2(ideal h,poly a,poly b)
2006{
2007 int t0,t1,t2,i,j,t,m;
2008 ideal sub=psubset(b);
2009 ring r=rCopy(currRing);
2010 std::vector<std::vector<int> > hvs=supports(h), mv=Mabv(h,a,b), mts, vecs,vars;
2011 std::vector<int> av=support1(a), bv=support1(b), vec,var;
2012 mts=mabtv(hvs,mv,av,bv);
2013 PrintS("The homomorphism should map onto:\n");
2015 m=mv.size();
2016 if(m > 0)
2017 {
2018 vars=mabtv(hvs,mv,av,bv);
2019 int vn=vars.size();
2020 for(t0=0;t0<vars.size();t0++)
2021 {
2022 i=vars[t0][0];
2023 j=vars[t0][1];
2024 if(!condition1for2(mv[i],mv[j],bv))//condition 1
2025 {
2026 //PrintS("And they satisfy the condition 1.\n");
2027 vec=makeequation(t0+1,0,0);
2028 //PrintS("So the equation:\n");
2029 //pWrite(p);
2030 //PrintS("holds.\n");
2031 vecs.push_back(vec);
2032 vec.clear();
2033 }
2034 if(condition3for2(hvs,mv[i],mv[j],av,bv))//condition 3
2035 {
2036 //PrintS("And they satisfy the condition 3.\n");
2037 vec=makeequation(t0+1,0,0);
2038 //PrintS("So the equation: \n");
2039 //pWrite(p);
2040 //PrintS("holds.\n");
2041 vecs.push_back(vec);
2042 vec.clear();
2043 }
2044 for(t1=t0+1;t1<vars.size();t1++)
2045 {
2046 for(t2=t1+1;t2<vars.size();t2++)
2047 {
2048 if(vars[t0][0]==vars[t1][0]&&vars[t1][1]==vars[t2][1]&&vars[t0][1]==vars[t2][0])
2049 {
2050 i=vars[t0][0];
2051 j=vars[t0][1];
2052 t=vars[t1][1];
2053 if(condition2for2(hvs,mv[i],mv[j],mv[t],av,bv))//condition 2
2054 {
2055 vec=makeequation(t0+1,t1+1,t2+1);
2056 vecs.push_back(vec);
2057 vec.clear();
2058 }
2059 }
2060 }
2061 }
2062 }
2063 //PrintS("this is EQUATIONS:\n");
2064 //listsprint(vecs);
2065 equmab(vn);
2067 //id_print(id_re);
2068 std::vector<std::vector<int> > re=getvector(id_re,vn);
2069 PrintS("this is the solution for ideal :\n");
2070 listsprint(re);
2071 rChangeCurrRing(r);
2072 std::vector<std::vector<int> > sub=subspacet(mv, bv,vars);
2073 PrintS("this is the solution for subspace:\n");
2074 listsprint(sub);
2075 equmab(vn);
2076 std::vector<std::vector<int> > solve=vecqring(re, sub);
2077 PrintS("This is the solution of coefficients:\n");
2079 rChangeCurrRing(r);
2080 }
2081 else
2082 {
2083 PrintS("No element considered!");
2084 }
2085}
2086
2087/**********************************************************************/
2088//For the method of N_{a-b}
2089
2090//returns true if pv(support of monomial) satisfies pv union av minus bv is in hvs
2091static bool nabconditionv(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> av, std::vector<int> bv)
2092{
2093 std::vector<int> vec1=vecIntersection(pv,bv), vec2=vecUnion(pv,bv);
2094 int s1=vec1.size();
2095 if(!vInvsl(vec2,hvs) && s1==0 && vsubset(av,pv))
2096 {
2097 //PrintS("nab condition satisfied\n");
2098 return(true);
2099 }
2100 //PrintS("nab condition not satisfied\n");
2101 return(false);
2102}
2103
2104//returns N_{a-b}
2105static std::vector<std::vector<int> > Nabv(std::vector<std::vector<int> > hvs, std::vector<int> av, std::vector<int> bv)
2106{
2107 std::vector<std::vector<int> > vecs;
2108 int num=hvs.size();
2109 for(int i=0;i<num;i++)
2110 {
2111 if(nabconditionv(hvs,hvs[i],av,bv))
2112 {
2113 //PrintS("satisfy:\n");
2114 vecs.push_back(hvs[i]);
2115 }
2116 }
2117 return vecs;
2118}
2119
2120//returns true if pv union qv union av minus bv is in hvs
2121//hvs is simplicial complex
2122static bool nabtconditionv(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> qv)
2123{
2124 std::vector<int> v1;
2125 v1=vecUnion(pv,qv);
2126 if(vInvsl(v1,hvs))
2127 {
2128 return (true);
2129 }
2130 return (false);
2131}
2132
2133//returns N_{a-b}^(2)
2134static 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)
2135{
2136 std::vector<int> v1,var;
2137 std::vector<std::vector<int> > vars;
2138 for(unsigned i=0;i<Nv.size();i++)
2139 {
2140 for(unsigned j=i+1;j<Nv.size();j++)
2141 {
2142 var.clear();
2143 if(nabtconditionv(hvs, Nv[i], Nv[j]))
2144 {
2145 var.push_back(i);
2146 var.push_back(j);
2147 vars.push_back(var);
2148 }
2149 }
2150 }
2151 return vars;
2152}
2153
2154//p must be the monomial which is a face
2155// ideal sub=psubset(b); bvs=supports(sub);
2156static bool tNab(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<std::vector<int> > bvs)
2157{
2158 std::vector<int> sv;
2159 if(bvs.size()<=1) return false;
2160 for(unsigned i=0;i<bvs.size();i++)
2161 {
2162 sv=vecUnion(pv,bvs[i]);
2163 if(!vInvsl(sv,hvs))
2164 {
2165 return true;
2166 }
2167 }
2168 return false;
2169}
2170
2171static std::vector<int> tnab(std::vector<std::vector<int> > hvs,std::vector<std::vector<int> > nvs,std::vector<std::vector<int> > bvs)
2172{
2173 std::vector<int> pv, vec;
2174 for(unsigned j=0;j<nvs.size();j++)
2175 {
2176 pv=nvs[j];
2177 if(tNab(hvs, pv, bvs))
2178 {
2179 vec.push_back(j);
2180 }
2181 }
2182 return vec;
2183}
2184
2185//the image phi(pv)=pv union av minus bv
2186static 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//mvs and nvs are the supports of ideal Mab and Nab
2194//vecs is the solution of nab
2195static 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)
2196{
2197 int j;
2198 std::vector<int> pv, base;
2199 std::vector<std::vector<int> > bases;
2200 for(unsigned t=0;t<vecs.size();t++)
2201 {
2202 for(unsigned i=0;i<mvs.size();i++)
2203 {
2204 pv=phimage(mvs[i],av,bv);
2205 for( j=0;j<nvs.size();j++)
2206 {
2207 if(vEvl(pv,nvs[j]))
2208 {
2209 base.push_back(vecs[t][j]);
2210 break;
2211 }
2212 }
2213 if(j==nvs.size())
2214 {
2215 base.push_back(0);
2216 }
2217 }
2218 if(base.size()!=mvs.size())
2219 {
2220 //WerrorS("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
2221 WerrorS("Errors in Equations solving (Values Finding)!");
2222 usleep(1000000);
2223 assert(false);
2224
2225 }
2226 bases.push_back(base);
2227 base.clear();
2228 }
2229 return bases;
2230}
2231
2232static intvec *Tmat(std::vector<std::vector<int> > vecs)
2233{
2234 //std::vector<std::vector<int> > solve=gradedpiece1n(h,a,b);
2235 //Print("the size of solve is: %ld\n",solve.size());
2236 //vtm(solve);
2237 intvec *m;
2238 int i,j, a=vecs.size();
2239 if(a==0)
2240 {
2241 m=new intvec(1,1,10);
2242 }
2243 else
2244 {
2245 int b=vecs[0].size();
2246 m=new intvec(a,b,0);
2247 for(i=1;i<=a;i++)
2248 {
2249 for(j=1;j<=b;j++)
2250 {
2251 IMATELEM(*m,i,j)=vecs[i-1][j-1];
2252 }
2253 }
2254 }
2255 return (m);
2256}
2257
2258//returns the set of position number of minimal gens in M
2259static std::vector<int> gensindex(ideal M, ideal ids)
2260{
2261 int i;
2262 std::vector<int> vec,index;
2263 if(!idIs0(M))
2264 {
2265 std::vector<std::vector<int> > vecs=supports(ids);
2266 for(i=0;i<IDELEMS(M);i++)
2267 {
2268 vec=support1(M->m[i]);
2269 if(vInvsl(vec,vecs))
2270 index.push_back(i);
2271 }
2272 }
2273 return (index);
2274}
2275
2276static ideal mingens(ideal h, poly a, poly b)
2277{
2278 int i;
2279 std::vector<std::vector<int> > mv=Mabv(h,a,b);
2280 ideal M=idMaken(mv), hi=idInit(1,1);
2281 std::vector<int> index = gensindex(M, idsrRing(h));
2282 for(i=0;i<index.size();i++)
2283 {
2284 idInsertPoly(hi,M->m[index[i]]);
2285 }
2287 return (hi);
2288}
2289
2290static std::vector<std::vector<int> > minisolve(std::vector<std::vector<int> > solve, std::vector<int> index)
2291{
2292 int i,j;
2293 std::vector<int> vec,solm;
2294 std::vector<std::vector<int> > solsm;
2295 for(i=0;i<solve.size();i++)
2296 {
2297 vec=solve[i];
2298 for(j=0;j<vec.size();j++)
2299 {
2300 if(IsinL(j,index))
2301 solm.push_back(vec[j]);
2302 }
2303 solsm.push_back(solm);
2304 solm.clear();
2305 }
2306 return (solsm);
2307}
2308
2309//T_1 graded piece(N method)
2310//frame of the most efficient version
2311//regardless of links
2312static intvec * gradedpiece1n(ideal h,poly a,poly b)
2313{
2314 int i,j,co,n;
2315 std::vector<std::vector<int> > hvs=supports(h),mv=Mabv(h,a,b),sbv,nv,good,solve;
2316 std::vector<int> av=support1(a), bv=support1(b), bad, tnv, index;
2317 ideal sub=psubset(b),M;
2318 sbv=supports(sub);
2319 nv=Nabv(hvs,av,bv);
2320 M=idMaken(mv);
2321 index = gensindex(M, idsrRing(h));
2322 n=nv.size();
2323 ring r=currRing;
2324 if(n > 0)
2325 {
2326 tnv=tnab(hvs,nv,sbv);
2327 for(i=0;i<tnv.size();i++)
2328 {
2329 co=tnv[i];
2330 bad.push_back(co+1);
2331 }
2332 for(i=0;i<n;i++)
2333 {
2334 for(j=i+1;j<n;j++)
2335 {
2336 if(nabtconditionv(hvs,nv[i],nv[j]))
2337 {
2339 }
2340 else
2341 {
2342 ;
2343 }
2344 }
2345 }
2346 solve=eli2(n,bad,good);
2347 if(bv.size()!=1)
2348 {;
2349 //PrintS("This is the solution of coefficients:\n");
2350 //listsprint(solve);
2351 }
2352 else
2353 {
2354 std::vector<int> su=make1(n);
2355 std::vector<std::vector<int> > suu;
2356 suu.push_back(su);
2357 equmab(n);
2359 //PrintS("This is the solution of coefficients:\n");
2360 //listsprint(solve);
2361 rChangeCurrRing(r);
2362 }
2364 }
2365 else
2366 {
2367 //PrintS("No element considered here!\n");
2368 solve.clear();
2369 }
2370 //PrintS("This is the solution of final coefficients:\n");
2371 //listsprint(solve);
2373 intvec *sl=Tmat(solve);
2374 //sl->show(0,0);
2375 return sl;
2376}
2377
2378//for debugging
2379static void T1(ideal h)
2380{
2381 ideal bi=findb(h),ai;
2382 int mm=0;
2383 id_print(bi);
2384 poly a,b;
2385 std::vector<std::vector<int> > solve;
2386 for(int i=0;i<IDELEMS(bi);i++)
2387 {
2388 //PrintS("This is aset according to:");
2389 b=pCopy(bi->m[i]);
2390 pWrite(b);
2391 ai=finda(h,b,0);
2392 if(!idIs0(ai))
2393 {
2394 id_print(ai);
2395 for(int j=0;j<IDELEMS(ai);j++)
2396 {
2397 //PrintS("This is a:");
2398 a=pCopy(ai->m[j]);
2399 //pWrite(a);
2400 intvec * solve=gradedpiece1n(h, a, b);
2401 if (IMATELEM(*solve,1,1)!=10)
2402 mm++;
2403 }
2404 }
2405 }
2406 Print("Finished %d!\n",mm);
2407}
2408
2409static bool condition2for2nv(std::vector<std::vector<int> > hvs, std::vector<int> pv, std::vector<int> qv, std::vector<int> fv)
2410{
2411 std::vector<int> vec=vecUnion(pv,qv);
2412 vec=vecUnion(vec,fv);
2413 if(vInvsl(vec,hvs))
2414 {
2415 //PrintS("condition2for2 yes\n");
2416 return (true);
2417 }
2418 //PrintS("condition2for2 no\n");
2419 return (false);
2420}
2421
2422//for subspace of T2(find all the possible values of alpha)
2423static std::vector<int> findalphan(std::vector<std::vector<int> > N, std::vector<int> tN)
2424{
2425 int i;std::vector<int> alset,vec;
2426 for(i=0;i<N.size();i++)
2427 {
2428 // vec=N[i];
2429 if(!IsinL(i,tN))
2430 {
2431 alset.push_back(i);
2432 }
2433 }
2434 //listprint(alset);
2435 return alset;
2436}
2437
2438//subspace of T^2 (nab method)
2439static std::vector<std::vector<int> > subspacetn(std::vector<std::vector<int> > N, std::vector<int> tN, std::vector<std::vector<int> > ntvs)
2440{
2441 int i;
2442 std::vector<int> alset=findalphan(N,tN), subase;
2443 std::vector<std::vector<int> > subases;
2444 for(i=0;i<alset.size();i++)
2445 {
2447 subases.push_back(subase);
2448 }
2449 //PrintS("These are the bases for the subspace:\n");
2450 //listsprint(subases);
2451 return subases;
2452}
2453
2454//mts Mabt
2455//nts Nabt
2456//mvs Mab
2457//nvs Nab
2458static 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)
2459{
2460 int row,col,j;
2461 std::vector<int> pv,qv, base;
2462 std::vector<std::vector<int> > bases;
2463 //PrintS("This is the nabt:\n");
2464 //listsprint(nts);
2465 //PrintS("nabt ends:\n");
2466 //PrintS("This is the mabt:\n");
2467 //listsprint(mts);
2468 //PrintS("mabt ends:\n");
2469 for(unsigned t=0;t<vecs.size();t++)
2470 {
2471 for(unsigned i=0;i<mts.size();i++)
2472 {
2473 row=mts[i][0];
2474 col=mts[i][1];
2475 pv=phimage(mvs[row],av,bv);
2476 qv=phimage(mvs[col],av,bv);
2477 if(vEvl(pv,qv))
2478 base.push_back(0);
2479 else
2480 {
2481 for(j=0;j<nts.size();j++)
2482 {
2483 row=nts[j][0];
2484 col=nts[j][1];
2485 if(vEvl(pv,nvs[row])&&vEvl(qv,nvs[col]))
2486 {
2487 base.push_back(vecs[t][j]);break;
2488 }
2489 else if(vEvl(pv,nvs[col])&&vEvl(qv,nvs[row]))
2490 {
2491 base.push_back(-vecs[t][j]);break;
2492 }
2493 }
2494 if(j==nts.size()) {base.push_back(0);}
2495 }
2496 }
2497 if(base.size()!=mts.size())
2498 {
2499 WerrorS("Errors in Values Finding(value2)!");
2500 //WerrorS("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
2501 usleep(1000000);
2502 assert(false);
2503 }
2504 bases.push_back(base);
2505 base.clear();
2506 }
2507 return bases;
2508}
2509
2510static ideal genst(ideal h, poly a, poly b)
2511{
2512 std::vector<std::vector<int> > hvs=supports(h),mv,mts;
2513 std::vector<int> av=support1(a), bv=support1(b);
2514 mv=Mabv(h,a,b);
2515 mts=mabtv(hvs,mv,av,bv);
2516 std::vector<std::vector<poly> > pvs=idMakei(mv,mts);
2517 ideal gens=idInit(1,1);
2518 for(unsigned i=0;i<pvs.size();i++)
2519 {
2520 idInsertPoly(gens,pvs[i][0]);
2521 idInsertPoly(gens,pvs[i][1]);
2522 }
2524 return (gens);
2525}
2526
2527static intvec * gradedpiece2n(ideal h,poly a,poly b)
2528{
2529 int i,j,t,n;
2530 std::vector<std::vector<int> > hvs=supports(h),nv,mv,mts,sbv,vecs,vars,ntvs,solve;
2531 std::vector<int> av=support1(a), bv=support1(b),tnv,vec,var;
2532 ideal sub=psubset(b);
2533 sbv=supports(sub);
2534 nv=Nabv(hvs,av,bv);
2535 n=nv.size();
2536 tnv=tnab(hvs,nv,sbv);
2537 ring r=currRing;
2538 mv=Mabv(h,a,b);
2539 mts=mabtv(hvs,mv,av,bv);
2540 //PrintS("The relations are:\n");
2541 //listsprint(mts);
2542 //PrintS("The homomorphism should map onto:\n");
2543 //lpsprint(idMakei(mv,mts));
2544 if(n>0)
2545 {
2546 ntvs=nabtv( hvs, nv, av, bv);
2547 //PrintS("The current homomorphism map onto###:\n");
2548 //lpsprint(idMakei(nv,ntvs));
2549 int l=ntvs.size();
2550 for(int t0=0;t0<l;t0++)
2551 {
2552 i=ntvs[t0][0];
2553 j=ntvs[t0][1];
2554 if(tNab(hvs,nv[i],sbv)&&tNab(hvs,nv[j],sbv))//condition 1
2555 {
2556 vec=makeequation(t0+1,0,0);
2557 vecs.push_back(vec);
2558 vec.clear();
2559 }
2560 for(int t1=t0+1;t1<ntvs.size();t1++)
2561 {
2562 for(int t2=t1+1;t2<ntvs.size();t2++)
2563 {
2564 if(ntvs[t0][0]==ntvs[t1][0]&&ntvs[t1][1]==ntvs[t2][1]&&ntvs[t0][1]==ntvs[t2][0])
2565 {
2566 i=ntvs[t0][0];
2567 j=ntvs[t0][1];
2568 t=ntvs[t1][1];
2569 if(condition2for2nv(hvs,nv[i],nv[j],nv[t]))
2570 {
2571 vec=makeequation(t0+1,t1+1,t2+1);
2572 vecs.push_back(vec);
2573 vec.clear();
2574 }
2575 }
2576 }
2577 }
2578 }
2579 //PrintS("this is EQUATIONS:\n");
2580 //listsprint(vecs);
2581 if(n==1) l=1;
2582 equmab(l);
2584 //id_print(id_re);
2585 std::vector<std::vector<int> > re=getvector(id_re,l);
2586 //PrintS("this is the solution for ideal :\n");
2587 //listsprint(re);
2588 rChangeCurrRing(r);
2589 std::vector<std::vector<int> > sub=subspacetn(nv, tnv,ntvs);
2590 //PrintS("this is the solution for subspace:\n");
2591 //listsprint(sub);
2592 equmab(l);
2593 solve=vecqring(re, sub);
2594 //PrintS("This is the solution of coefficients:\n");
2595 //listsprint(solve);
2596 rChangeCurrRing(r);
2598 }
2599 else
2600 solve.clear();
2601 intvec *sl=Tmat(solve);
2602 return sl;
2603}
2604
2605//for debugging
2606static void T2(ideal h)
2607{
2608 ideal bi=findb(h),ai;
2609 id_print(bi);
2610 poly a,b;
2611 int mm=0,gp=0;
2612 std::vector<int> bv,av;
2613 std::vector<std::vector<int> > solve;
2614 for(int i=0;i<IDELEMS(bi);i++)
2615 {
2616 b=pCopy(bi->m[i]);
2617 //bv=support1(b);
2618 //PrintS("This is aset according to:");
2619 pWrite(b);
2620//if(bv.size()==2)
2621 //{
2622 ai=finda(h,b,0);
2623 if(!idIs0(ai))
2624 {
2625 PrintS("This is a set according to current b:\n");
2626 id_print(ai);
2627 for(int j=0;j<IDELEMS(ai);j++)
2628 {
2629 PrintS("This is a:");
2630 a=pCopy(ai->m[j]);
2631 pWrite(a);
2632 PrintS("This is b:");
2633 pWrite(b);
2635 delete solve;
2636 gp++;
2637 }
2638 }
2639 mm=mm+1;
2640 }
2641 if(mm==IDELEMS(bi))
2642 PrintS("Finished!\n");
2643 Print("There are %d graded pieces in total.\n",gp);
2644}
2645
2646/*****************************for links*******************************************/
2647//the image phi(pv)=pv minus av minus bv
2648static std::vector<int> phimagel(std::vector<int> fv, std::vector<int> av, std::vector<int> bv)
2649{
2650 std::vector<int> nv;
2651 nv=vecMinus(fv,bv);
2652 nv=vecMinus(nv,av);
2653 return nv;
2654}
2655
2656//mvs and nvs are the supports of ideal Mab and Nab
2657//vecs is the solution of nab
2658static std::vector<std::vector<int> > value1l(std::vector<std::vector<int> > mvs, std::vector<std::vector<int> > lks, std::vector<std::vector<int> > vecs,std::vector<int> av, std::vector<int> bv)
2659{
2660 int j;
2661 std::vector<int> pv;
2662 std::vector<int> base;
2663 std::vector<std::vector<int> > bases;
2664 for(unsigned t=0;t<vecs.size();t++)
2665 {
2666 for(unsigned i=0;i<mvs.size();i++)
2667 {
2668 pv=phimagel(mvs[i], av, bv);
2669 for(j=0;j<lks.size();j++)
2670 {
2671 if(vEvl(pv,lks[j]))
2672 {
2673 base.push_back(vecs[t][j]);break;
2674 }
2675 }
2676 //if(j==lks.size()) {base.push_back(0);}
2677 }
2678 if(base.size()!=mvs.size())
2679 {
2680 WerrorS("Errors in Values Finding(value1l)!");
2681 usleep(1000000);
2682 assert(false);
2683 }
2684 bases.push_back(base);
2685 base.clear();
2686 }
2687 return bases;
2688}
2689
2690/***************************************************/
2692/**************************************************/
2693
2695{
2696 Print("The time of value matching for first order deformation: %.2f sec ;\n", ((double) t_value)/CLOCKS_PER_SEC);
2697 Print("The total time of fpiece: %.2f sec ;\n", ((double) t_total)/CLOCKS_PER_SEC);
2698 Print("The time of equations construction for fpiece: %.2f sec ;\n", ((double) t_construct)/CLOCKS_PER_SEC);
2699 Print("The total time of equations solving for fpiece: %.2f sec ;\n", ((double) t_solve)/CLOCKS_PER_SEC);
2700 PrintS("__________________________________________________________\n");
2701}
2702
2703static std::vector<std::vector<int> > gpl(ideal h,poly a,poly b)
2704{
2705 int i,j,co;
2706 std::vector<std::vector<int> > hvs=supports(h),sbv,nv,mv,good,solve;
2707 std::vector<int> av=support1(a), bv=support1(b),index,bad,tnv;
2708 ideal sub=psubset(b);
2709 sbv=supports(sub);
2710 nv=Nabv(hvs,av,bv);
2711 mv=Mabv(h,a,b);
2712 ideal M=idMaken(mv);
2713 index = gensindex(M, idsrRing(h));
2714 int n=nv.size();
2715 ring r=currRing;
2716 t_begin=clock();
2717 if(n > 0)
2718 {
2719 tnv=tnab(hvs,nv,sbv);
2720 for(i=0;i<tnv.size();i++)
2721 {
2722 co=tnv[i];
2723 bad.push_back(co+1);
2724 }
2725 for(i=0;i<n;i++)
2726 {
2727 for(j=i+1;j<n;j++)
2728 {
2729 if(nabtconditionv(hvs,nv[i],nv[j]))
2730 {
2732 }
2733 else
2734 {
2735 ;
2736 }
2737 }
2738 }
2740 t_begin=clock();
2741 solve=eli2(n,bad,good);
2743 if(bv.size()!=1)
2744 {;
2745 }
2746 else
2747 {
2748 std::vector<int> su=make1(n);
2749 std::vector<std::vector<int> > suu;
2750 suu.push_back(su);
2751 equmab(n);
2753 rChangeCurrRing(r);
2754 }
2755 }
2756 else
2757 {
2758 solve.clear();
2759 }
2760 //listsprint(solve);
2761 //sl->show(0,0);
2762 return solve;
2763}
2764
2765//T^1
2766//only need to consider the links of a, and reduce a to empty set
2767static intvec * gradedpiece1nl(ideal h,poly a,poly b, int set)
2768{
2769 t_start=clock();
2770 poly e=pOne();
2771 std::vector<int> av=support1(a),bv=support1(b),index, em;
2772 std::vector<std::vector<int> > solve, hvs=supports(h), lks=links(a,h), mv=Mabv(h,a,b), nvl;
2774 ideal M=idMaken(mv);
2775 index = gensindex(M, idsrRing(h));
2776 solve=gpl(id_links,e,b);
2777 t_mark=clock();
2778 nvl=Nabv(lks,em,bv);
2779 solve=value1l(mv, nvl , solve, av, bv);
2780 if(set==1)
2781 {
2783 }
2784 intvec *sl=Tmat(solve);
2787 return sl;
2788}
2789
2790//for finding values of T^2
2791static std::vector<std::vector<int> > value2l(std::vector<std::vector<int> > mvs, std::vector<std::vector<int> > lks, std::vector<std::vector<int> > mts, std::vector<std::vector<int> > lkts, std::vector<std::vector<int> > vecs,std::vector<int> av, std::vector<int> bv)
2792{
2793 std::vector<int> pv,qv,base;
2794 int row,col,j;
2795 std::vector<std::vector<int> > bases;
2796 if(vecs.size()==0)
2797 {
2798
2799 }
2800 for(unsigned t=0;t<vecs.size();t++)
2801 {
2802 for(unsigned i=0;i<mts.size();i++)
2803 {
2804 row=mts[i][0];
2805 col=mts[i][1];
2806 pv=phimagel(mvs[row],av,bv);
2807 qv=phimagel(mvs[col],av,bv);
2808 if(vEvl(pv,qv))
2809 base.push_back(0);
2810 else
2811 {
2812 for(j=0;j<lkts.size();j++)
2813 {
2814 row=lkts[j][0];
2815 col=lkts[j][1];
2816 if(vEvl(pv,lks[row])&&vEvl(qv,lks[col]))
2817 {
2818 base.push_back(vecs[t][j]);break;
2819 }
2820 else if(vEvl(qv,lks[row])&&vEvl(pv,lks[col]))
2821 {
2822 base.push_back(-vecs[t][j]);break;
2823 }
2824 }
2825 //if(j==lkts.size())
2826 //{
2827 //base.push_back(0);
2828 //}
2829 }
2830 }
2831 if(base.size()!=mts.size())
2832 {
2833 WerrorS("Errors in Values Finding!");
2834 //WerrorS("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1");
2835 usleep(1000000);
2836 assert(false);
2837 }
2838 bases.push_back(base);
2839 base.clear();
2840 }
2841 return bases;
2842}
2843
2844static std::vector<std::vector<int> > gpl2(ideal h,poly a,poly b)
2845{
2846 int i,j,t,n;
2847 std::vector<std::vector<int> > hvs=supports(h),sbv,nv,mv,mts,vecs,vars,ntvs,solve;
2848 std::vector<int> av=support1(a), bv=support1(b),vec,var,tnv;
2849 ideal sub=psubset(b);
2850 sbv=supports(sub);
2851 nv=Nabv(hvs,av,bv);
2852 n=nv.size();
2853 tnv=tnab(hvs,nv,sbv);
2854 ring r=currRing;
2855 mv=Mabv(h,a,b);
2856 mts=mabtv(hvs,mv,av,bv);
2857 if(n>0)
2858 {
2859 ntvs=nabtv( hvs, nv, av, bv);
2860 int l=ntvs.size();
2861 if(l>0)
2862 {
2863 for(int t0=0;t0<l;t0++)
2864 {
2865 i=ntvs[t0][0];
2866 j=ntvs[t0][1];
2867 if(tNab(hvs,nv[i],sbv)&&tNab(hvs,nv[j],sbv))//condition 1
2868 {
2869 vec=makeequation(t0+1,0,0);
2870 vecs.push_back(vec);
2871 vec.clear();
2872 }
2873 for(int t1=t0+1;t1<ntvs.size();t1++)
2874 {
2875 for(int t2=t1+1;t2<ntvs.size();t2++)
2876 {
2877 if(ntvs[t0][0]==ntvs[t1][0]&&ntvs[t1][1]==ntvs[t2][1]&&ntvs[t0][1]==ntvs[t2][0])
2878 {
2879 i=ntvs[t0][0];
2880 j=ntvs[t0][1];
2881 t=ntvs[t1][1];
2882 if(condition2for2nv(hvs,nv[i],nv[j],nv[t]))
2883 {
2884 vec=makeequation(t0+1,t1+1,t2+1);
2885 vecs.push_back(vec);
2886 vec.clear();
2887 }
2888 }
2889 }
2890 }
2891 }
2892 if(n==1) {l=1;}
2893 equmab(l);
2895 std::vector<std::vector<int> > re=getvector(id_re,l);
2896 rChangeCurrRing(r);
2897 std::vector<std::vector<int> > sub=subspacetn(nv, tnv,ntvs);
2898 equmab(l);
2899 solve=vecqring(re, sub);
2900 rChangeCurrRing(r);
2901 }
2902 else
2903 {
2904 solve.clear();
2905 }
2906 }
2907 else
2908 solve.clear();
2909 return solve;
2910}
2911
2912static intvec * gradedpiece2nl(ideal h,poly a,poly b)
2913{
2914 poly e=pOne();
2915 std::vector<int> av=support1(a), bv=support1(b), em;
2916 std::vector<std::vector<int> > hvs=supports(h), mv=Mabv(h,a,b),mts,solve,lks,nvl,ntsl;
2917 mts=mabtv(hvs,mv,av,bv);
2918 lks=links(a,h);
2920//PrintS("This is the links of a:\n"); id_print(id_links);
2921 nvl=Nabv(lks,em,bv);
2922//PrintS("This is the N set:\n"); id_print(idMaken(nvl));
2923 ntsl=nabtv(lks,nvl,em,bv);
2924//PrintS("This is N^2:\n"); listsprint(ntsl);
2925 solve=gpl2(id_links,e,b);
2926//PrintS("This is pre solution of N:\n"); listsprint(solve);
2927 if(solve.size() > 0)
2928 {
2929 solve=value2l(mv, nvl, mts, ntsl, solve, av, bv);
2930 }
2931//PrintS("This is solution of N:\n"); listsprint(solve);
2932 intvec *sl=Tmat(solve);
2933 return sl;
2934}
2935
2936//for debugging
2937/*
2938void Tlink(ideal h,poly a,poly b,int n)
2939{
2940 std::vector<std::vector<int> > hvs=supports(h);
2941 std::vector<int> av=support1(a);
2942 std::vector<int> bv=support1(b);
2943 std::vector<std::vector<int> > vec=links(a, h);
2944 PrintS("This is the links of a:\n");
2945 listsprint(vec);
2946 ideal li=idMaken(vec);
2947 PrintS("This is the links of a(ideal version):\n");
2948 id_print(li);
2949 poly p=pOne();
2950 PrintS("1************************************************\n");
2951 PrintS("This is T_1 (m):\n");
2952 gradedpiece1(li,p,b);
2953 PrintS("2************************************************\n");
2954 PrintS("This is T_2 (m):\n");
2955 gradedpiece2(li,p,b);
2956 PrintS("3************************************************\n");
2957 PrintS("This is T_1 (n):\n");
2958 gradedpiece1n(li,p,b);
2959 PrintS("4************************************************\n");
2960 PrintS("This is T_2 (n):\n");
2961 gradedpiece2n(li,p,b);
2962}
2963*/
2964
2965/******************************for triangulation***********************************/
2966
2967//returns all the faces which are triangles
2969{
2970 int i;
2971 ideal ids=idInit(1,1);
2972 std::vector<int> pv;
2973 for(i=0;i<IDELEMS(h);i++)
2974 {
2975 pv= support1(h->m[i]);
2976 if(pv.size()==3)
2977 idInsertPoly(ids, pCopy(h->m[i]));
2978 }
2980 return ids;
2981}
2982
2983// case 1 new faces
2984static std::vector<std::vector<int> > triface(poly p, int vert)
2985{
2986 std::vector<int> vec, fv=support1(p);
2987 std::vector<std::vector<int> > fvs0, fvs;
2988 vec.push_back(vert);
2989 fvs.push_back(vec);
2990 fvs0=b_subsets(fv);
2992 for(unsigned i=0;i<fvs0.size();i++)
2993 {
2994 vec=fvs0[i];
2995 vec.push_back(vert);
2996 fvs.push_back(vec);
2997 }
2998 return (fvs);
2999}
3000
3001// the size of p's support must be 3
3002//returns the new complex which is a triangulation based on the face p
3003static ideal triangulations1(ideal h, poly p, int vert)
3004{
3005 std::vector<int> vec, pv=support1(p);
3006 std::vector<std::vector<int> > vecs=supports(h),vs,vs0;
3007 vs0=triface(p,vert);
3008 vecs=vsMinusv(vecs, pv);
3010 //PrintS("This is the new simplicial complex according to the face \n"); pWrite(p);
3011 //PrintS("is:\n");
3012 //listsprint(vecs);
3014 return re;
3015}
3016
3017/*
3018static ideal triangulations1(ideal h)
3019{
3020 int i,vert=currRing->N+1;
3021 std::vector<int> vec;
3022 std::vector<std::vector<int> > vecs=supports(h),vs,vs0;
3023 for (i=0;i<vecs.size();i++)
3024 {
3025 if((vecs[i]).size()==3)
3026 {
3027 vs0=triface(vecs[i],vert);
3028 vs=vsMinusv(vecs,vecs[i]);
3029 vs=vsUnion(vs,vs0);
3030 PrintS("This is the new simplicial complex according to the face \n");listprint(vecs[i]);
3031 PrintS("is:\n");
3032 listsprint(vs);
3033 }
3034 //else if((vecs[i]).size()==4)
3035 //tetraface(vecs[i]);
3036 }
3037 //ideal hh=idMaken(vs);
3038 return h;
3039}*/
3040
3041static std::vector<int> commonedge(poly p, poly q)
3042{
3043 std::vector<int> ev, fv1= support1(p), fv2= support2(q);
3044 for(unsigned i=0;i<fv1.size();i++)
3045 {
3046 if(IsinL(fv1[i], fv2))
3047 ev.push_back(fv1[i]);
3048 }
3049 return ev;
3050}
3051
3052static intvec *edgemat(poly p, poly q)
3053{
3054 intvec *m;
3055 int i;
3056 std::vector<int> dg=commonedge(p, q);
3057 int lg=dg.size();
3058 m=new intvec(lg);
3059 if(lg!=0)
3060 {
3061 m=new intvec(lg);
3062 for(i=0;i<lg;i++)
3063 {
3064 (*m)[i]=dg[i];
3065 }
3066 }
3067 return (m);
3068}
3069
3070// case 2 the new face
3071static std::vector<std::vector<int> > tetraface(poly p, poly q, int vert)
3072{
3073 std::vector<int> ev=commonedge(p, q), vec, fv1=support1(p), fv2=support1(q);
3074 std::vector<std::vector<int> > fvs1, fvs2, fvs;
3075 vec.push_back(vert);
3076 fvs.push_back(vec);
3082 fvs2=vsMinusv(fvs2, ev);
3083 for(unsigned i=0;i<fvs2.size();i++)
3084 {
3085 vec=fvs2[i];
3086 vec.push_back(vert);
3087 fvs.push_back(vec);
3088 }
3089 return (fvs);
3090}
3091
3092//if p and q have a common edge
3093static ideal triangulations2(ideal h, poly p, poly q, int vert)
3094{
3095 std::vector<int> ev, fv1=support1(p), fv2=support1(q);
3096 std::vector<std::vector<int> > vecs=supports(h), vs1;
3097 ev=commonedge(p, q);
3098 vecs=vsMinusv(vecs, ev);
3101 vs1=tetraface(p, q, vert);
3104 return hh;
3105}
3106
3107// case 2 the new face
3108static std::vector<std::vector<int> > penface(poly p, poly q, poly g, int vert)
3109{
3110 int en=0;
3111 std::vector<int> ev1=commonedge(p, q), ev2=commonedge(p, g), ev3=commonedge(q, g), ind, vec, fv1=support1(p), fv2=support1(q), fv3=support1(g);
3112 std::vector<std::vector<int> > fvs1, fvs2, fvs3, fvs, evec;
3113 evec.push_back(ev1);
3114 evec.push_back(ev2);
3115 evec.push_back(ev3);
3116 for(unsigned i=0;i<evec.size();i++)
3117 {
3118 if(evec[i].size()==2)
3119 {
3120 en++;
3121 }
3122 }
3123 if(en==2)
3124 {
3125 vec.push_back(vert);
3126 fvs.push_back(vec);
3135 for(unsigned i=0;i<evec.size();i++)
3136 {
3137 if(evec[i].size()==2)
3138 {
3139 fvs3=vsMinusv(fvs3, evec[i]);
3140 }
3141 }
3142 for(unsigned i=0;i<fvs3.size();i++)
3143 {
3144 vec=fvs3[i];
3145 vec.push_back(vert);
3146 fvs.push_back(vec);
3147 }
3148 }
3149 return (fvs);
3150}
3151
3152static ideal triangulations3(ideal h, poly p, poly q, poly g, int vert)
3153{
3154 std::vector<int> ev1=commonedge(p, q), ev2=commonedge(p, g), ev3=commonedge(q, g), fv1=support1(p), fv2=support1(q), fv3=support1(g);
3155 std::vector<std::vector<int> > vecs=supports(h), vs1, evec;
3156 evec.push_back(ev1);
3157 evec.push_back(ev2);
3158 evec.push_back(ev3);
3159 for(unsigned i=0;i<evec.size();i++)
3160 {
3161 if(evec[i].size()==2)
3162 {
3163 vecs=vsMinusv(vecs, evec[i]);
3164 }
3165 }
3169 vs1=penface(p, q, g, vert);
3172 return hh;
3173}
3174
3175//returns p's valency in h
3176//p must be a vertex
3177static int valency(ideal h, poly p)
3178{
3179 int val=0;
3180 std::vector<int> ev=support1(pCopy(p));
3181 int ver=ev[0];
3182//PrintS("the vertex is :\n"); listprint(p);
3183 std::vector<std::vector<int> > vecs=supports(idCopy(h));
3184 for(unsigned i=0;i<vecs.size();i++)
3185 {
3186 if(vecs[i].size()==2 && IsinL(ver, vecs[i]))
3187 val++;
3188 }
3189 return (val);
3190}
3191
3192/*ideal triangulations2(ideal h)
3193{
3194 int i,j,vert=currRing->N+1;
3195 std::vector<int> ev;
3196 std::vector<std::vector<int> > vecs=supports(h),vs,vs0,vs1;
3197 vs0=tetrasets(h);
3198 for (i=0;i<vs0.size();i++)
3199 {
3200 for(j=i;j<vs0.size();j++)
3201 {
3202 ev=commonedge(vs0[i],vs0[j]);
3203 if(ev.size()==2)
3204 {
3205 vecs=vsMinusv(vecs, ev);
3206 vs=vsMinusv(vecs,vs0[i]);
3207 vs=vsMinusv(vecs,vs0[j]);
3208 vs1=tetraface(vs0[i],vs0[j],vert);
3209 vs=vsUnion(vs,vs1);
3210 PrintS("This is the new simplicial complex according to the face 1 \n");listprint(vecs[i]);
3211PrintS("face 2: \n");
3212 PrintS("is:\n");
3213 listsprint(vs);
3214 }
3215 }
3216
3217 //else if((vecs[i]).size()==4)
3218 //tetraface(vecs[i]);
3219 }
3220 //ideal hh=idMaken(vs);
3221 return h;
3222}*/
3223
3224/*********************************For computation of X_n***********************************/
3225static std::vector<std::vector<int> > vsMinusvs(std::vector<std::vector<int> > vs1, std::vector<std::vector<int> > vs2)
3226{
3227 std::vector<std::vector<int> > vs=vs1;
3228 for(unsigned i=0;i<vs2.size();i++)
3229 {
3230 vs=vsMinusv(vs, vs2[i]);
3231 }
3232 return vs;
3233}
3234
3235static std::vector<std::vector<int> > vs_subsets(std::vector<std::vector<int> > vs)
3236{
3237 std::vector<std::vector<int> > sset, bv;
3238 for(unsigned i=0;i<vs.size();i++)
3239 {
3240 bv=b_subsets(vs[i]);
3241 sset=vsUnion(sset, bv);
3242 }
3243 return sset;
3244}
3245
3246static std::vector<std::vector<int> > p_constant(ideal Xo, ideal Sigma)
3247{
3248 std::vector<std::vector<int> > xs=supports(idCopy(Xo)), ss=supports(idCopy(Sigma)), fvs1;
3251 return fvs1;
3252}
3253
3254static std::vector<std::vector<int> > p_change(ideal Sigma)
3255{
3256 std::vector<std::vector<int> > ss=supports(idCopy(Sigma)), fvs;
3257 fvs=vs_subsets(ss);
3258 return (fvs);
3259}
3260
3261static std::vector<std::vector<int> > p_new(ideal Xo, ideal Sigma)
3262{
3263 int vert=0;
3264 std::vector<std::vector<int> > ss=supports(idCopy(Sigma)), fvs;
3265 for(int i=1;i<=currRing->N;i++)
3266 {
3267 for(int j=0;j<IDELEMS(Xo);j++)
3268 {
3269 if(pGetExp(Xo->m[j],i)>0)
3270 {
3271 vert=i+1;
3272 break;
3273 }
3274 }
3275 }
3276 int typ=ss.size();
3277 if(typ==1)
3278 {
3279 fvs=triface(Sigma->m[0], vert);
3280 }
3281 else if(typ==2)
3282 {
3283 fvs=tetraface(Sigma->m[0], Sigma->m[1], vert);
3284 }
3285 else
3286 {
3287 fvs=penface(Sigma->m[0], Sigma->m[1], Sigma->m[2], vert);
3288 }
3289 return (fvs);
3290}
3291
3293{
3294 std::vector<std::vector<int> > vs1=p_constant(Io, sig), vs2=p_change(sig), vs3=p_new(Io, sig), vsig=supports(sig), vs;
3295 std::vector<int> ev;
3296 int ednum=vsig.size();
3297 if(ednum==2)
3298 {
3299 vsig.push_back(commonedge(sig->m[0], sig->m[1]));
3300 }
3301 else if(ednum==3)
3302 {
3303 for(int i=0;i<IDELEMS(sig);i++)
3304 {
3305 for(int j=i+1;j<IDELEMS(sig);j++)
3306 {
3307 ev=commonedge(sig->m[i], sig->m[j]);
3308 if(ev.size()==2)
3309 {
3310 vsig.push_back(ev);
3311 }
3312 }
3313 }
3314 }
3315//PrintS("the first part is:\n");id_print(idMaken(vs1));
3316//PrintS("the second part is:\n");id_print(idMaken(vsig));
3317//PrintS("the third part is:\n");id_print(idMaken(vs3));
3319//PrintS("the constant part2 is:\n");id_print(idMaken(vs2));
3320 vs=vsUnion(vs2, vs1);
3321//PrintS("the constant part is:\n");id_print(idMaken(vs));
3322 vs=vsUnion(vs, vs3);
3323//PrintS("the whole part is:\n");id_print(idMaken(vs));
3324 return(idMaken(vs));
3325}
3326
3327static std::vector<std::vector<int> > phi1(poly a, ideal Sigma)
3328{
3329 std::vector<std::vector<int> > ss=supports(idCopy(Sigma)), fvs;
3330 std::vector<int> av=support1(a), intvec, vv;
3331 for(unsigned i=0;i<ss.size();i++)
3332 {
3334 if(intvec.size()==av.size())
3335 {
3336 vv=vecMinus(ss[i], av);
3337 fvs.push_back(vv);
3338 }
3339 }
3340 return fvs;
3341}
3342
3343static std::vector<std::vector<int> > phi2(poly a, ideal Xo, ideal Sigma)
3344{
3345
3346 std::vector<std::vector<int> > ss=p_new(Sigma, Xo), fvs;
3347 std::vector<int> av=support1(a), intvec, vv;
3348 for(unsigned i=0;i<ss.size();i++)
3349 {
3351 if(intvec.size()==av.size())
3352 {
3353 vv=vecMinus(ss[i], av);
3354 fvs.push_back(vv);
3355 }
3356 }
3357 return fvs;
3358}
3359
3360static std::vector<std::vector<int> > links_new(poly a, ideal Xo, ideal Sigma, int vert, int ord)
3361{
3362 std::vector<int> av=support1(a);
3363 std::vector<std::vector<int> > lko, lkn, lk1, lk2;
3364 lko=links(a, Xo);
3365 if(ord==1)
3366 return lko;
3367 if(ord==2)
3368 {
3369 lk1=phi1(a, Sigma);
3370 lk2=phi2(a, Xo, Sigma);
3371 lkn=vsMinusvs(lko, lk1);
3372 lkn=vsUnion(lkn, lk2);
3373 return lkn;
3374 }
3375 if(ord==3)
3376 {
3377 lkn=phi2(a, Xo, Sigma);
3378 return lkn;
3379 }
3380 WerrorS("Cannot find the links smartly!");
3381 return lko;
3382}
3383
3384//returns 1 if there is a real divisor of b not in Xs
3385static int existIn(poly b, ideal Xs)
3386{
3387 std::vector<int> bv=support1(pCopy(b));
3388 std::vector<std::vector<int> > xvs=supports(idCopy(Xs)), bs=b_subsets(bv);
3389 bs=vsMinusv(bs, bv);
3390 for(unsigned i=0;i<bs.size();i++)
3391 {
3392 if(!vInvsl(bs[i], xvs))
3393 {
3394 return 1;
3395 }
3396 }
3397 return 0;
3398}
3399
3400static int isoNum(poly p, ideal I, poly a, poly b)
3401{
3402 int i;
3403 std::vector<std::vector<int> > vs=supports(idCopy(I));
3404 std::vector<int> v1=support1(a), v2=support1(b), v=support1(p);
3405 std::vector<int> vp, iv=phimagel(v, v1, v2);
3406 for(i=0;i<IDELEMS(I);i++)
3407 {
3408 vp=support1(pCopy(I->m[i]));
3409 if(vEvl(iv, phimagel(vp, v1, v2)))
3410 {
3411 return (i+1);
3412 }
3413 }
3414 return (0);
3415}
3416
3417static int ifIso(poly p, poly q, poly f, poly g, poly a, poly b)
3418{
3419 std::vector<int> va=support1(a), vb=support1(b), vp=support1(p), vq=support1(q), vf=support1(f), vg=support1(g);
3420 std::vector<int> v1=phimagel(vp, va, vb), v2=phimagel(vq, va, vb), v3=phimagel(vf, va, vb), v4=phimagel(vg, va, vb);
3421 if((vEvl(v1, v3)&& vEvl(v2,v4))||(vEvl(v1, v4)&& vEvl(v2,v3)) )
3422 {
3423 return (1);
3424 }
3425 return (0);
3426}
3427
3428static ideal idMinusp(ideal I, poly p)
3429{
3430 ideal h=idInit(1,1);
3431 int i;
3432 for(i=0;i<IDELEMS(I);i++)
3433 {
3434 if(!p_EqualPolys(I->m[i], p, currRing))
3435 {
3436 idInsertPoly(h, pCopy(I->m[i]));
3437 }
3438 }
3439 idSkipZeroes(h);
3440 return h;
3441}
3442
3443/****************************for the interface of .lib*********************************/
3444
3445static std::vector<int> v_minus(std::vector<int> v1, std::vector<int> v2)
3446{
3447 std::vector<int> vec;
3448 for(unsigned i=0;i<v1.size();i++)
3449 {
3450 vec.push_back(v1[i]-v2[i]);
3451 }
3452 return vec;
3453}
3454
3455static std::vector<int> gdegree(poly a, poly b)
3456{
3457 int i;
3458 std::vector<int> av,bv;
3459 for(i=1;i<=currRing->N;i++)
3460 {
3461 av.push_back(pGetExp(a,i));
3462 bv.push_back(pGetExp(b,i));
3463 }
3464 std::vector<int> vec=v_minus(av,bv);
3465 //PrintS("The degree is:\n");
3466 //listprint(vec);
3467 return vec;
3468}
3469
3470/********************************for stellar subdivision******************************/
3471
3472static std::vector<std::vector<int> > star(poly a, ideal h)
3473{
3474 int i;
3475 std::vector<std::vector<int> > st,X=supports(h);
3476 std::vector<int> U,av=support1(a);
3477 for(i=0;i<X.size();i++)
3478 {
3479 U=vecUnion(av,X[i]);
3480 if(vInvsl(U,X))
3481 {
3482 st.push_back(X[i]);
3483 }
3484 }
3485 return st;
3486}
3487
3488static std::vector<std::vector<int> > boundary(poly a)
3489{
3490 std::vector<int> av=support1(a), vec;
3491 std::vector<std::vector<int> > vecs;
3492 vecs=b_subsets(av);
3493 vecs.push_back(vec);
3494 vecs=vsMinusv(vecs, av);
3495 return vecs;
3496}
3497
3498static std::vector<std::vector<int> > stellarsub(poly a, ideal h)
3499{
3500 std::vector<std::vector<int> > vecs_minus, vecs_plus, lk=links(a,h), hvs=supports(h), sub, bys=boundary(a);
3501 std::vector<int> av=support1(a), vec, vec_n;
3502 int i,j,vert=0;
3503 for(i=1;i<=currRing->N;i++)
3504 {
3505 for(j=0;j<IDELEMS(h);j++)
3506 {
3507 if(pGetExp(h->m[j],i)>0)
3508 {
3509 vert=i+1;
3510 break;
3511 }
3512 }
3513 }
3514 vec_n.push_back(vert);
3515 for(i=0;i<lk.size();i++)
3516 {
3517 vec=vecUnion(av, lk[i]);
3518 vecs_minus.push_back(vec);
3519 for(j=0;j<bys.size();j++)
3520 {
3521 vec=vecUnion(lk[i], vec_n);
3522 vec=vecUnion(vec, bys[j]);
3523 vecs_plus.push_back(vec);
3524 }
3525 }
3526 sub=vsMinusvs(hvs, vecs_minus);
3527 sub=vsUnion(sub, vecs_plus);
3528 return(sub);
3529}
3530
3531static std::vector<std::vector<int> > bsubsets_1(poly b)
3532{
3533 std::vector<int> bvs=support1(b), vs;
3534 std::vector<std::vector<int> > bset;
3535 for(unsigned i=0;i<bvs.size();i++)
3536 {
3537 for(int j=0;j!=i; j++)
3538 {
3539 vs.push_back(bvs[j]);
3540 }
3541 bset.push_back(vs);
3542 vs.resize(0);
3543 }
3544 return bset;
3545}
3546
3547/***************************for time testing******************************/
3549{
3550 int i, j;
3551 //std::vector < intvec > T1;
3552 ideal ai=p_a(h), bi;
3553 //intvec *L;
3554 for(i=0;i<IDELEMS(ai);i++)
3555 {
3556 bi=p_b(h,ai->m[i]);
3557 if(!idIs0(bi))
3558 {
3559 for(j=0;j<IDELEMS(bi);j++)
3560 {
3561 //PrintS("This is for:\n");pWrite(ai->m[i]); pWrite(bi->m[j]);
3562 gradedpiece1nl(h,ai->m[i],bi->m[j], 0);
3563 //PrintS("Succeed!\n");
3564 //T1.push_back(L);
3565 }
3566 }
3567 }
3569 return h;
3570}
3571
3572/**************************************interface T1****************************************/
3573/*
3574static BOOLEAN makeqring(leftv res, leftv args)
3575{
3576 leftv h=args;
3577 ideal h2= id_complement( hh);
3578 if((h != NULL)&&(h->Typ() == POLY_CMD))
3579 {
3580 poly p= (poly)h->Data();
3581 h = h->next;
3582 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3583 {
3584 ideal hh=(ideal)h->Data();
3585 ideal h2=id_complement(hh);
3586 ideal h1=id_Init(1,1);
3587 idInsertPoly(h1,p);
3588 ideal gb=kStd(h2,NULL,testHomog,NULL,NULL,0,0,NULL);
3589 ideal idq=kNF(gb,NULL,h1);
3590 idSkipZeroes(h1);
3591 res->rtyp =POLY_CMD;
3592 res->data =h1->m[0];
3593 }
3594 }
3595 }
3596 return false;
3597}*/
3598
3600{
3601 leftv h=args;
3602 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3603 {
3604 ideal hh=(ideal)h->Data();
3605 res->rtyp =IDEAL_CMD;
3606 res->data =idsrRing(hh);
3607 }
3608 return false;
3609}
3610
3612{
3613 leftv h=args;
3614 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3615 {
3616 ideal hh=(ideal)h->Data();
3618 res->rtyp =IDEAL_CMD;
3619 res->data =h2;
3620 }
3621 return false;
3622}
3623
3625{
3626 leftv h=args;
3627 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3628 {
3629 ideal hh=(ideal)h->Data();
3630 res->rtyp =IDEAL_CMD;
3631 res->data =T_1h(hh);
3632 }
3633 return false;
3634}
3635
3637{
3638 leftv h=args;
3639 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3640 {
3641 ideal h1= (ideal)h->Data();
3642 h = h->next;
3643 if((h != NULL)&&(h->Typ() == POLY_CMD))
3644 {
3645 poly p= (poly)h->Data();
3646 h = h->next;
3647 if((h != NULL)&&(h->Typ() == POLY_CMD))
3648 {
3649 poly q= (poly)h->Data();
3650 res->rtyp =IDEAL_CMD;
3651 res->data =mingens(h1,p,q);
3652 }
3653 }
3654 }
3655 return false;
3656}
3657
3658static intvec *dmat(poly a, poly b)
3659{
3660 intvec *m;
3661 int i;
3662 std::vector<int> dg=gdegree(a,b);
3663 int lg=dg.size();
3664 m=new intvec(lg);
3665 if(lg!=0)
3666 {
3667 m=new intvec(lg);
3668 for(i=0;i<lg;i++)
3669 {
3670 (*m)[i]=dg[i];
3671 }
3672 }
3673 return (m);
3674}
3675
3676static BOOLEAN gd(leftv res, leftv args)
3677{
3678 leftv h=args;
3679 if((h != NULL)&&(h->Typ() == POLY_CMD))
3680 {
3681 poly p= (poly)h->Data();
3682 h = h->next;
3683 if((h != NULL)&&(h->Typ() == POLY_CMD))
3684 {
3685 poly q= (poly)h->Data();
3686 res->rtyp =INTVEC_CMD;
3687 res->data =dmat(p,q);
3688 }
3689 }
3690 return false;
3691}
3692
3694{
3695 leftv h=args;
3696 if((h != NULL)&&(h->Typ() == POLY_CMD))
3697 {
3698 poly p= (poly)h->Data();
3699 h = h->next;
3700 if((h != NULL)&&(h->Typ() == POLY_CMD))
3701 {
3702 poly q= (poly)h->Data();
3703 res->rtyp =INTVEC_CMD;
3704 res->data =edgemat(p,q);
3705 }
3706 }
3707 return false;
3708}
3709
3710static BOOLEAN fb(leftv res, leftv args)
3711{
3712 leftv h=args;
3713 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3714 {
3715 ideal h1= (ideal)h->Data();
3716 res->rtyp =IDEAL_CMD;
3717 res->data =findb(h1);
3718 }
3719 return false;
3720}
3721
3722static BOOLEAN pa(leftv res, leftv args)
3723{
3724 leftv h=args;
3725 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3726 {
3727 ideal h1= (ideal)h->Data();
3728 res->rtyp =IDEAL_CMD;
3729 res->data =p_a(h1);
3730 }
3731 return false;
3732}
3733
3735{
3736 leftv h=args;
3737 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3738 {
3739 ideal h1= (ideal)h->Data();
3740 res->rtyp =IDEAL_CMD;
3741 res->data =complementsimplex(h1);
3742 }
3743 return false;
3744}
3745
3746static BOOLEAN pb(leftv res, leftv args)
3747{
3748 leftv h=args;
3749 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3750 {
3751 ideal h1= (ideal)h->Data();
3752 h = h->next;
3753 if((h != NULL)&&(h->Typ() == POLY_CMD))
3754 {
3755 poly p= (poly)h->Data();
3756 res->rtyp =IDEAL_CMD;
3757 res->data =p_b(h1,p);
3758 }
3759 }
3760 return false;
3761}
3762
3763static BOOLEAN fa(leftv res, leftv args)
3764{
3765 leftv h=args;
3766 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3767 {
3768 ideal h1= (ideal)h->Data();
3769 h = h->next;
3770 if((h != NULL)&&(h->Typ() == POLY_CMD))
3771 {
3772 poly q= (poly)h->Data();
3773 h = h->next;
3774 if((h != NULL)&&(h->Typ() == INT_CMD))
3775 {
3776 int d= (int)(long)h->Data();
3777 res->rtyp =IDEAL_CMD;
3778 res->data =finda(h1,q,d);
3779 }
3780 }
3781 }
3782 return false;
3783}
3784
3786{
3787 leftv h=args;
3788 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3789 {
3790 ideal h1= (ideal)h->Data();
3791 h = h->next;
3792 if((h != NULL)&&(h->Typ() == POLY_CMD))
3793 {
3794 poly p= (poly)h->Data();
3795 h = h->next;
3796 if((h != NULL)&&(h->Typ() == POLY_CMD))
3797 {
3798 poly q= (poly)h->Data();
3799 res->rtyp =INTVEC_CMD;
3800 res->data =gradedpiece1n(h1,p,q);
3801 }
3802 }
3803 }
3804 return false;
3805}
3806
3808{
3809 leftv h=args;
3810 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3811 {
3812 ideal h1= (ideal)h->Data();
3813 h = h->next;
3814 if((h != NULL)&&(h->Typ() == POLY_CMD))
3815 {
3816 poly p= (poly)h->Data();
3817 h = h->next;
3818 if((h != NULL)&&(h->Typ() == POLY_CMD))
3819 {
3820 poly q= (poly)h->Data();
3821 h = h->next;
3822 if((h != NULL)&&(h->Typ() == INT_CMD))
3823 {
3824 int d= (int)(long)h->Data();
3825 res->rtyp =INTVEC_CMD;
3826 res->data =gradedpiece1nl(h1,p,q,d);
3827 }
3828 }
3829 }
3830 }
3831 return false;
3832}
3833
3835{
3836 leftv h=args;
3837 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3838 {
3839 ideal h1= (ideal)h->Data();
3840 h = h->next;
3841 if((h != NULL)&&(h->Typ() == POLY_CMD))
3842 {
3843 poly p= (poly)h->Data();
3844 h = h->next;
3845 if((h != NULL)&&(h->Typ() == POLY_CMD))
3846 {
3847 poly q= (poly)h->Data();
3848 res->rtyp =IDEAL_CMD;
3849 res->data =genst(h1,p,q);
3850 }
3851 }
3852 }
3853 return false;
3854}
3855
3857{
3858 leftv h=args;
3859 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3860 {
3861 ideal h1= (ideal)h->Data();
3862 h = h->next;
3863 if((h != NULL)&&(h->Typ() == POLY_CMD))
3864 {
3865 poly p= (poly)h->Data();
3866 h = h->next;
3867 if((h != NULL)&&(h->Typ() == POLY_CMD))
3868 {
3869 poly q= (poly)h->Data();
3870 res->rtyp =INTVEC_CMD;
3871 res->data =gradedpiece2n(h1,p,q);
3872 }
3873 }
3874 }
3875 return false;
3876}
3877
3879{
3880 leftv h=args;
3881 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3882 {
3883 ideal h1= (ideal)h->Data();
3884 h = h->next;
3885 if((h != NULL)&&(h->Typ() == POLY_CMD))
3886 {
3887 poly p= (poly)h->Data();
3888 h = h->next;
3889 if((h != NULL)&&(h->Typ() == POLY_CMD))
3890 {
3891 poly q= (poly)h->Data();
3892 res->rtyp =INTVEC_CMD;
3893 res->data =gradedpiece2nl(h1,p,q);
3894 }
3895 }
3896 }
3897 return false;
3898}
3899
3901{
3902 leftv h=args;
3903 if((h != NULL)&&(h->Typ() == POLY_CMD))
3904 {
3905 poly p= (poly)h->Data();
3906 h = h->next;
3907 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3908 {
3909 ideal h1= (ideal)h->Data();
3910 res->rtyp =IDEAL_CMD;
3911 std::vector<std::vector<int> > vecs=links(p,h1);
3912 res->data =idMaken(vecs);
3913 }
3914 }
3915 return false;
3916}
3917
3919{
3920 leftv h=args;
3921 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3922 {
3923 ideal h1= (ideal)h->Data();
3924 res->rtyp =IDEAL_CMD;
3925 res->data =IsSimplex(h1);
3926 }
3927 return false;
3928}
3929
3931{
3932 leftv h=args;
3933 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3934 {
3935 ideal h1= (ideal)h->Data();
3936 h = h->next;
3937 if((h != NULL)&&(h->Typ() == POLY_CMD))
3938 {
3939 poly p= (poly)h->Data();
3940 h = h->next;
3941 if((h != NULL)&&(h->Typ() == INT_CMD))
3942 {
3943 int d= (int)(long)h->Data();
3944 res->rtyp =IDEAL_CMD;
3945 res->data =triangulations1(h1, p, d);
3946 }
3947 }
3948 }
3949 return false;
3950}
3951
3953{
3954 leftv h=args;
3955 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3956 {
3957 ideal h1= (ideal)h->Data();
3958 h = h->next;
3959 if((h != NULL)&&(h->Typ() == POLY_CMD))
3960 {
3961 poly p= (poly)h->Data();
3962 h = h->next;
3963 if((h != NULL)&&(h->Typ() == POLY_CMD))
3964 {
3965 poly q= (poly)h->Data();
3966 h = h->next;
3967 if((h != NULL)&&(h->Typ() == INT_CMD))
3968 {
3969 int d= (int)(long)h->Data();
3970 res->rtyp =IDEAL_CMD;
3971 res->data =triangulations2(h1,p,q,d);
3972 }
3973 }
3974 }
3975 }
3976 return false;
3977}
3978
3980{
3981 leftv h=args;
3982 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
3983 {
3984 ideal h1= (ideal)h->Data();
3985 h = h->next;
3986 if((h != NULL)&&(h->Typ() == POLY_CMD))
3987 {
3988 poly p= (poly)h->Data();
3989 h = h->next;
3990 if((h != NULL)&&(h->Typ() == POLY_CMD))
3991 {
3992 poly q= (poly)h->Data();
3993 h = h->next;
3994 if((h != NULL)&&(h->Typ() == POLY_CMD))
3995 {
3996 poly g= (poly)h->Data();
3997 h = h->next;
3998 if((h != NULL)&&(h->Typ() == INT_CMD))
3999 {
4000 int d= (int)(long)h->Data();
4001 res->rtyp =IDEAL_CMD;
4002 res->data =triangulations3(h1,p,q,g,d);
4003 }
4004 }
4005 }
4006 }
4007 }
4008 return false;
4009}
4010
4012{
4013 leftv h=args;int i;
4014 std::vector<int> bset,bs;
4015 std::vector<std::vector<int> > gset;
4016 if((h != NULL)&&(h->Typ() == INT_CMD))
4017 {
4018 int n= (int)(long)h->Data();
4019 h = h->next;
4020 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4021 {
4022 ideal bi= (ideal)h->Data();
4023 h = h->next;
4024 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4025 {
4026 ideal gi= (ideal)h->Data();
4027 for(i=0;i<IDELEMS(bi);i++)
4028 {
4029 bs=support1(bi->m[i]);
4030 if(bs.size()==1)
4031 bset.push_back(bs[0]);
4032 else if(bs.size()==0)
4033 ;
4034 else
4035 {
4036 WerrorS("Errors in T^1 Equations Solving!");
4037 usleep(1000000);
4038 assert(false);
4039 }
4040
4041 }
4042 gset=supports2(gi);
4043 res->rtyp =INTVEC_CMD;
4044 std::vector<std::vector<int> > vecs=eli2(n,bset,gset);
4045 res->data =Tmat(vecs);
4046 }
4047 }
4048 }
4049 return false;
4050}
4051
4053{
4054 leftv h=args;
4055 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4056 {
4057 ideal h1= (ideal)h->Data();
4058 res->rtyp =IDEAL_CMD;
4059 res->data =trisets(h1);
4060 }
4061 return false;
4062}
4063
4065{
4066 leftv h=args;
4067 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4068 {
4069 ideal h1= (ideal)h->Data();
4070 h = h->next;
4071 if((h != NULL)&&(h->Typ() == POLY_CMD))
4072 {
4073 poly p= (poly)h->Data();
4074 res->rtyp =INT_CMD;
4075 res->data =(void *)(long)valency(h1,p);
4076 }
4077 }
4078 return false;
4079}
4080
4082{
4083 leftv h=args;
4084 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4085 {
4086 ideal h1= (ideal)h->Data();
4087 h = h->next;
4088 if((h != NULL)&&(h->Typ() == POLY_CMD))
4089 {
4090 poly p= (poly)h->Data();
4091 h = h->next;
4092 if((h != NULL)&&(h->Typ() == POLY_CMD))
4093 {
4094 poly q= (poly)h->Data();
4095 res->rtyp =IDEAL_CMD;
4096 std::vector<std::vector<int> > vecs=supports(h1);
4097 std::vector<int> pv=support1(p), qv=support1(q);
4098 res->data =idMaken(Nabv(vecs,pv,qv));
4099 }
4100 }
4101 }
4102 return false;
4103}
4104
4106{
4107 leftv h=args;
4108 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4109 {
4110 ideal h1= (ideal)h->Data();
4111 h = h->next;
4112 if((h != NULL)&&(h->Typ() == POLY_CMD))
4113 {
4114 poly p= (poly)h->Data();
4115 h = h->next;
4116 if((h != NULL)&&(h->Typ() == POLY_CMD))
4117 {
4118 poly q= (poly)h->Data();
4119 res->rtyp =IDEAL_CMD;
4120 std::vector<std::vector<int> > vecs=supports(h1), sbv,tnbr;
4121 std::vector<int> pv=support1(p), qv=support1(q);
4122 std::vector<std::vector<int> > nvs=Nabv(vecs, pv, qv);
4123 ideal sub=psubset(q);
4124 sbv=supports(sub);
4125 std::vector<int> tnv =tnab(vecs,nvs,sbv);
4126 for(unsigned i=0;i<tnv.size();i++)
4127 {
4128 tnbr.push_back(nvs[tnv[i]]);
4129 }
4130 res->data =idMaken(tnbr);
4131 }
4132 }
4133 }
4134 return false;
4135}
4136
4138{
4139 leftv h=args;
4140 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4141 {
4142 ideal h1= (ideal)h->Data();
4143 h = h->next;
4144 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4145 {
4146 ideal h2= (ideal)h->Data();
4147 res->rtyp =INT_CMD;
4148 std::vector<std::vector<int> > vs1=supports(h1), vs2=supports(h2);
4149 res->data =(void *)(long)(vsIntersection(vs1, vs2).size());
4150 }
4151 }
4152 return false;
4153}
4154
4156{
4157 leftv h=args;
4158 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4159 {
4160 ideal h1= (ideal)h->Data();
4161 h = h->next;
4162 if((h != NULL)&&(h->Typ() == POLY_CMD))
4163 {
4164 poly p= (poly)h->Data();
4165 h = h->next;
4166 if((h != NULL)&&(h->Typ() == POLY_CMD))
4167 {
4168 poly q= (poly)h->Data();
4169 res->rtyp =IDEAL_CMD;
4170 res->data =idMaken(Mabv(h1,p,q));
4171 }
4172 }
4173 }
4174 return false;
4175}
4176
4178{
4179 leftv h=args;
4180 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4181 {
4182 ideal h1= (ideal)h->Data();
4183 h = h->next;
4184 if((h != NULL)&&(h->Typ() == POLY_CMD))
4185 {
4186 poly p= (poly)h->Data();
4187 h = h->next;
4188 if((h != NULL)&&(h->Typ() == POLY_CMD))
4189 {
4190 poly q= (poly)h->Data();
4191 std::vector<std::vector<int> > hvs=supports(h1), nv, ntvs;
4192 std::vector<int> av=support1(p), bv=support1(q);
4193 nv=Nabv(hvs,av,bv);
4194 ntvs=nabtv( hvs, nv, av, bv);
4195 std::vector<std::vector<poly> > pvs=idMakei(nv,ntvs);
4196 ideal gens=idInit(1,1);
4197 for(unsigned i=0;i<pvs.size();i++)
4198 {
4199 idInsertPoly(gens,pvs[i][0]);
4200 idInsertPoly(gens,pvs[i][1]);
4201 }
4203 res->rtyp =IDEAL_CMD;
4204 res->data =gens;
4205 }
4206 }
4207 }
4208 return false;
4209}
4210
4212{
4213 leftv h=args;
4214 if((h != NULL)&&(h->Typ() == POLY_CMD))
4215 {
4216 poly a= (poly)h->Data();
4217 h = h->next;
4218 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4219 {
4220 ideal Xo= (ideal)h->Data();
4221 h = h->next;
4222 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4223 {
4224 ideal Sigma= (ideal)h->Data();
4225 h = h->next;
4226 if((h != NULL)&&(h->Typ() == INT_CMD))
4227 {
4228 int vert= (int)(long)h->Data();
4229 h = h->next;
4230 if((h != NULL)&&(h->Typ() == INT_CMD))
4231 {
4232 int ord= (int)(long)h->Data();
4233 res->rtyp =IDEAL_CMD;
4234 res->data =idMaken(links_new(a, Xo, Sigma, vert, ord));
4235 }
4236 }
4237 }
4238 }
4239 }
4240 return false;
4241}
4242
4244{
4245 leftv h=args;
4246 if((h != NULL)&&(h->Typ() == POLY_CMD))
4247 {
4248 poly p= (poly)h->Data();
4249 h = h->next;
4250 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4251 {
4252 ideal h1= (ideal)h->Data();
4253 res->rtyp =INT_CMD;
4254 res->data =(void *)(long)existIn(p, h1);
4255 }
4256 }
4257 return false;
4258}
4259
4261{
4262 leftv h=args;
4263 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4264 {
4265 ideal h1= (ideal)h->Data();
4266 h = h->next;
4267 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4268 {
4269 ideal h2= (ideal)h->Data();
4270 res->rtyp =IDEAL_CMD;
4271 res->data =idMaken(p_constant(h1,h2));
4272 }
4273 }
4274 return false;
4275}
4276
4278{
4279 leftv h=args;
4280 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4281 {
4282 ideal h1= (ideal)h->Data();
4283 res->rtyp =IDEAL_CMD;
4284 res->data =idMaken(p_change(h1));
4285 }
4286 return false;
4287}
4288
4290{
4291 leftv h=args;
4292 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4293 {
4294 ideal h1= (ideal)h->Data();
4295 h = h->next;
4296 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4297 {
4298 ideal h2= (ideal)h->Data();
4299 res->rtyp =IDEAL_CMD;
4300 res->data =idMaken(p_new(h1,h2));
4301 }
4302 }
4303 return false;
4304}
4305
4307{
4308 leftv h=args;
4309 if((h != NULL)&&(h->Typ() == POLY_CMD))
4310 {
4311 poly p= (poly)h->Data();
4312 res->rtyp =INT_CMD;
4313 res->data =(void *)(long)(support1(p).size());
4314 }
4315 return false;
4316}
4317
4319{
4320 leftv h=args;
4321 if((h != NULL)&&(h->Typ() == POLY_CMD))
4322 {
4323 poly p= (poly)h->Data();
4324 res->rtyp =IDEAL_CMD;
4325 res->data =idMaken(bsubsets_1(p));
4326 }
4327 return false;
4328}
4329
4331{
4332 leftv h=args;
4333 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4334 {
4335 ideal h1= (ideal)h->Data();
4336 h = h->next;
4337 if((h != NULL)&&(h->Typ() == POLY_CMD))
4338 {
4339 poly p= (poly)h->Data();
4340 res->rtyp =IDEAL_CMD;
4341 res->data =idMinusp(h1, p);
4342 }
4343 }
4344 return false;
4345}
4346
4348{
4349 leftv h=args;
4350 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4351 {
4352 ideal h1= (ideal)h->Data();
4353 h = h->next;
4354 if((h != NULL)&&(h->Typ() == POLY_CMD))
4355 {
4356 poly p= (poly)h->Data();
4357 std::vector<std::vector<int> > st=star(p, h1);
4358 std::vector<std::vector<int> > hvs=supports(h1);
4359 std::vector<std::vector<int> > re= vsMinusvs(hvs, st);
4360 res->rtyp =IDEAL_CMD;
4361 res->data =idMaken(re);
4362 }
4363 }
4364 return false;
4365}
4366
4368{
4369 leftv h=args;
4370 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4371 {
4372 ideal h1= (ideal)h->Data();
4373 h = h->next;
4374 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4375 {
4376 ideal h2= (ideal)h->Data();
4377 res->rtyp =IDEAL_CMD;
4378 res->data =c_New(h1, h2);
4379 }
4380 }
4381 return false;
4382}
4383
4385{
4386 leftv h=args;
4387 if((h != NULL)&&(h->Typ() == POLY_CMD))
4388 {
4389 poly p= (poly)h->Data();
4390 h = h->next;
4391 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4392 {
4393 ideal h1= (ideal)h->Data();
4394 res->rtyp =IDEAL_CMD;
4395 res->data =idMaken(star(p, h1));
4396 }
4397 }
4398 return false;
4399}
4400
4402{
4403 leftv h=args;
4404 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4405 {
4406 ideal h2= (ideal)h->Data();
4407 h = h->next;
4408 if((h != NULL)&&(h->Typ() == POLY_CMD))
4409 {
4410 poly p= (poly)h->Data();
4411 res->rtyp =IDEAL_CMD;
4412 res->data =idMaken(stellarsub(p, h2));
4413 }
4414 }
4415 return false;
4416}
4417
4419{
4420 leftv h=args;
4421 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4422 {
4423 ideal h1= (ideal)h->Data();
4424 h = h->next;
4425 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4426 {
4427 ideal h2= (ideal)h->Data();
4428 res->rtyp =IDEAL_CMD;
4429 res->data =idmodulo(h1, h2);
4430 }
4431 }
4432 return false;
4433}
4434
4436{
4437 leftv h=args;
4438 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4439 {
4440 ideal h1= (ideal)h->Data();
4441 h = h->next;
4442 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4443 {
4444 ideal h2= (ideal)h->Data();
4445 res->rtyp =IDEAL_CMD;
4446 res->data =idMinus(h1, h2);
4447 }
4448 }
4449 return false;
4450}
4451
4453{
4454 leftv h=args;
4455 if((h != NULL)&&(h->Typ() == POLY_CMD))
4456 {
4457 poly p= (poly)h->Data();
4458 h = h->next;
4459 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4460 {
4461 ideal h1= (ideal)h->Data();
4462 h = h->next;
4463 if((h != NULL)&&(h->Typ() == POLY_CMD))
4464 {
4465 poly a= (poly)h->Data();
4466 h = h->next;
4467 if((h != NULL)&&(h->Typ() == POLY_CMD))
4468 {
4469 poly b= (poly)h->Data();
4470 res->rtyp =INT_CMD;
4471 res->data =(void *)(long)isoNum(p, h1, a, b);
4472 }
4473 }
4474 }
4475 }
4476 return false;
4477}
4478
4480{
4481 leftv h=args;
4482 if((h != NULL)&&(h->Typ() == POLY_CMD))
4483 {
4484 poly p= (poly)h->Data();
4485 h = h->next;
4486 if((h != NULL)&&(h->Typ() == POLY_CMD))
4487 {
4488 poly q= (poly)h->Data();
4489 h = h->next;
4490 if((h != NULL)&&(h->Typ() == POLY_CMD))
4491 {
4492 poly f= (poly)h->Data();
4493 h = h->next;
4494 if((h != NULL)&&(h->Typ() == POLY_CMD))
4495 {
4496 poly g= (poly)h->Data();
4497 h = h->next;
4498 if((h != NULL)&&(h->Typ() == POLY_CMD))
4499 {
4500 poly a= (poly)h->Data();
4501 h = h->next;
4502 if((h != NULL)&&(h->Typ() == POLY_CMD))
4503 {
4504 poly b= (poly)h->Data();
4505 res->rtyp =INT_CMD;
4506 res->data =(void *)(long)ifIso(p,q,f,g, a, b);
4507 }
4508 }
4509 }
4510 }
4511 }
4512 }
4513 return false;
4514}
4515
4517{
4518 leftv h=args;
4519 if((h != NULL)&&(h->Typ() == POLY_CMD))
4520 {
4521 poly p= (poly)h->Data();
4522 h = h->next;
4523 if((h != NULL)&&(h->Typ() == INT_CMD))
4524 {
4525 int num= (int)(long)h->Data();
4526 res->rtyp =INT_CMD;
4527 res->data =(void *)(long)redefinedeg( p, num);
4528 }
4529 }
4530 return false;
4531}
4532
4534{
4535 leftv h=args;
4536 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4537 {
4538 ideal h1= (ideal)h->Data();
4539 res->rtyp =IDEAL_CMD;
4540 res->data =complementsimplex(h1);
4541 }
4542 return false;
4543}
4544
4546{
4547 leftv h=args;
4548 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4549 {
4550 ideal h1= (ideal)h->Data();
4551 res->rtyp =INT_CMD;
4552 res->data =(void *)(long)dim_sim(h1);
4553 }
4554 return false;
4555}
4556
4558{
4559 leftv h=args;
4560 if((h != NULL)&&(h->Typ() == IDEAL_CMD))
4561 {
4562 ideal h1= (ideal)h->Data();
4563 h = h->next;
4564 if((h != NULL)&&(h->Typ() == INT_CMD))
4565 {
4566 int num= (int)(long)h->Data();
4567 res->rtyp =INT_CMD;
4568 res->data =(void *)(long)num4dim( h1, num);
4569 }
4570 }
4571 return false;
4572}
4573
4574/**************************************interface T2****************************************/
4575
4577{
4578 p->iiAddCproc("","mg",FALSE,idsr);
4579 p->iiAddCproc("","gd",FALSE,gd);
4580 p->iiAddCproc("","findbset",FALSE,fb);
4581 p->iiAddCproc("","findaset",FALSE,fa);
4582 p->iiAddCproc("","fgp",FALSE,fgp);
4583 p->iiAddCproc("","fgpl",FALSE,fgpl);
4584 p->iiAddCproc("","idcomplement",FALSE,idcomplement);
4585 p->iiAddCproc("","genst",FALSE,genstt);
4586 p->iiAddCproc("","sgp",FALSE,sgp);
4587 p->iiAddCproc("","sgpl",FALSE,sgpl);
4588 p->iiAddCproc("","Links",FALSE,Links);
4589 p->iiAddCproc("","eqsolve1",FALSE,eqsolve1);
4590 p->iiAddCproc("","pb",FALSE,pb);
4591 p->iiAddCproc("","pa",FALSE,pa);
4592 p->iiAddCproc("","makeSimplex",FALSE,makeSimplex);
4593 p->iiAddCproc("","isSim",FALSE,isSim);
4594 p->iiAddCproc("","nfaces1",FALSE,nfaces1);
4595 p->iiAddCproc("","nfaces2",FALSE,nfaces2);
4596 p->iiAddCproc("","nfaces3",FALSE,nfaces3);
4597 p->iiAddCproc("","comedg",FALSE,comedg);
4598 p->iiAddCproc("","tsets",FALSE,tsets);
4599 p->iiAddCproc("","valency",FALSE,Valency);
4600 p->iiAddCproc("","nab",FALSE,nabvl);
4601 p->iiAddCproc("","tnab",FALSE,tnabvl);
4602 p->iiAddCproc("","mab",FALSE,mabvl);
4603 p->iiAddCproc("","SRideal",FALSE,SRideal);
4604 p->iiAddCproc("","Linkn",FALSE,linkn);
4605 p->iiAddCproc("","Existb",FALSE,existsub);
4606 p->iiAddCproc("","pConstant",FALSE,pConstant);
4607 p->iiAddCproc("","pChange",FALSE,pChange);
4608 p->iiAddCproc("","pNew",FALSE,p_New);
4609 p->iiAddCproc("","pSupport",FALSE,support);
4610 p->iiAddCproc("","psMinusp",FALSE,psMinusp);
4611 p->iiAddCproc("","cNew",FALSE,cNew);
4612 p->iiAddCproc("","isoNumber",FALSE,isoNumber);
4613 p->iiAddCproc("","vsInsec",FALSE,vsIntersec);
4614 p->iiAddCproc("","getnabt",FALSE,nabtvl);
4615 p->iiAddCproc("","idmodulo",FALSE,idModulo);
4616 p->iiAddCproc("","ndegree",FALSE,newDegree);
4617 p->iiAddCproc("","nonf2f",FALSE,nonf2f);
4618 p->iiAddCproc("","ifIsom",FALSE,ifIsomorphism);
4619 p->iiAddCproc("","stellarsubdivision",FALSE,stellarsubdivision);
4620 p->iiAddCproc("","star",FALSE,stars);
4621 p->iiAddCproc("","numdim",FALSE,numdim);
4622 p->iiAddCproc("","dimsim",FALSE,dimsim);
4623 p->iiAddCproc("","bprime",FALSE,bprime);
4624 p->iiAddCproc("","remainpart",FALSE,stellarremain);
4625 p->iiAddCproc("","idminus",FALSE,idminus);
4626 p->iiAddCproc("","time1",FALSE,t1h);
4627}
4628
4630{
4632 return MAX_TOK;
4633}
4634#endif
4635#endif
int BOOLEAN
Definition auxiliary.h:87
#define FALSE
Definition auxiliary.h:96
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
CanonicalForm num(const CanonicalForm &f)
Variable mvar(const CanonicalForm &f)
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int p
Definition cfModGcd.cc:4078
g
Definition cfModGcd.cc:4090
CanonicalForm cf
Definition cfModGcd.cc:4083
CanonicalForm gp
Definition cfModGcd.cc:4102
CanonicalForm b
Definition cfModGcd.cc:4103
bool solve(int **extmat, int nrows, int ncols)
Definition cf_linsys.cc:504
FILE * f
Definition checklibs.c:9
Definition idrec.h:35
Class used for (list of) interpreter objects.
Definition subexpr.h:83
void * CopyD(int t)
Definition subexpr.cc:710
int rtyp
Definition subexpr.h:91
void * Data()
Definition subexpr.cc:1173
void Init()
Definition subexpr.h:107
void * data
Definition subexpr.h:88
Definition lists.h:24
sleftv * m
Definition lists.h:46
Coefficient rings, fields and other domains suitable for Singular polynomials.
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:544
static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
"copy" coeffs, i.e. increment ref
Definition coeffs.h:430
static BOOLEAN fa(leftv res, leftv args)
Definition cohomo.cc:3763
static std::vector< int > vecbase1(int num, std::vector< int > oset)
Definition cohomo.cc:1169
static BOOLEAN pa(leftv res, leftv args)
Definition cohomo.cc:3722
static BOOLEAN tsets(leftv res, leftv args)
Definition cohomo.cc:4052
static ideal T_1h(ideal h)
Definition cohomo.cc:3548
static std::vector< int > fvarsvalue(int vnum, std::vector< int > fvars)
Definition cohomo.cc:1108
static std::vector< int > commonedge(poly p, poly q)
Definition cohomo.cc:3041
static std::vector< int > v_minus(std::vector< int > v1, std::vector< int > v2)
Definition cohomo.cc:3445
static bool IsinL(int a, std::vector< int > vec)
Definition cohomo.cc:132
static BOOLEAN tnabvl(leftv res, leftv args)
Definition cohomo.cc:4105
BOOLEAN nfaces1(leftv res, leftv args)
Definition cohomo.cc:3930
static std::vector< int > subspace1(std::vector< std::vector< int > > mv, std::vector< int > bv)
Definition cohomo.cc:1639
VAR clock_t t_construct
Definition cohomo.cc:2691
static 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:2171
static BOOLEAN cNew(leftv res, leftv args)
Definition cohomo.cc:4367
static std::vector< std::vector< int > > listsinsertlist(std::vector< std::vector< int > > gset, int a, int b)
Definition cohomo.cc:1561
static std::vector< std::vector< int > > vsMinusvs(std::vector< std::vector< int > > vs1, std::vector< std::vector< int > > vs2)
Definition cohomo.cc:3225
static BOOLEAN comedg(leftv res, leftv args)
Definition cohomo.cc:3693
static poly pMaken(std::vector< int > vbase)
Definition cohomo.cc:465
static std::vector< std::vector< int > > value1l(std::vector< std::vector< int > > mvs, std::vector< std::vector< int > > lks, std::vector< std::vector< int > > vecs, std::vector< int > av, std::vector< int > bv)
Definition cohomo.cc:2658
VAR clock_t t_start
Definition cohomo.cc:2691
static BOOLEAN idModulo(leftv res, leftv args)
Definition cohomo.cc:4418
static ideal idMaken(std::vector< std::vector< int > > vecs)
Definition cohomo.cc:479
static std::vector< int > vecIntersection(std::vector< int > p, std::vector< int > q)
Definition cohomo.cc:147
static std::vector< std::vector< int > > penface(poly p, poly q, poly g, int vert)
Definition cohomo.cc:3108
static ideal idMake(std::vector< std::vector< int > > vecs)
Definition cohomo.cc:358
static std::vector< std::vector< int > > vsMinusv(std::vector< std::vector< int > > vecs, std::vector< int > vec)
Definition cohomo.cc:225
static intvec * gradedpiece1n(ideal h, poly a, poly b)
Definition cohomo.cc:2312
static std::vector< std::vector< int > > value2l(std::vector< std::vector< int > > mvs, std::vector< std::vector< int > > lks, std::vector< std::vector< int > > mts, std::vector< std::vector< int > > lkts, std::vector< std::vector< int > > vecs, std::vector< int > av, std::vector< int > bv)
Definition cohomo.cc:2791
static BOOLEAN isoNumber(leftv res, leftv args)
Definition cohomo.cc:4452
static BOOLEAN makeSimplex(leftv res, leftv args)
Definition cohomo.cc:3734
static bool vInvsl(std::vector< int > vec, std::vector< std::vector< int > > vecs)
Definition cohomo.cc:186
static 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:1982
static BOOLEAN fgp(leftv res, leftv args)
Definition cohomo.cc:3785
static bool tNab(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< std::vector< int > > bvs)
Definition cohomo.cc:2156
static int valency(ideal h, poly p)
Definition cohomo.cc:3177
static 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:1776
static void lpsprint(std::vector< std::vector< poly > > pvs)
Definition cohomo.cc:112
static 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:2458
static std::vector< int > phimagel(std::vector< int > fv, std::vector< int > av, std::vector< int > bv)
Definition cohomo.cc:2648
static BOOLEAN stars(leftv res, leftv args)
Definition cohomo.cc:4384
static std::vector< int > keeporder(std::vector< int > vec)
Definition cohomo.cc:1039
static std::vector< std::vector< int > > p_new(ideal Xo, ideal Sigma)
Definition cohomo.cc:3261
static BOOLEAN newDegree(leftv res, leftv args)
Definition cohomo.cc:4516
static void T1(ideal h)
Definition cohomo.cc:2379
static 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:1763
static std::vector< std::vector< int > > Nabv(std::vector< std::vector< int > > hvs, std::vector< int > av, std::vector< int > bv)
Definition cohomo.cc:2105
static ideal trisets(ideal h)
Definition cohomo.cc:2968
static int pvert(poly p)
Definition cohomo.cc:541
static int idvert(ideal h)
Definition cohomo.cc:522
static void firstorderdef_setup(SModulFunctions *p)
Definition cohomo.cc:4576
static ideal SimFacset(poly p)
Definition cohomo.cc:787
static std::vector< std::vector< int > > links_new(poly a, ideal Xo, ideal Sigma, int vert, int ord)
Definition cohomo.cc:3360
static std::vector< std::vector< poly > > idMakei(std::vector< std::vector< int > > mv, std::vector< std::vector< int > > vecs)
Definition cohomo.cc:1670
static ideal psubset(poly p)
Definition cohomo.cc:1539
static BOOLEAN bprime(leftv res, leftv args)
Definition cohomo.cc:4318
static void listprint(std::vector< int > vec)
Definition cohomo.cc:49
static BOOLEAN pConstant(leftv res, leftv args)
Definition cohomo.cc:4260
static bool vInp(int m, poly p)
Definition cohomo.cc:405
static BOOLEAN dimsim(leftv res, leftv args)
Definition cohomo.cc:4545
static std::vector< std::vector< int > > ofindbases(int num, std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition cohomo.cc:1227
static BOOLEAN fgpl(leftv res, leftv args)
Definition cohomo.cc:3807
static bool p_Ifsfree(poly P)
Definition cohomo.cc:643
static int redefinedeg(poly p, int num)
Definition cohomo.cc:1315
static intvec * edgemat(poly p, poly q)
Definition cohomo.cc:3052
static BOOLEAN psMinusp(leftv res, leftv args)
Definition cohomo.cc:4330
static bool nabtconditionv(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > qv)
Definition cohomo.cc:2122
static BOOLEAN SRideal(leftv res, leftv args)
Definition cohomo.cc:3599
static std::vector< std::vector< int > > phi1(poly a, ideal Sigma)
Definition cohomo.cc:3327
static bool condition2for2nv(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > qv, std::vector< int > fv)
Definition cohomo.cc:2409
static std::vector< int > freevars(int n, std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition cohomo.cc:1085
static BOOLEAN stellarsubdivision(leftv res, leftv args)
Definition cohomo.cc:4401
static BOOLEAN idcomplement(leftv res, leftv args)
Definition cohomo.cc:3611
static std::vector< std::vector< int > > phi2(poly a, ideal Xo, ideal Sigma)
Definition cohomo.cc:3343
VAR clock_t t_begin
Definition cohomo.cc:2691
static int isoNum(poly p, ideal I, poly a, poly b)
Definition cohomo.cc:3400
static bool condition1for2(std::vector< int > pv, std::vector< int > qv, std::vector< int > bv)
Definition cohomo.cc:1750
static BOOLEAN isSim(leftv res, leftv args)
Definition cohomo.cc:3918
static ideal IsSimplex(ideal h)
Definition cohomo.cc:832
static BOOLEAN gd(leftv res, leftv args)
Definition cohomo.cc:3676
static std::vector< std::vector< int > > vsUnion(std::vector< std::vector< int > > vs1, std::vector< std::vector< int > > vs2)
Definition cohomo.cc:239
static BOOLEAN nabvl(leftv res, leftv args)
Definition cohomo.cc:4081
static BOOLEAN fb(leftv res, leftv args)
Definition cohomo.cc:3710
static ideal idmodulo(ideal h1, ideal h2)
Definition cohomo.cc:375
VAR clock_t t_mark
Definition cohomo.cc:2691
static ideal idadda(ideal h1, ideal h2)
Definition cohomo.cc:808
static intvec * gradedpiece2n(ideal h, poly a, poly b)
Definition cohomo.cc:2527
static ideal idMake3(std::vector< std::vector< int > > vecs)
Definition cohomo.cc:1601
static ideal complementsimplex(ideal h)
Definition cohomo.cc:853
static ideal c_New(ideal Io, ideal sig)
Definition cohomo.cc:3292
static void T2(ideal h)
Definition cohomo.cc:2606
static std::vector< int > make1(int n)
Definition cohomo.cc:1198
static ideal qringadd(ideal h1, ideal h2, int deg)
Definition cohomo.cc:735
static BOOLEAN eqsolve1(leftv res, leftv args)
Definition cohomo.cc:4011
static std::vector< std::vector< int > > vAbsorb(std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition cohomo.cc:1125
static ideal finda(ideal h, poly S, int ddeg)
Definition cohomo.cc:934
static std::vector< std::vector< int > > soleli1(std::vector< std::vector< int > > eqs)
Definition cohomo.cc:1052
static std::vector< int > vMake(poly p)
Definition cohomo.cc:420
static std::vector< int > subspacet1(int num, std::vector< std::vector< int > > ntvs)
Definition cohomo.cc:1941
static std::vector< std::vector< int > > vsMake(ideal h)
Definition cohomo.cc:439
static BOOLEAN numdim(leftv res, leftv args)
Definition cohomo.cc:4557
static bool vEvl(std::vector< int > vec1, std::vector< int > vec2)
Definition cohomo.cc:174
static BOOLEAN vsIntersec(leftv res, leftv args)
Definition cohomo.cc:4137
static BOOLEAN support(leftv res, leftv args)
Definition cohomo.cc:4306
static void id_print(ideal h)
Definition cohomo.cc:84
static std::vector< std::vector< int > > bsubsets_1(poly b)
Definition cohomo.cc:3531
static BOOLEAN genstt(leftv res, leftv args)
Definition cohomo.cc:3834
static void TimeShow(clock_t t_construct, clock_t t_solve, clock_t t_value, clock_t t_total)
Definition cohomo.cc:2694
static intvec * dmat(poly a, poly b)
Definition cohomo.cc:3658
static BOOLEAN nonf2f(leftv res, leftv args)
Definition cohomo.cc:4533
static std::vector< std::vector< int > > stellarsub(poly a, ideal h)
Definition cohomo.cc:3498
static void equmab(int num)
Definition cohomo.cc:1618
static BOOLEAN sgpl(leftv res, leftv args)
Definition cohomo.cc:3878
static std::vector< int > support1(poly p)
Definition cohomo.cc:271
static bool nabconditionv(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > av, std::vector< int > bv)
Definition cohomo.cc:2091
static std::vector< int > support2(poly p)
Definition cohomo.cc:304
static std::vector< std::vector< int > > p_change(ideal Sigma)
Definition cohomo.cc:3254
static std::vector< std::vector< int > > vecqring(std::vector< std::vector< int > > vec1, std::vector< std::vector< int > > vec2)
Definition cohomo.cc:454
static std::vector< int > gdegree(poly a, poly b)
Definition cohomo.cc:3455
static ideal id_sfmon(ideal h)
Definition cohomo.cc:679
static ideal triangulations1(ideal h, poly p, int vert)
Definition cohomo.cc:3003
VAR clock_t t_value
Definition cohomo.cc:2691
static int id_maxdeg(ideal h)
Definition cohomo.cc:744
static std::vector< int > vertset(std::vector< std::vector< int > > vecs)
Definition cohomo.cc:1404
static ideal id_complement(ideal h)
Definition cohomo.cc:698
static ideal p_a(ideal h)
Definition cohomo.cc:1335
static std::vector< std::vector< int > > tetraface(poly p, poly q, int vert)
Definition cohomo.cc:3071
static std::vector< std::vector< int > > eli2(int num, std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition cohomo.cc:1254
static ideal triangulations3(ideal h, poly p, poly q, poly g, int vert)
Definition cohomo.cc:3152
static std::vector< std::vector< int > > vs_subsets(std::vector< std::vector< int > > vs)
Definition cohomo.cc:3235
static std::vector< int > vecUnion(std::vector< int > vec1, std::vector< int > vec2)
Definition cohomo.cc:200
static BOOLEAN sgp(leftv res, leftv args)
Definition cohomo.cc:3856
static intvec * Tmat(std::vector< std::vector< int > > vecs)
Definition cohomo.cc:2232
static std::vector< std::vector< int > > canonicalbase(int n)
Definition cohomo.cc:1842
static BOOLEAN idsr(leftv res, leftv args)
Definition cohomo.cc:3636
static std::vector< std::vector< int > > minisolve(std::vector< std::vector< int > > solve, std::vector< int > index)
Definition cohomo.cc:2290
static ideal genst(ideal h, poly a, poly b)
Definition cohomo.cc:2510
static BOOLEAN linkn(leftv res, leftv args)
Definition cohomo.cc:4211
static std::vector< int > vecMinus(std::vector< int > vec1, std::vector< int > vec2)
Definition cohomo.cc:212
static std::vector< std::vector< int > > Mabv(ideal h, poly a, poly b)
Definition cohomo.cc:975
static std::vector< int > gensindex(ideal M, ideal ids)
Definition cohomo.cc:2259
static BOOLEAN Valency(leftv res, leftv args)
Definition cohomo.cc:4064
static std::vector< int > makeequation(int i, int j, int t)
Definition cohomo.cc:1570
static bool mabconditionv(std::vector< std::vector< int > > hvs, std::vector< int > pv, std::vector< int > av, std::vector< int > bv)
Definition cohomo.cc:963
static std::vector< std::vector< int > > boundary(poly a)
Definition cohomo.cc:3488
static ideal idMinus(ideal h1, ideal h2)
Definition cohomo.cc:617
int SI_MOD_INIT() cohomo(SModulFunctions *p)
Definition cohomo.cc:4629
static int dim_sim(ideal h)
Definition cohomo.cc:876
static std::vector< std::vector< int > > star(poly a, ideal h)
Definition cohomo.cc:3472
static std::vector< int > findalpha(std::vector< std::vector< int > > mv, std::vector< int > bv)
Definition cohomo.cc:1926
static BOOLEAN stellarremain(leftv res, leftv args)
Definition cohomo.cc:4347
static void lpprint(std::vector< poly > pv)
Definition cohomo.cc:97
static ideal getpresolve(ideal h)
Definition cohomo.cc:1795
static BOOLEAN nabtvl(leftv res, leftv args)
Definition cohomo.cc:4177
static std::vector< int > make0(int n)
Definition cohomo.cc:1185
static 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:2439
static int pcoef(poly p, int m)
Definition cohomo.cc:386
static ideal triangulations2(ideal h, poly p, poly q, int vert)
Definition cohomo.cc:3093
static std::vector< std::vector< int > > getvector(ideal h, int n)
Definition cohomo.cc:1862
VAR clock_t t_total
Definition cohomo.cc:2691
static std::vector< std::vector< int > > gpl(ideal h, poly a, poly b)
Definition cohomo.cc:2703
static BOOLEAN nfaces3(leftv res, leftv args)
Definition cohomo.cc:3979
static 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:2134
static void gradedpiece1(ideal h, poly a, poly b)
Definition cohomo.cc:1690
static BOOLEAN p_New(leftv res, leftv args)
Definition cohomo.cc:4289
static BOOLEAN Links(leftv res, leftv args)
Definition cohomo.cc:3900
static poly pMake(std::vector< int > vbase)
Definition cohomo.cc:343
static BOOLEAN nfaces2(leftv res, leftv args)
Definition cohomo.cc:3952
static 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:2195
static bool IsInX(poly p, ideal X)
Definition cohomo.cc:719
static intvec * gradedpiece1nl(ideal h, poly a, poly b, int set)
Definition cohomo.cc:2767
static std::vector< std::vector< int > > links(poly a, ideal h)
Definition cohomo.cc:1293
static std::vector< std::vector< int > > supports(ideal h)
Definition cohomo.cc:287
static BOOLEAN pb(leftv res, leftv args)
Definition cohomo.cc:3746
VAR clock_t t_solve
Definition cohomo.cc:2691
static std::vector< int > ofindbases1(int num, int vnum, std::vector< int > bset, std::vector< std::vector< int > > gset)
Definition cohomo.cc:1211
static std::vector< std::vector< int > > vsIntersection(std::vector< std::vector< int > > vs1, std::vector< std::vector< int > > vs2)
Definition cohomo.cc:253
static ideal sfreemon(ideal h, int deg)
Definition cohomo.cc:658
static int existIn(poly b, ideal Xs)
Definition cohomo.cc:3385
static std::vector< std::vector< int > > supports2(ideal h)
Definition cohomo.cc:326
static BOOLEAN pChange(leftv res, leftv args)
Definition cohomo.cc:4277
static std::vector< std::vector< int > > gpl2(ideal h, poly a, poly b)
Definition cohomo.cc:2844
static std::vector< int > numfree(ideal h)
Definition cohomo.cc:1823
static std::vector< int > eli1(std::vector< int > eq1, std::vector< int > eq2)
Definition cohomo.cc:996
static ideal idsrRing(ideal h)
Definition cohomo.cc:758
static ideal idMinusp(ideal I, poly p)
Definition cohomo.cc:3428
static std::vector< std::vector< int > > triface(poly p, int vert)
Definition cohomo.cc:2984
static BOOLEAN idminus(leftv res, leftv args)
Definition cohomo.cc:4435
static ideal p_b(ideal h, poly a)
Definition cohomo.cc:1427
static void listsprint(std::vector< std::vector< int > > posMat)
Definition cohomo.cc:65
static BOOLEAN mabvl(leftv res, leftv args)
Definition cohomo.cc:4155
static int num4dim(ideal h, int n)
Definition cohomo.cc:889
static std::vector< int > findalphan(std::vector< std::vector< int > > N, std::vector< int > tN)
Definition cohomo.cc:2423
static BOOLEAN ifIsomorphism(leftv res, leftv args)
Definition cohomo.cc:4479
static int ifIso(poly p, poly q, poly f, poly g, poly a, poly b)
Definition cohomo.cc:3417
static void gradedpiece2(ideal h, poly a, poly b)
Definition cohomo.cc:2005
static intvec * gradedpiece2nl(ideal h, poly a, poly b)
Definition cohomo.cc:2912
static std::vector< std::vector< int > > b_subsets(std::vector< int > vec)
Definition cohomo.cc:496
static std::vector< std::vector< int > > p_constant(ideal Xo, ideal Sigma)
Definition cohomo.cc:3246
static BOOLEAN existsub(leftv res, leftv args)
Definition cohomo.cc:4243
static ideal mingens(ideal h, poly a, poly b)
Definition cohomo.cc:2276
static std::vector< int > phimage(std::vector< int > pv, std::vector< int > av, std::vector< int > bv)
Definition cohomo.cc:2186
static bool vsubset(std::vector< int > vec1, std::vector< int > vec2)
Definition cohomo.cc:160
static ideal findb(ideal h)
Definition cohomo.cc:908
static BOOLEAN t1h(leftv res, leftv args)
Definition cohomo.cc:3624
static std::vector< poly > pMakei(std::vector< std::vector< int > > mv, std::vector< int > vbase)
Definition cohomo.cc:1656
static 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:1968
static poly pMake3(std::vector< int > vbase)
Definition cohomo.cc:1583
#define Print
Definition emacs.cc:80
const CanonicalForm int s
Definition facAbsFact.cc:51
CanonicalForm res
Definition facAbsFact.cc:60
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
bool bad
fq_nmod_poly_t * vec
Definition facHensel.cc:108
int j
Definition facHensel.cc:110
static int max(int a, int b)
Definition fast_mult.cc:264
void WerrorS(const char *s)
Definition feFopen.cc:24
#define VAR
Definition globaldefs.h:5
@ IDEAL_CMD
Definition grammar.cc:284
@ POLY_CMD
Definition grammar.cc:289
@ RING_CMD
Definition grammar.cc:281
ideal scKBase(int deg, ideal s, ideal Q, intvec *mv)
Definition hdegree.cc:1448
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
ideal idCopy(ideal A)
Definition ideals.h:60
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition ideals.h:68
#define IMATELEM(M, I, J)
Definition intvec.h:85
idhdl ggetid(const char *n)
Definition ipid.cc:581
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:279
#define IDROOT
Definition ipid.h:19
#define IDRING(a)
Definition ipid.h:127
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition iplib.cc:504
INST_VAR sleftv iiRETURNEXPR
Definition iplib.cc:474
void rSetHdl(idhdl h)
Definition ipshell.cc:5128
STATIC_VAR Poly * h
Definition janet.cc:971
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3185
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:2449
void rem(unsigned long *a, unsigned long *q, unsigned long p, int &dega, int degq)
Definition minpoly.cc:572
#define pNext(p)
Definition monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
slists * lists
The main handler for Singular numbers which are suitable for Singular polynomials.
#define nInit(i)
Definition numbers.h:24
#define omStrDup(s)
#define omAlloc(size)
#define omalloc(size)
#define NULL
Definition omList.c:12
static int index(p_Length length, p_Ord ord)
poly p_Subst(poly p, int n, poly e, const ring r)
Definition p_polys.cc:3958
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition p_polys.cc:4512
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1031
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
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1900
void rChangeCurrRing(ring r)
Definition polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pAdd(p, q)
Definition polys.h:203
static long pTotaldegree(poly p)
Definition polys.h:282
#define pSetm(p)
Definition polys.h:271
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:31
void pWrite(poly p)
Definition polys.h:308
#define pGetExp(p, i)
Exponent.
Definition polys.h:41
#define pEqualPolys(p1, p2)
Definition polys.h:399
#define pSetExp(p, i, v)
Definition polys.h:42
#define pCopy(p)
return a copy of the poly
Definition polys.h:185
#define pOne()
Definition polys.h:315
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310
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:102
ring rCopy(ring r)
Definition ring.cc:1731
@ ringorder_lp
Definition ring.h:77
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:592
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
ideal idInit(int idsize, int rank)
initialise an ideal / module
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define IDELEMS(i)
#define R
Definition sirandom.c:27
#define M
Definition sirandom.c:25
unsigned size() const
@ testHomog
Definition structs.h:38
#define assert(A)
Definition svd_si.h:3
@ INTVEC_CMD
Definition tok.h:101
@ INT_CMD
Definition tok.h:96
@ MAX_TOK
Definition tok.h:218
int dim(ideal I, ring r)
int tdeg(poly p)