My Project
Loading...
Searching...
No Matches
groebnerFan.cc
Go to the documentation of this file.
1#include "misc/options.h"
2#include "bbfan.h"
3
4#include "groebnerCone.h"
5#include "startingCone.h"
6#include "tropicalTraversal.h"
7
8
10
11/***
12 * sets option(redSB)
13 **/
14static void setOptionRedSB()
15{
18}
19
20/***
21 * sets option(noredSB);
22 **/
23static void undoSetOptionRedSB()
24{
26}
27
28gfan::ZFan* groebnerFan(const tropicalStrategy currentStrategy)
29{
30 groebnerCone startingCone = groebnerStartingCone(currentStrategy);
32 return toFanStar(groebnerFan);
33}
34
35
36gfan::ZFan* groebnerFanOfPolynomial(poly g, ring r, bool onlyLowerHalfSpace=false)
37{
38 int n = rVar(r);
39
40 if (g==NULL || g->next==NULL)
41 {
42 // if g is a term or zero, return the fan consisting of the whole weight space
43 gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(n));
44 return zf;
45 }
46 else
47 {
48 gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
49 lowerHalfSpaceCondition[0] = -1;
50
51 // otherwise, obtain a list of all the exponent vectors
52 int* expv = (int*) omAlloc((n+1)*sizeof(int));
53 gfan::ZMatrix exponents = gfan::ZMatrix(0,n);
54 for (poly s=g; s; pIter(s))
55 {
56 p_GetExpV(s,expv,r);
57 gfan::ZVector zv = intStar2ZVector(n,expv);
58 exponents.appendRow(intStar2ZVector(n,expv));
59 }
60 omFreeSize(expv,(n+1)*sizeof(int));
61
62 // and construct the Groebner fan
63 gfan::ZFan* zf = new gfan::ZFan(n);
64 int l = exponents.getHeight();
65 for (int i=0; i<l; i++)
66 {
67 // constructs the Groebner cone such that initial form is i-th term
68 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
69 if (onlyLowerHalfSpace)
70 inequalities.appendRow(lowerHalfSpaceCondition);
71 for (int j=0; j<l; j++)
72 {
73 if (i!=j)
74 inequalities.appendRow(exponents[i].toVector()-exponents[j].toVector());
75 }
76 gfan::ZCone zc = gfan::ZCone(inequalities,gfan::ZMatrix(0,inequalities.getWidth()));
77 zc.canonicalize();
78 zf->insert(zc);
79 }
80 return zf;
81 }
82}
83
84
86{
87 leftv u = args;
88 if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
89 {
90 ideal I = (ideal) u->CopyD();
91 leftv v = u->next;
92
93 if (v==NULL)
94 {
95 if ((I->m[0]!=NULL) && (idElem(I)==1))
96 {
97 try
98 {
99 poly g = I->m[0];
100 gfan::ZFan* zf = groebnerFanOfPolynomial(g,currRing);
101 res->rtyp = fanID;
102 res->data = (char*) zf;
103 return FALSE;
104 }
105 catch (const std::exception& ex)
106 {
107 WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
108 return TRUE;
109 }
110 }
111 else
112 {
113 try
114 {
115 tropicalStrategy currentStrategy(I,currRing);
117 gfan::ZFan* zf = groebnerFan(currentStrategy);
119 res->rtyp = fanID;
120 res->data = (char*) zf;
121 return FALSE;
122 }
123 catch (const std::exception& ex)
124 {
125 WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
126 return TRUE;
127 }
128 }
129 }
130 }
131 if ((u!=NULL) && (u->Typ()==POLY_CMD))
132 {
133 poly g = (poly) u->Data();
134 leftv v = u->next;
135 if (v==NULL)
136 {
137 try
138 {
139 gfan::ZFan* zf = groebnerFanOfPolynomial(g,currRing);
140 res->rtyp = fanID;
141 res->data = (char*) zf;
142 return FALSE;
143 }
144 catch (const std::exception& ex)
145 {
146 WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
147 return TRUE;
148 }
149 }
150 }
151 WerrorS("groebnerFan: unexpected parameters");
152 return TRUE;
153}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
BOOLEAN inequalities(leftv res, leftv args)
Definition: bbcone.cc:560
VAR int fanID
Definition: bbfan.cc:19
gfan::ZVector intStar2ZVector(const int d, const int *i)
gfan::ZFan * toFanStar(std::set< gfan::ZCone > setOfCones)
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
g
Definition: cfModGcd.cc:4090
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
void * CopyD(int t)
Definition: subexpr.cc:710
int Typ()
Definition: subexpr.cc:1019
void * Data()
Definition: subexpr.cc:1162
leftv next
Definition: subexpr.h:86
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
int j
Definition: facHensel.cc:110
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
implementation of the class groebnerCone
std::set< groebnerCone, groebnerCone_compare > groebnerCones
Definition: groebnerCone.h:24
VAR BITSET groebnerBitsetSave2
Definition: groebnerFan.cc:9
gfan::ZFan * groebnerFan(const tropicalStrategy currentStrategy)
Definition: groebnerFan.cc:28
static void setOptionRedSB()
Definition: groebnerFan.cc:14
static void undoSetOptionRedSB()
Definition: groebnerFan.cc:23
gfan::ZFan * groebnerFanOfPolynomial(poly g, ring r, bool onlyLowerHalfSpace=false)
Definition: groebnerFan.cc:36
VAR BITSET groebnerBitsetSave1
Definition: groebnerFan.cc:9
#define pIter(p)
Definition: monomials.h:37
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:12
VAR unsigned si_opt_1
Definition: options.c:5
#define SI_SAVE_OPT(A, B)
Definition: options.h:20
#define OPT_REDSB
Definition: options.h:77
#define Sy_bit(x)
Definition: options.h:31
#define SI_RESTORE_OPT(A, B)
Definition: options.h:23
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1518
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
static int idElem(const ideal F)
number of non-zero polys in F
Definition: simpleideals.h:67
groebnerCone groebnerStartingCone(const tropicalStrategy &currentStrategy)
Definition: startingCone.cc:21
#define BITSET
Definition: structs.h:16
groebnerCones groebnerTraversal(const groebnerCone startingCone)