My Project
Functions
groebnerFan.h File Reference
#include "gfanlib/gfanlib_zfan.h"

Go to the source code of this file.

Functions

gfan::ZFan * groebnerFanOfPolynomial (poly g, ring r, bool onlyLowerHalfSpace=false)
 
BOOLEAN groebnerFan (leftv res, leftv args)
 

Function Documentation

◆ groebnerFan()

BOOLEAN groebnerFan ( leftv  res,
leftv  args 
)

Definition at line 85 of file groebnerFan.cc.

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}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
VAR int fanID
Definition: bbfan.cc:19
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:1011
void * Data()
Definition: subexpr.cc:1154
leftv next
Definition: subexpr.h:86
CanonicalForm res
Definition: facAbsFact.cc:60
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
void WerrorS(const char *s)
Definition: feFopen.cc:24
@ IDEAL_CMD
Definition: grammar.cc:284
@ POLY_CMD
Definition: grammar.cc:289
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
#define NULL
Definition: omList.c:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static int idElem(const ideal F)
number of non-zero polys in F
Definition: simpleideals.h:67

◆ groebnerFanOfPolynomial()

gfan::ZFan * groebnerFanOfPolynomial ( poly  g,
ring  r,
bool  onlyLowerHalfSpace = false 
)

Definition at line 36 of file groebnerFan.cc.

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}
BOOLEAN inequalities(leftv res, leftv args)
Definition: bbcone.cc:560
BOOLEAN fullFan(leftv res, leftv args)
Definition: bbfan.cc:228
gfan::ZVector intStar2ZVector(const int d, const int *i)
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
const CanonicalForm int s
Definition: facAbsFact.cc:51
int j
Definition: facHensel.cc:110
#define pIter(p)
Definition: monomials.h:37
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1518
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592