[b3e45f] | 1 | /* |
---|
[6623f3] | 2 | Compute the Groebner fan of an ideal |
---|
[361be1f] | 3 | Author: $Author: monerjan $ |
---|
[6623f3] | 4 | Date: $Date: 2009-02-09 20:51:48 $ |
---|
| 5 | Header: $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.7 2009-02-09 20:51:48 monerjan Exp $ |
---|
| 6 | Id: $Id: gfan.cc,v 1.7 2009-02-09 20:51:48 monerjan Exp $ |
---|
[b3e45f] | 7 | */ |
---|
| 8 | |
---|
[d3398c] | 9 | #include "mod2.h" |
---|
| 10 | #include "kstd1.h" |
---|
[50ab25a] | 11 | #include "intvec.h" |
---|
[2c6535] | 12 | #include "polys.h" |
---|
| 13 | #include "ideals.h" |
---|
[d3398c] | 14 | |
---|
[b3e45f] | 15 | #ifndef gfan_DEBUG |
---|
| 16 | #define gfan_DEBUG |
---|
| 17 | #endif |
---|
| 18 | |
---|
[2c6535] | 19 | ideal getGB(ideal inputIdeal) |
---|
| 20 | { |
---|
[b3e45f] | 21 | #ifdef gfan_DEBUG |
---|
| 22 | printf("Now in getGB\n"); |
---|
| 23 | #endif |
---|
[2c6535] | 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 | |
---|
[b3e45f] | 29 | return gb; |
---|
| 30 | } |
---|
| 31 | |
---|
[2c6535] | 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 | { |
---|
[b3e45f] | 71 | #ifdef gfan_DEBUG |
---|
| 72 | printf("Now in subroutine gfan\n"); |
---|
| 73 | #endif |
---|
| 74 | ideal res; |
---|
[2c6535] | 75 | matrix ineq; //Matrix containing the boundary inequalities |
---|
| 76 | |
---|
[b3e45f] | 77 | res=getGB(inputIdeal); |
---|
[2c6535] | 78 | getWallIneq(res); |
---|
[b3e45f] | 79 | return res; |
---|
[d3398c] | 80 | } |
---|