My Project
Loading...
Searching...
No Matches
tropicalVariety.cc
Go to the documentation of this file.
2#include "std_wrapper.h"
3#include "bbfan.h"
4#include "groebnerCone.h"
7#include "coeffs/numbers.h"
8#include "misc/options.h"
9#include "kernel/structs.h"
10
11#include "gfanlib/gfanlib_zfan.h"
12
14
15
16/***
17 * sets option(redSB)
18 **/
19static void setOptionRedSB()
20{
23}
24
25
26/***
27 * sets option(noredSB);
28 **/
29static void undoSetOptionRedSB()
30{
32}
33
34static gfan::ZFan* toZFan(std::set<gfan::ZCone> maxCones, int d)
35{
36 gfan::ZFan* zf = new gfan::ZFan(d);
37 for (std::set<gfan::ZCone>::iterator sigma = maxCones.begin(); sigma!=maxCones.end(); sigma++)
38 zf->insert(*sigma);
39 return zf;
40}
41
42
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;
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;
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 {
147 ideal stdI;
148 if (!hasFlag(u,FLAG_STD))
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))
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}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
VAR int fanID
Definition: bbfan.cc:19
int p
Definition: cfModGcd.cc:4078
g
Definition: cfModGcd.cc:4090
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int Typ()
Definition: subexpr.cc:1019
void * Data()
Definition: subexpr.cc:1162
leftv next
Definition: subexpr.h:86
ring getStartingRing() const
returns the polynomial ring over the valuation ring
ideal getStartingIdeal() const
returns the input ideal
int getExpectedAmbientDimension() const
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
#define VAR
Definition: globaldefs.h:5
@ IDEAL_CMD
Definition: grammar.cc:284
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
implementation of the class groebnerCone
ideal id_Copy(ideal h1, const ring r)
copy an ideal
#define hasFlag(A, F)
Definition: ipid.h:112
#define FLAG_STD
Definition: ipid.h:106
#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
VAR 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:35
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static int idElem(const ideal F)
number of non-zero polys in F
Definition: simpleideals.h:67
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6
#define BITSET
Definition: structs.h:16
VAR BITSET bitsetSave2
static void setOptionRedSB()
BOOLEAN tropicalVariety(leftv res, leftv args)
VAR BITSET bitsetSave1
static void undoSetOptionRedSB()
static gfan::ZFan * toZFan(std::set< gfan::ZCone > maxCones, int d)