1 | /* |
---|
2 | Compute the Grï¿œbner fan of an ideal |
---|
3 | Author: $Author: monerjan $ |
---|
4 | Date: $Date: 2009-02-09 20:46:59 $ |
---|
5 | Header: $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.6 2009-02-09 20:46:59 monerjan Exp $ |
---|
6 | Id: $Id: gfan.cc,v 1.6 2009-02-09 20:46:59 monerjan Exp $ |
---|
7 | */ |
---|
8 | |
---|
9 | #include "mod2.h" |
---|
10 | #include "kstd1.h" |
---|
11 | #include "intvec.h" |
---|
12 | #include "polys.h" |
---|
13 | #include "ideals.h" |
---|
14 | |
---|
15 | #ifndef gfan_DEBUG |
---|
16 | #define gfan_DEBUG |
---|
17 | #endif |
---|
18 | |
---|
19 | ideal getGB(ideal inputIdeal) |
---|
20 | { |
---|
21 | #ifdef gfan_DEBUG |
---|
22 | printf("Now in getGB\n"); |
---|
23 | #endif |
---|
24 | |
---|
25 | ideal gb; |
---|
26 | gb=kStd(inputIdeal,NULL,testHomog,NULL); //Possible to call without testHomog/isHomog? |
---|
27 | idSkipZeroes(gb); //Get rid of zero entries |
---|
28 | |
---|
29 | return gb; |
---|
30 | } |
---|
31 | |
---|
32 | /****** getWallIneq computes the inequalities ***/ |
---|
33 | /*INPUT_TYPE: ideal */ |
---|
34 | /*RETURN_TYPE: matrix */ |
---|
35 | /************************************************/ |
---|
36 | void getWallIneq(ideal I) |
---|
37 | { |
---|
38 | #ifdef gfan_DEBUG |
---|
39 | printf("Computing Inequalities...\n"); |
---|
40 | #endif |
---|
41 | |
---|
42 | // Exponentenvektor |
---|
43 | Exponent_t leadexp,aktexp,diffexp; |
---|
44 | poly aktpoly; |
---|
45 | |
---|
46 | int lengthGB=IDELEMS(I); |
---|
47 | printf("The Gröbner basis has %i elements\n",lengthGB); |
---|
48 | |
---|
49 | // We loop through each g\in GB |
---|
50 | for (int i=0; i<IDELEMS(I); i++) |
---|
51 | { |
---|
52 | aktpoly=(poly)I->m[i]; |
---|
53 | leadexp = pGetExp(aktpoly,1); //get the exp.vect of leading monomial |
---|
54 | for (int j=2;j<=pLength(aktpoly);j++) |
---|
55 | { |
---|
56 | aktexp=pGetExp(aktpoly,j); |
---|
57 | //diffexp=pSubExp(aktpoly, leadexp,aktexp); //Dang! => runtime error |
---|
58 | //printf("Exponentenvektor=%i\n",expmark); |
---|
59 | //printf("Diff=%i\n",expmark-pGetExp(aktpoly,j)); |
---|
60 | } |
---|
61 | int pCompCount; |
---|
62 | pCompCount=pLength(aktpoly); |
---|
63 | printf("Poly No. %i has %i components\n",i,pCompCount); |
---|
64 | } //for |
---|
65 | //res=(ideal)aktpoly; |
---|
66 | //return res; |
---|
67 | } |
---|
68 | |
---|
69 | ideal gfan(ideal inputIdeal) |
---|
70 | { |
---|
71 | #ifdef gfan_DEBUG |
---|
72 | printf("Now in subroutine gfan\n"); |
---|
73 | #endif |
---|
74 | ideal res; |
---|
75 | matrix ineq; //Matrix containing the boundary inequalities |
---|
76 | |
---|
77 | res=getGB(inputIdeal); |
---|
78 | getWallIneq(res); |
---|
79 | return res; |
---|
80 | } |
---|