Functions
tropicalVariety.h File Reference

Go to the source code of this file.

Functions

BOOLEAN tropicalVariety (leftv res, leftv args)
 

Function Documentation

BOOLEAN tropicalVariety ( leftv  res,
leftv  args 
)

Definition at line 45 of file tropicalVariety.cc.

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