My Project  debian-1:4.1.1-p2+ds-4build4
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 43 of file tropicalVariety.cc.

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