Functions
tropicalVariety.h File Reference

Go to the source code of this file.

Functions

BOOLEAN tropicalVariety (leftv res, leftv args)
 

Function Documentation

§ tropicalVariety()

BOOLEAN tropicalVariety ( leftv  res,
leftv  args 
)

Definition at line 44 of file tropicalVariety.cc.

45 {
46  leftv u = args;
47  if ((u!=NULL) && (u->Typ()==POLY_CMD))
48  {
49  poly g = (poly) u->Data();
50  leftv v = u->next;
51  if (v==NULL)
52  {
53  try
54  {
55  ideal I = idInit(1);
56  I->m[0] = g;
57  tropicalStrategy currentStrategy(I,currRing);
58  std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,&currentStrategy);
59  res->rtyp = fanID;
60  res->data = (char*) toZFan(maxCones,currentStrategy.getExpectedAmbientDimension());
61  I->m[0] = NULL;
62  id_Delete(&I,currRing);
63  return FALSE;
64  }
65  catch (const std::exception& ex)
66  {
67  Werror("ERROR: %s",ex.what());
68  return TRUE;
69  }
70  }
71  if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
72  {
73  try
74  {
75  ideal I = idInit(1);
76  I->m[0] = g;
77  number p = (number) v->Data();
78  tropicalStrategy currentStrategy(I,p,currRing);
79  ideal startingIdeal = currentStrategy.getStartingIdeal();
80  ring startingRing = currentStrategy.getStartingRing();
81  poly gStart = startingIdeal->m[0];
82  std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing,&currentStrategy);
83  res->rtyp = fanID;
84  res->data = (char*) toZFan(maxCones,currentStrategy.getExpectedAmbientDimension());
85  I->m[0] = NULL;
86  id_Delete(&I,currRing);
87  return FALSE;
88  }
89  catch (const std::exception& ex)
90  {
91  Werror("ERROR: %s",ex.what());
92  return TRUE;
93  }
94 
95  }
96  }
97  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
98  {
99  ideal I = (ideal) u->Data();
100  leftv v = u->next;
101 
102  if ((I->m[0]!=NULL) && (idElem(I)==1))
103  {
104  poly g = I->m[0];
105  if (v==NULL)
106  {
107  try
108  {
109  tropicalStrategy currentStrategy(I,currRing);
110  std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,&currentStrategy);
111  res->rtyp = fanID;
112  res->data = (char*) toZFan(maxCones,currentStrategy.getExpectedAmbientDimension());
113  return FALSE;
114  }
115  catch (const std::exception& ex)
116  {
117  Werror("ERROR: %s",ex.what());
118  return TRUE;
119  }
120  }
121  if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
122  {
123  try
124  {
125  number p = (number) v->Data();
126  tropicalStrategy currentStrategy(I,p,currRing);
127  ideal startingIdeal = currentStrategy.getStartingIdeal();
128  ring startingRing = currentStrategy.getStartingRing();
129  poly gStart = startingIdeal->m[0];
130  std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing,&currentStrategy);
131  res->rtyp = fanID;
132  res->data = (char*) toZFan(maxCones,currentStrategy.getExpectedAmbientDimension());
133  return FALSE;
134  }
135  catch (const std::exception& ex)
136  {
137  Werror("ERROR: %s",ex.what());
138  return TRUE;
139  }
140  }
141  }
142 
143  if (v==NULL)
144  {
145  try
146  {
147  setOptionRedSB();
148  ideal stdI;
149  if (!hasFlag(u,FLAG_STD))
150  stdI = gfanlib_kStd_wrapper(I,currRing);
151  else
152  stdI = id_Copy(I,currRing);
153  tropicalStrategy currentStrategy(stdI,currRing);
154  gfan::ZFan* tropI = tropicalVariety(currentStrategy);
155  res->rtyp = fanID;
156  res->data = (char*) tropI;
158  id_Delete(&stdI,currRing);
159  return FALSE;
160  }
161  catch (const std::exception& ex)
162  {
163  Werror("ERROR: %s",ex.what());
164  return TRUE;
165  }
166  }
167  if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
168  {
169  try
170  {
171  number p = (number) v->Data();
172  ideal stdI;
173  if (!hasFlag(u,FLAG_STD))
174  stdI = gfanlib_kStd_wrapper(I,currRing);
175  else
176  stdI = id_Copy(I,currRing);
177  tropicalStrategy currentStrategy(stdI,p,currRing);
178  gfan::ZFan* tropI = tropicalVariety(currentStrategy);
179  res->rtyp = fanID;
180  res->data = (char*) tropI;
181  id_Delete(&stdI,currRing);
182  return FALSE;
183  }
184  catch (const std::exception& ex)
185  {
186  Werror("ERROR: %s",ex.what());
187  return TRUE;
188  }
189  }
190  return FALSE;
191  }
192  WerrorS("tropicalVariety: unexpected parameters");
193  return TRUE;
194 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
#define FALSE
Definition: auxiliary.h:94
static void setOptionRedSB()
return P p
Definition: myNF.cc:203
ideal id_Copy(ideal h1, const ring r)
copy an ideal
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define TRUE
Definition: auxiliary.h:98
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
int fanID
Definition: bbfan.cc:20
int Typ()
Definition: subexpr.cc:996
void * data
Definition: subexpr.h:89
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
static gfan::ZFan * toZFan(std::set< gfan::ZCone > maxCones, int d)
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6
BOOLEAN tropicalVariety(leftv res, leftv args)
#define FLAG_STD
Definition: ipid.h:106
leftv next
Definition: subexpr.h:87
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
#define hasFlag(A, F)
Definition: ipid.h:109
int rtyp
Definition: subexpr.h:92
void * Data()
Definition: subexpr.cc:1138
int idElem(const ideal F)
count non-zero elements
static void undoSetOptionRedSB()
polyrec * poly
Definition: hilb.h:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189